Skip to content

Commit ff3cbd8

Browse files
committed
Rename Absorb and Squeeze functions to Keccak1600_ layer specific
Clean redefinition of SHAKE blocksize/rate macros; Update their use inside MLKEM and MLDSA.
1 parent 697acc6 commit ff3cbd8

File tree

8 files changed

+68
-70
lines changed

8 files changed

+68
-70
lines changed

crypto/dilithium/pqcrystals_dilithium_ref_common/params.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct {
4141
#define ML_DSA_L_MAX (7)
4242
#define ML_DSA_C_TILDE_BYTES_MAX (64)
4343
#define ML_DSA_POLYW1_PACKEDBYTES_MAX (192)
44-
#define ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX ((227 + SHAKE256_RATE - 1)/SHAKE256_RATE)
44+
#define ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX ((227 + SHAKE256_BLOCKSIZE - 1)/SHAKE256_BLOCKSIZE)
4545
#define ML_DSA_POLYZ_PACKEDBYTES_MAX (576)
4646

4747
void ml_dsa_44_params_init(ml_dsa_params *params);

crypto/dilithium/pqcrystals_dilithium_ref_common/poly.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ static unsigned int ml_dsa_rej_uniform(int32_t *a,
301301
* - const uint8_t seed[]: byte array with seed of length SEEDBYTES
302302
* - uint16_t nonce: 2-byte nonce
303303
**************************************************/
304-
#define POLY_UNIFORM_NBLOCKS ((768 + SHAKE128_RATE - 1)/ SHAKE128_RATE)
304+
#define POLY_UNIFORM_NBLOCKS ((768 + SHAKE128_BLOCKSIZE - 1)/ SHAKE128_BLOCKSIZE)
305305
void ml_dsa_poly_uniform(ml_dsa_poly *a,
306306
const uint8_t seed[ML_DSA_SEEDBYTES],
307307
uint16_t nonce)
308308
{
309309
unsigned int i, ctr, off;
310-
unsigned int buflen = POLY_UNIFORM_NBLOCKS*SHAKE128_RATE;
311-
uint8_t buf[POLY_UNIFORM_NBLOCKS*SHAKE128_RATE + 2];
310+
unsigned int buflen = POLY_UNIFORM_NBLOCKS*SHAKE128_BLOCKSIZE;
311+
uint8_t buf[POLY_UNIFORM_NBLOCKS*SHAKE128_BLOCKSIZE + 2];
312312
KECCAK1600_CTX state;
313313

314314
uint8_t t[2];
@@ -328,7 +328,7 @@ void ml_dsa_poly_uniform(ml_dsa_poly *a,
328328
buf[i] = buf[buflen - off + i];
329329

330330
SHAKE_Final(buf + off, &state, POLY_UNIFORM_NBLOCKS * SHAKE128_BLOCKSIZE);
331-
buflen = SHAKE128_RATE + off;
331+
buflen = SHAKE128_BLOCKSIZE + off;
332332
ctr += ml_dsa_rej_uniform(a->coeffs + ctr, ML_DSA_N - ctr, buf, buflen);
333333
}
334334
/* FIPS 204. Section 3.6.3 Destruction of intermediate values. */
@@ -409,8 +409,8 @@ void ml_dsa_poly_uniform_eta(ml_dsa_params *params,
409409
uint16_t nonce)
410410
{
411411
unsigned int ctr;
412-
unsigned int buflen = ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_RATE;
413-
uint8_t buf[ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_RATE];
412+
unsigned int buflen = ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_BLOCKSIZE;
413+
uint8_t buf[ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_BLOCKSIZE];
414414
KECCAK1600_CTX state;
415415

416416
uint8_t t[2];
@@ -426,7 +426,7 @@ void ml_dsa_poly_uniform_eta(ml_dsa_params *params,
426426

427427
while(ctr < ML_DSA_N) {
428428
SHAKE_Final(buf, &state, SHAKE256_BLOCKSIZE);
429-
ctr += rej_eta(params, a->coeffs + ctr, ML_DSA_N - ctr, buf, SHAKE256_RATE);
429+
ctr += rej_eta(params, a->coeffs + ctr, ML_DSA_N - ctr, buf, SHAKE256_BLOCKSIZE);
430430
}
431431
/* FIPS 204. Section 3.6.3 Destruction of intermediate values. */
432432
OPENSSL_cleanse(buf, sizeof(buf));
@@ -445,13 +445,13 @@ void ml_dsa_poly_uniform_eta(ml_dsa_params *params,
445445
* - const uint8_t seed[]: byte array with seed of length CRHBYTES
446446
* - uint16_t nonce: 16-bit nonce
447447
**************************************************/
448-
#define POLY_UNIFORM_GAMMA1_NBLOCKS ((ML_DSA_POLYZ_PACKEDBYTES_MAX + SHAKE256_RATE - 1) / SHAKE256_RATE)
448+
#define POLY_UNIFORM_GAMMA1_NBLOCKS ((ML_DSA_POLYZ_PACKEDBYTES_MAX + SHAKE256_BLOCKSIZE - 1) / SHAKE256_BLOCKSIZE)
449449
void ml_dsa_poly_uniform_gamma1(ml_dsa_params *params,
450450
ml_dsa_poly *a,
451451
const uint8_t seed[ML_DSA_CRHBYTES],
452452
uint16_t nonce)
453453
{
454-
uint8_t buf[POLY_UNIFORM_GAMMA1_NBLOCKS * SHAKE256_RATE];
454+
uint8_t buf[POLY_UNIFORM_GAMMA1_NBLOCKS * SHAKE256_BLOCKSIZE];
455455
KECCAK1600_CTX state;
456456

457457
uint8_t t[2];
@@ -483,7 +483,7 @@ void ml_dsa_poly_uniform_gamma1(ml_dsa_params *params,
483483
void ml_dsa_poly_challenge(ml_dsa_params *params, ml_dsa_poly *c, const uint8_t *seed) {
484484
unsigned int i, b, pos;
485485
uint64_t signs;
486-
uint8_t buf[SHAKE256_RATE];
486+
uint8_t buf[SHAKE256_BLOCKSIZE];
487487
KECCAK1600_CTX state;
488488

489489
SHAKE_Init(&state, SHAKE256_BLOCKSIZE);
@@ -501,7 +501,7 @@ void ml_dsa_poly_challenge(ml_dsa_params *params, ml_dsa_poly *c, const uint8_t
501501
}
502502
for(i = ML_DSA_N-params->tau; i < ML_DSA_N; ++i) {
503503
do {
504-
if(pos >= SHAKE256_RATE) {
504+
if(pos >= SHAKE256_BLOCKSIZE) {
505505
SHAKE_Final(buf, &state, SHAKE256_BLOCKSIZE);
506506
pos = 0;
507507
}

crypto/fipsmodule/ml_kem/ml_kem_ref/symmetric-shake.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void kyber_shake128_absorb(KECCAK1600_CTX *ctx,
3737
* Name: kyber_shake128_squeeze
3838
*
3939
* Description: Squeeze step of SHAKE128 XOF. Squeezes full blocks of
40-
* SHAKE128_RATE bytes each. Can be called multiple times
40+
* SHAKE128_BLOCKSIZE bytes each. Can be called multiple times
4141
* to keep squeezing. Assumes new block has not yet been
4242
* started.
4343
*

crypto/fipsmodule/sha/asm/keccak1600-armv8.pl

+16-16
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@
343343
AARCH64_VALIDATE_LINK_REGISTER
344344
ret
345345
.size KeccakF1600,.-KeccakF1600
346-
.globl SHA3_Absorb_hw
347-
.type SHA3_Absorb_hw,%function
346+
.globl Keccak1600_Absorb_hw
347+
.type Keccak1600_Absorb_hw,%function
348348
.align 5
349-
SHA3_Absorb_hw:
349+
Keccak1600_Absorb_hw:
350350
AARCH64_SIGN_LINK_REGISTER
351351
stp x29,x30,[sp,#-128]!
352352
add x29,sp,#0
@@ -438,15 +438,15 @@
438438
ldp x29,x30,[sp],#128
439439
AARCH64_VALIDATE_LINK_REGISTER
440440
ret
441-
.size SHA3_Absorb_hw,.-SHA3_Absorb_hw
441+
.size Keccak1600_Absorb_hw,.-Keccak1600_Absorb_hw
442442
___
443443
{
444444
my ($A_flat,$out,$len,$bsz) = map("x$_",(19..22));
445445
$code.=<<___;
446-
.globl SHA3_Squeeze_hw
447-
.type SHA3_Squeeze_hw,%function
446+
.globl Keccak1600_Squeeze_hw
447+
.type Keccak1600_Squeeze_hw,%function
448448
.align 5
449-
SHA3_Squeeze_hw:
449+
Keccak1600_Squeeze_hw:
450450
AARCH64_SIGN_LINK_REGISTER
451451
stp x29,x30,[sp,#-48]!
452452
add x29,sp,#0
@@ -512,7 +512,7 @@
512512
ldp x29,x30,[sp],#48
513513
AARCH64_VALIDATE_LINK_REGISTER
514514
ret
515-
.size SHA3_Squeeze_hw,.-SHA3_Squeeze_hw
515+
.size Keccak1600_Squeeze_hw,.-Keccak1600_Squeeze_hw
516516
___
517517
} }}}
518518
{{{
@@ -650,10 +650,10 @@
650650
my ($ctx,$inp,$len,$bsz) = map("x$_",(0..3));
651651

652652
$code.=<<___;
653-
.globl SHA3_Absorb_cext
654-
.type SHA3_Absorb_cext,%function
653+
.globl Keccak1600_Absorb_cext
654+
.type Keccak1600_Absorb_cext,%function
655655
.align 5
656-
SHA3_Absorb_cext:
656+
Keccak1600_Absorb_cext:
657657
AARCH64_SIGN_LINK_REGISTER
658658
stp x29,x30,[sp,#-80]!
659659
add x29,sp,#0
@@ -722,16 +722,16 @@
722722
ldp x29,x30,[sp],#80
723723
AARCH64_VALIDATE_LINK_REGISTER
724724
ret
725-
.size SHA3_Absorb_cext,.-SHA3_Absorb_cext
725+
.size Keccak1600_Absorb_cext,.-Keccak1600_Absorb_cext
726726
___
727727
}
728728
{
729729
my ($ctx,$out,$len,$bsz) = map("x$_",(0..3));
730730
$code.=<<___;
731-
.globl SHA3_Squeeze_cext
732-
.type SHA3_Squeeze_cext,%function
731+
.globl Keccak1600_Squeeze_cext
732+
.type Keccak1600_Squeeze_cext,%function
733733
.align 5
734-
SHA3_Squeeze_cext:
734+
Keccak1600_Squeeze_cext:
735735
AARCH64_SIGN_LINK_REGISTER
736736
stp x29,x30,[sp,#-16]!
737737
add x29,sp,#0
@@ -787,7 +787,7 @@
787787
ldr x29,[sp],#16
788788
AARCH64_VALIDATE_LINK_REGISTER
789789
ret
790-
.size SHA3_Squeeze_cext,.-SHA3_Squeeze_cext
790+
.size Keccak1600_Squeeze_cext,.-Keccak1600_Squeeze_cext
791791
___
792792
} }}}
793793
$code.=<<___;

crypto/fipsmodule/sha/internal.h

+19-21
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939

4040
// SHA3 constants, from NIST FIPS202.
4141
// https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
42-
#define SHA3_ROWS 5
42+
#define KECCAK1600_ROWS 5
4343
#define KECCAK1600_WIDTH 1600
4444

4545
#define SHA3_224_CAPACITY_BYTES 56
@@ -64,11 +64,9 @@ extern "C" {
6464
// SHAKE constants, from NIST FIPS202.
6565
// https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
6666
#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
7270

7371
// SHAKE128 has the maximum block size among the SHA3/SHAKE algorithms.
7472
#define SHA3_MAX_BLOCKSIZE SHAKE128_BLOCKSIZE
@@ -78,7 +76,7 @@ typedef struct keccak_st KECCAK1600_CTX;
7876
// The data buffer should have at least the maximum number of
7977
// block size bytes to fit any SHA3/SHAKE block length.
8078
struct keccak_st {
81-
uint64_t A[SHA3_ROWS][SHA3_ROWS];
79+
uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS];
8280
size_t block_size; // cached ctx->digest->block_size
8381
size_t md_size; // output length, variable in XOF (SHAKE)
8482
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,
400398

401399
// SHAKE_Init initializes |ctx| with specified |block_size|, returns 1 on
402400
// 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);
404402

405403
// SHAKE_Final writes |len| bytes of finalized digest to |md|, returns 1 on
406404
// 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);
408406

409407
// 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);
411409

412410
// SHA3_Init initialises |ctx| fields and returns 1 on success and 0 on failure.
413411
OPENSSL_EXPORT int SHA3_Init(KECCAK1600_CTX *ctx, uint8_t pad,
414412
size_t bitlen);
415413

416414
// 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,
419417
size_t len);
420418

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);
424422

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
426424
// 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],
428426
const uint8_t *data, size_t len, size_t r);
429427

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
431429
// 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.
434432
// Squeezes full blocks of |r| bytes each. When performing multiple squeezes, any
435433
// left over bytes from previous squeezes are not consumed, and |len| must be a
436434
// 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],
438436
uint8_t *out, size_t len, size_t r, int padded);
439437

440438
#if defined(__cplusplus)

crypto/fipsmodule/sha/keccak1600.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#if !defined(KECCAK1600_ASM)
2525

26-
static const uint8_t rhotates[SHA3_ROWS][SHA3_ROWS] = {
26+
static const uint8_t rhotates[KECCAK1600_ROWS][KECCAK1600_ROWS] = {
2727
{ 0, 1, 62, 28, 27 },
2828
{ 36, 44, 6, 55, 20 },
2929
{ 3, 10, 43, 25, 39 },
@@ -103,9 +103,9 @@ static uint64_t ROL64(uint64_t val, int offset)
103103
// it with actual data (see round loop below).
104104
// It ensures best compiler interpretation to assembly and provides best
105105
// instruction per processed byte ratio at minimal round unroll factor.
106-
static void Round(uint64_t R[SHA3_ROWS][SHA3_ROWS], uint64_t A[SHA3_ROWS][SHA3_ROWS], size_t i)
106+
static void Round(uint64_t R[KECCAK1600_ROWS][KECCAK1600_ROWS], uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], size_t i)
107107
{
108-
uint64_t C[SHA3_ROWS], D[SHA3_ROWS];
108+
uint64_t C[KECCAK1600_ROWS], D[KECCAK1600_ROWS];
109109

110110
assert(i < (sizeof(iotas) / sizeof(iotas[0])));
111111

@@ -222,9 +222,9 @@ static void Round(uint64_t R[SHA3_ROWS][SHA3_ROWS], uint64_t A[SHA3_ROWS][SHA3_R
222222
#endif
223223
}
224224

225-
static void KeccakF1600(uint64_t A[SHA3_ROWS][SHA3_ROWS])
225+
static void KeccakF1600(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS])
226226
{
227-
uint64_t T[SHA3_ROWS][SHA3_ROWS];
227+
uint64_t T[KECCAK1600_ROWS][KECCAK1600_ROWS];
228228
size_t i;
229229

230230
#ifdef KECCAK_COMPLEMENTING_TRANSFORM
@@ -323,15 +323,15 @@ static uint64_t BitDeinterleave(uint64_t Ai)
323323
return Ai;
324324
}
325325

326-
// SHA3_Absorb can be called multiple times; at each invocation the
326+
// Keccak1600_Absorb can be called multiple times; at each invocation the
327327
// largest multiple of |r| out of |len| bytes are processed. The
328328
// remaining amount of bytes is returned. This is done to spare caller
329329
// trouble of calculating the largest multiple of |r|. |r| can be viewed
330330
// as blocksize. It is commonly (1600 - 256*n)/8, e.g. 168, 136, 104,
331331
// 72, but can also be (1600 - 448)/8 = 144. All this means that message
332332
// padding and intermediate sub-block buffering, byte- or bitwise, is
333333
// caller's responsibility.
334-
size_t SHA3_Absorb(uint64_t A[SHA3_ROWS][SHA3_ROWS], const uint8_t *inp, size_t len,
334+
size_t Keccak1600_Absorb(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], const uint8_t *inp, size_t len,
335335
size_t r)
336336
{
337337
uint64_t *A_flat = (uint64_t *)A;
@@ -356,8 +356,8 @@ size_t SHA3_Absorb(uint64_t A[SHA3_ROWS][SHA3_ROWS], const uint8_t *inp, size_t
356356
return len;
357357
}
358358

359-
void SHA3_Squeeze(uint64_t A[SHA3_ROWS][SHA3_ROWS], uint8_t *out, size_t len, size_t r, int padded)
360-
// SHA3_Squeeze can be called multiple times to incrementally
359+
void Keccak1600_Squeeze(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], uint8_t *out, size_t len, size_t r, int padded)
360+
// Keccak1600_Squeeze can be called multiple times to incrementally
361361
{
362362
uint64_t *A_flat = (uint64_t *)A;
363363
size_t i, w = r / 8;
@@ -396,19 +396,19 @@ void SHA3_Squeeze(uint64_t A[SHA3_ROWS][SHA3_ROWS], uint8_t *out, size_t len, si
396396

397397
#else
398398

399-
size_t SHA3_Absorb_hw(uint64_t A[SHA3_ROWS][SHA3_ROWS], const uint8_t *inp, size_t len,
399+
size_t Keccak1600_Absorb_hw(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], const uint8_t *inp, size_t len,
400400
size_t r);
401401

402-
size_t SHA3_Absorb(uint64_t A[SHA3_ROWS][SHA3_ROWS], const uint8_t *inp, size_t len,
402+
size_t Keccak1600_Absorb(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], const uint8_t *inp, size_t len,
403403
size_t r) {
404-
return SHA3_Absorb_hw(A, inp, len, r);
404+
return Keccak1600_Absorb_hw(A, inp, len, r);
405405
}
406406

407-
size_t SHA3_Squeeze_hw(uint64_t A[SHA3_ROWS][SHA3_ROWS], const uint8_t *out, size_t len,
407+
size_t Keccak1600_Squeeze_hw(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], const uint8_t *out, size_t len,
408408
size_t r, int padded);
409409

410-
void SHA3_Squeeze(uint64_t A[SHA3_ROWS][SHA3_ROWS], uint8_t *out, size_t len, size_t r, int padded) {
411-
SHA3_Squeeze_hw(A, out, len, r, padded);
410+
void Keccak1600_Squeeze(uint64_t A[KECCAK1600_ROWS][KECCAK1600_ROWS], uint8_t *out, size_t len, size_t r, int padded) {
411+
Keccak1600_Squeeze_hw(A, out, len, r, padded);
412412
}
413413

414414
#endif // !KECCAK1600_ASM

crypto/fipsmodule/sha/sha3.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ int SHA3_Update(KECCAK1600_CTX *ctx, const void *data, size_t len) {
180180
// leaving the rest for later processing.
181181
memcpy(ctx->buf + num, data_ptr_copy, rem);
182182
data_ptr_copy += rem, len -= rem;
183-
if (SHA3_Absorb(ctx->A, ctx->buf, block_size, block_size) != 0 ) {
183+
if (Keccak1600_Absorb(ctx->A, ctx->buf, block_size, block_size) != 0 ) {
184184
return 0;
185185
}
186186
ctx->buf_load = 0;
187187
// ctx->buf is processed, ctx->buf_load is guaranteed to be zero
188188
}
189189

190190
if (len >= block_size) {
191-
rem = SHA3_Absorb(ctx->A, data_ptr_copy, len, block_size);
191+
rem = Keccak1600_Absorb(ctx->A, data_ptr_copy, len, block_size);
192192
}
193193
else {
194194
rem = len;
@@ -218,12 +218,12 @@ int SHA3_Final(uint8_t *md, KECCAK1600_CTX *ctx) {
218218
ctx->buf[num] = ctx->pad;
219219
ctx->buf[block_size - 1] |= 0x80;
220220

221-
if (SHA3_Absorb(ctx->A, ctx->buf, block_size, block_size) != 0) {
221+
if (Keccak1600_Absorb(ctx->A, ctx->buf, block_size, block_size) != 0) {
222222
return 0;
223223
}
224224
}
225225

226-
SHA3_Squeeze(ctx->A, md, ctx->md_size, block_size, ctx->padded);
226+
Keccak1600_Squeeze(ctx->A, md, ctx->md_size, block_size, ctx->padded);
227227
ctx->padded = 1;
228228

229229
FIPS_service_indicator_update_state();

0 commit comments

Comments
 (0)