diff options
Diffstat (limited to 'src/lib/libcrypto/sha/sha3_internal.h')
| -rw-r--r-- | src/lib/libcrypto/sha/sha3_internal.h | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/lib/libcrypto/sha/sha3_internal.h b/src/lib/libcrypto/sha/sha3_internal.h index 1b4c6675ad..3227e6120f 100644 --- a/src/lib/libcrypto/sha/sha3_internal.h +++ b/src/lib/libcrypto/sha/sha3_internal.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha3_internal.h,v 1.3 2023/04/15 18:07:44 jsing Exp $ */ | 1 | /* $OpenBSD: sha3_internal.h,v 1.4 2023/04/15 18:14:21 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * The MIT License (MIT) | 3 | * The MIT License (MIT) |
| 4 | * | 4 | * |
| @@ -23,9 +23,6 @@ | |||
| 23 | * SOFTWARE. | 23 | * SOFTWARE. |
| 24 | */ | 24 | */ |
| 25 | 25 | ||
| 26 | // sha3.h | ||
| 27 | // 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi> | ||
| 28 | |||
| 29 | #ifndef SHA3_H | 26 | #ifndef SHA3_H |
| 30 | #define SHA3_H | 27 | #define SHA3_H |
| 31 | 28 | ||
| @@ -40,27 +37,23 @@ | |||
| 40 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) | 37 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) |
| 41 | #endif | 38 | #endif |
| 42 | 39 | ||
| 43 | // state context | ||
| 44 | typedef struct { | 40 | typedef struct { |
| 45 | union { // state: | 41 | union { |
| 46 | uint8_t b[200]; // 8-bit bytes | 42 | uint8_t b[200]; /* State as 8 bit bytes. */ |
| 47 | uint64_t q[25]; // 64-bit words | 43 | uint64_t q[25]; /* State as 64 bit words. */ |
| 48 | } st; | 44 | } st; |
| 49 | int pt, rsiz, mdlen; // these don't overflow | 45 | int pt, rsiz, mdlen; |
| 50 | } sha3_ctx_t; | 46 | } sha3_ctx_t; |
| 51 | 47 | ||
| 52 | // Compression function. | ||
| 53 | void sha3_keccakf(uint64_t st[25]); | 48 | void sha3_keccakf(uint64_t st[25]); |
| 54 | 49 | ||
| 55 | // OpenSSL - like interfece | 50 | int sha3_init(sha3_ctx_t *c, int mdlen); |
| 56 | int sha3_init(sha3_ctx_t *c, int mdlen); // mdlen = hash output in bytes | ||
| 57 | int sha3_update(sha3_ctx_t *c, const void *data, size_t len); | 51 | int sha3_update(sha3_ctx_t *c, const void *data, size_t len); |
| 58 | int sha3_final(void *md, sha3_ctx_t *c); // digest goes to md | 52 | int sha3_final(void *md, sha3_ctx_t *c); |
| 59 | 53 | ||
| 60 | // compute a sha3 hash (md) of given byte length from "in" | ||
| 61 | void *sha3(const void *in, size_t inlen, void *md, int mdlen); | 54 | void *sha3(const void *in, size_t inlen, void *md, int mdlen); |
| 62 | 55 | ||
| 63 | // SHAKE128 and SHAKE256 extensible-output functions | 56 | /* SHAKE128 and SHAKE256 extensible-output functions. */ |
| 64 | #define shake128_init(c) sha3_init(c, 16) | 57 | #define shake128_init(c) sha3_init(c, 16) |
| 65 | #define shake256_init(c) sha3_init(c, 32) | 58 | #define shake256_init(c) sha3_init(c, 32) |
| 66 | #define shake_update sha3_update | 59 | #define shake_update sha3_update |
| @@ -69,4 +62,3 @@ void shake_xof(sha3_ctx_t *c); | |||
| 69 | void shake_out(sha3_ctx_t *c, void *out, size_t len); | 62 | void shake_out(sha3_ctx_t *c, void *out, size_t len); |
| 70 | 63 | ||
| 71 | #endif | 64 | #endif |
| 72 | |||
