diff options
Diffstat (limited to 'src/lib/libcrypto/sha/sha3_internal.h')
| -rw-r--r-- | src/lib/libcrypto/sha/sha3_internal.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/libcrypto/sha/sha3_internal.h b/src/lib/libcrypto/sha/sha3_internal.h new file mode 100644 index 0000000000..ba24f43478 --- /dev/null +++ b/src/lib/libcrypto/sha/sha3_internal.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | // sha3.h | ||
| 2 | // 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi> | ||
| 3 | |||
| 4 | #ifndef SHA3_H | ||
| 5 | #define SHA3_H | ||
| 6 | |||
| 7 | #include <stddef.h> | ||
| 8 | #include <stdint.h> | ||
| 9 | |||
| 10 | #ifndef KECCAKF_ROUNDS | ||
| 11 | #define KECCAKF_ROUNDS 24 | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #ifndef ROTL64 | ||
| 15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) | ||
| 16 | #endif | ||
| 17 | |||
| 18 | // state context | ||
| 19 | typedef struct { | ||
| 20 | union { // state: | ||
| 21 | uint8_t b[200]; // 8-bit bytes | ||
| 22 | uint64_t q[25]; // 64-bit words | ||
| 23 | } st; | ||
| 24 | int pt, rsiz, mdlen; // these don't overflow | ||
| 25 | } sha3_ctx_t; | ||
| 26 | |||
| 27 | // Compression function. | ||
| 28 | void sha3_keccakf(uint64_t st[25]); | ||
| 29 | |||
| 30 | // OpenSSL - like interfece | ||
| 31 | int sha3_init(sha3_ctx_t *c, int mdlen); // mdlen = hash output in bytes | ||
| 32 | int sha3_update(sha3_ctx_t *c, const void *data, size_t len); | ||
| 33 | int sha3_final(void *md, sha3_ctx_t *c); // digest goes to md | ||
| 34 | |||
| 35 | // compute a sha3 hash (md) of given byte length from "in" | ||
| 36 | void *sha3(const void *in, size_t inlen, void *md, int mdlen); | ||
| 37 | |||
| 38 | // SHAKE128 and SHAKE256 extensible-output functions | ||
| 39 | #define shake128_init(c) sha3_init(c, 16) | ||
| 40 | #define shake256_init(c) sha3_init(c, 32) | ||
| 41 | #define shake_update sha3_update | ||
| 42 | |||
| 43 | void shake_xof(sha3_ctx_t *c); | ||
| 44 | void shake_out(sha3_ctx_t *c, void *out, size_t len); | ||
| 45 | |||
| 46 | #endif | ||
| 47 | |||
