@@ -39,7 +39,7 @@ extern "C" {
39
39
40
40
// SHA3 constants, from NIST FIPS202.
41
41
// https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
42
- #define SHA3_ROWS 5
42
+ #define KECCAK1600_ROWS 5
43
43
#define KECCAK1600_WIDTH 1600
44
44
45
45
#define SHA3_224_CAPACITY_BYTES 56
@@ -64,11 +64,9 @@ extern "C" {
64
64
// SHAKE constants, from NIST FIPS202.
65
65
// https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
66
66
#define SHAKE_PAD_CHAR 0x1F
67
- #define SHAKE128_BLOCKSIZE (KECCAK1600_WIDTH - 128 * 2) / 8
68
- #define SHAKE256_BLOCKSIZE (KECCAK1600_WIDTH - 256 * 2) / 8
69
- #define SHAKE128_RATE 168
70
- #define SHAKE256_RATE 136
71
- #define XOF_BLOCKBYTES SHAKE128_RATE
67
+ #define SHAKE128_BLOCKSIZE ((KECCAK1600_WIDTH - 128 * 2) / 8)
68
+ #define SHAKE256_BLOCKSIZE ((KECCAK1600_WIDTH - 256 * 2) / 8)
69
+ #define XOF_BLOCKBYTES SHAKE128_BLOCKSIZE
72
70
73
71
// SHAKE128 has the maximum block size among the SHA3/SHAKE algorithms.
74
72
#define SHA3_MAX_BLOCKSIZE SHAKE128_BLOCKSIZE
@@ -78,7 +76,7 @@ typedef struct keccak_st KECCAK1600_CTX;
78
76
// The data buffer should have at least the maximum number of
79
77
// block size bytes to fit any SHA3/SHAKE block length.
80
78
struct keccak_st {
81
- uint64_t A [SHA3_ROWS ][ SHA3_ROWS ];
79
+ uint64_t A [KECCAK1600_ROWS ][ KECCAK1600_ROWS ];
82
80
size_t block_size ; // cached ctx->digest->block_size
83
81
size_t md_size ; // output length, variable in XOF (SHAKE)
84
82
size_t buf_load ; // used bytes in below buffer
@@ -400,41 +398,41 @@ OPENSSL_EXPORT uint8_t *SHAKE256(const uint8_t *data, const size_t in_len,
400
398
401
399
// SHAKE_Init initializes |ctx| with specified |block_size|, returns 1 on
402
400
// success and 0 on failure. Calls SHA3_Init under the hood.
403
- OPENSSL_EXPORT int SHAKE_Init (KECCAK1600_CTX * ctx , size_t block_size );
401
+ int SHAKE_Init (KECCAK1600_CTX * ctx , size_t block_size );
404
402
405
403
// SHAKE_Final writes |len| bytes of finalized digest to |md|, returns 1 on
406
404
// success and 0 on failure. Calls SHA3_Final under the hood.
407
- OPENSSL_EXPORT int SHAKE_Final (uint8_t * md , KECCAK1600_CTX * ctx , size_t len );
405
+ int SHAKE_Final (uint8_t * md , KECCAK1600_CTX * ctx , size_t len );
408
406
409
407
// SHA3_Reset zeros the bitstate and the amount of processed input.
410
- OPENSSL_EXPORT void SHA3_Reset (KECCAK1600_CTX * ctx );
408
+ void SHA3_Reset (KECCAK1600_CTX * ctx );
411
409
412
410
// SHA3_Init initialises |ctx| fields and returns 1 on success and 0 on failure.
413
411
OPENSSL_EXPORT int SHA3_Init (KECCAK1600_CTX * ctx , uint8_t pad ,
414
412
size_t bitlen );
415
413
416
414
// SHA3_Update processes all data blocks that don't need pad through
417
- // |SHA3_Absorb | and returns 1 and 0 on failure.
418
- OPENSSL_EXPORT int SHA3_Update (KECCAK1600_CTX * ctx , const void * data ,
415
+ // |Keccak1600_Absorb | and returns 1 and 0 on failure.
416
+ int SHA3_Update (KECCAK1600_CTX * ctx , const void * data ,
419
417
size_t len );
420
418
421
- // SHA3_Final pads the last data block and processes it through |SHA3_Absorb |.
422
- // It processes the data through |SHA3_Squeeze | and returns 1 and 0 on failure.
423
- OPENSSL_EXPORT int SHA3_Final (uint8_t * md , KECCAK1600_CTX * ctx );
419
+ // SHA3_Final pads the last data block and processes it through |Keccak1600_Absorb |.
420
+ // It processes the data through |Keccak1600_Squeeze | and returns 1 and 0 on failure.
421
+ int SHA3_Final (uint8_t * md , KECCAK1600_CTX * ctx );
424
422
425
- // SHA3_Absorb processes the largest multiple of |r| out of |len| bytes and
423
+ // Keccak1600_Absorb processes the largest multiple of |r| out of |len| bytes and
426
424
// returns the remaining number of bytes.
427
- OPENSSL_EXPORT size_t SHA3_Absorb (uint64_t A [SHA3_ROWS ][ SHA3_ROWS ],
425
+ size_t Keccak1600_Absorb (uint64_t A [KECCAK1600_ROWS ][ KECCAK1600_ROWS ],
428
426
const uint8_t * data , size_t len , size_t r );
429
427
430
- // SHA3_Squeeze generates |out| value of |len| bytes (per call). It can be called
428
+ // Keccak1600_Squeeze generates |out| value of |len| bytes (per call). It can be called
431
429
// multiple times when used as eXtendable Output Function. |padded| indicates
432
- // whether it is the first call to SHA3_Squeeze ; i.e., if the current block has
433
- // been already processed and padded right after the last call to SHA3_Absorb .
430
+ // whether it is the first call to Keccak1600_Squeeze ; i.e., if the current block has
431
+ // been already processed and padded right after the last call to Keccak1600_Absorb .
434
432
// Squeezes full blocks of |r| bytes each. When performing multiple squeezes, any
435
433
// left over bytes from previous squeezes are not consumed, and |len| must be a
436
434
// multiple of the block size (except on the final squeeze).
437
- OPENSSL_EXPORT void SHA3_Squeeze (uint64_t A [SHA3_ROWS ][ SHA3_ROWS ],
435
+ OPENSSL_EXPORT void Keccak1600_Squeeze (uint64_t A [KECCAK1600_ROWS ][ KECCAK1600_ROWS ],
438
436
uint8_t * out , size_t len , size_t r , int padded );
439
437
440
438
#if defined(__cplusplus )
0 commit comments