]> git.ozlabs.org Git - ccan/blob - ccan/crypto/xtea/xtea.h
xtea: new module.
[ccan] / ccan / crypto / xtea / xtea.h
1 /* CC0 license (public domain) - see LICENSE file for details */
2 #ifndef CCAN_CRYPTO_XTEA_H
3 #define CCAN_CRYPTO_XTEA_H
4 /* Public domain - see LICENSE file for details */
5 #include "config.h"
6 #include <stdint.h>
7
8 /**
9  * struct xtea_secret - secret to use for xtea encryption
10  * @u.u8: an unsigned char array.
11  * @u.u32: a 32-bit integer array.
12  * @u.u64: a 64-bit integer array.
13  *
14  * Other fields may be added to the union in future.
15  */
16 struct xtea_secret {
17         union {
18                 /* Array of chars */
19                 unsigned char u8[16];
20                 /* Array of uint32_t */
21                 uint32_t u32[4];
22                 /* Array of uint64_t */
23                 uint64_t u64[2];
24         } u;
25 };
26
27 /**
28  * xtea_encipher - encrypt a 64-bit value.
29  * @secret: the xtea secret
30  * @v: the 64 bit value
31  *
32  * Returns the 64-bit encrypted value: use xtea_decipher to decrypt.
33  */
34 uint64_t xtea_encipher(const struct xtea_secret *secret, uint64_t v);
35
36 /**
37  * xtea_decipher - decrypt a 64-bit value.
38  * @secret: the xtea secret
39  * @e: the 64 bit encrypted value
40  *
41  * Returns the 64-bit decryptted value.
42  */
43 uint64_t xtea_decipher(const struct xtea_secret *secret, uint64_t e);
44
45 #endif /* CCAN_CRYPTO_SIPHASH24_H */