-
Notifications
You must be signed in to change notification settings - Fork 14
/
hh_crypto.h
39 lines (29 loc) · 1.42 KB
/
hh_crypto.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* This file is part of Hedgehog LISP.
* Copyright (C) 2005 Kenneth Oksanen.
* See file LICENSE.LGPL for pertinent licensing conditions.
*
* Author: Kenneth Oksanen <[email protected]>
*/
/* This file includes concise implementations of the SHA-256 hash
function and a slightly modified variant of the XXTEA for 128-bit
blocks. */
#include "hh_common.h"
/* Compute a 256-bit (32-byte) cryptographically strong hash value of
the given `n_bytes' in `data'. The `digest' must refer to at least
32 bytes of memory which are overwritten by the hash. */
void hh_sha256(unsigned char *data, unsigned long n_bytes,
unsigned char *digest);
/* Encrypt or decrypt, depending on whether `encrypt' is non-zero or
zero, the given `n_bytes_in' bytes in `in' with the given 16 bytes
of password data in `password'. The `out' must refer to at least
`n_bytes' + 19 bytes of memory, some of which may be unused. The
`*n_bytes_out' is assigned the actual number of bytes in the
en/decrypted message.
This function returns always one on encryption or on successful
decryption. However, should the given input buffer be of incorrect
length for the decryption to finish, then the function returns
zero. The caller can assume this to indicate an attack. */
int hh_xxtea(unsigned char *in, hh_word_t n_bytes_in,
unsigned char *out, hh_word_t *n_bytes_out,
int encrypt,
const unsigned char *password);