Skip to content

Commit d31ca86

Browse files
committed
Introduce the concept of "domain" for SHAKE XOF.
1 parent 4db24a7 commit d31ca86

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/hashes/sha3.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,19 @@ int keccak_done(hash_state *md, unsigned char *out)
353353
#endif
354354

355355
#ifdef LTC_SHA3
356-
static LTC_INLINE int s_sha3_shake_done(hash_state *md, unsigned char *out, unsigned long outlen, process_fn proc_f)
356+
static LTC_INLINE int s_sha3_shake_done(hash_state *md, unsigned char *out, unsigned long outlen, unsigned char domain, process_fn proc_f)
357357
{
358358
/* IMPORTANT NOTE: sha3_shake_done can be called many times */
359359
unsigned long idx;
360360
unsigned i;
361361

362362
if (outlen == 0) return CRYPT_OK; /* nothing to do */
363-
LTC_ARGCHK(md != NULL);
363+
LTC_ARGCHK(md != NULL);
364364
LTC_ARGCHK(out != NULL);
365365

366366
if (!md->sha3.xof_flag) {
367367
/* shake_xof operation must be done only once */
368-
md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (CONST64(0x1F) << (md->sha3.byte_index * 8)));
368+
md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (((ulong64)(domain)) << (md->sha3.byte_index * 8)));
369369
md->sha3.s[SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words - 1] ^= CONST64(0x8000000000000000);
370370
proc_f(md->sha3.s);
371371
/* store sha3.s[] as little-endian bytes into sha3.sb */
@@ -392,13 +392,13 @@ static LTC_INLINE int s_sha3_shake_done(hash_state *md, unsigned char *out, unsi
392392

393393
int sha3_shake_done(hash_state *md, unsigned char *out, unsigned long outlen)
394394
{
395-
return s_sha3_shake_done(md, out, outlen, s_keccakf);
395+
return s_sha3_shake_done(md, out, outlen, 0x1f, s_keccakf);
396396
}
397397

398398
#if defined LTC_TURBO_SHAKE
399399
int turbo_shake_done(hash_state *md, unsigned char *out, unsigned long outlen)
400400
{
401-
return s_sha3_shake_done(md, out, outlen, s_keccak_turbo_f);
401+
return s_sha3_shake_done(md, out, outlen, 0x1f, s_keccak_turbo_f);
402402
}
403403
#endif
404404

0 commit comments

Comments
 (0)