Adding the READ method for SHAKE
NIIBE Yutaka
gniibe at fsij.org
Tue Jun 20 02:43:31 CEST 2023
Hello,
I'd like to propose a change for the SHAKE implementation.
This comes in the context of a bug in gcry_pk_hash_sign:
https://dev.gnupg.org/T6539
I learned that there is a use case of SHAKE in CMS, specified in RFC
8802.
Use of the SHAKE One-Way Hash Functions in the Cryptographic Message
Syntax (CMS): https://www.rfc-editor.org/rfc/rfc8702.html
In RFC 8802, SHAKE128 is used with 32-byte output, and SHAKE256 is used
with 64-byte output.
I think that: when a digest function is used for signing, fixed size
makes sense, as the matter is the strength of the hash function.
Considering this use case for signing, I'd like to add the READ method
and the definition of length to the SHAKE digest functions. Attached is
the change.
How do you think?
==========================
diff --git a/cipher/keccak.c b/cipher/keccak.c
index 22c40302..76e08cb5 100644
--- a/cipher/keccak.c
+++ b/cipher/keccak.c
@@ -1630,8 +1630,8 @@ const gcry_md_spec_t _gcry_digest_spec_sha3_512 =
const gcry_md_spec_t _gcry_digest_spec_shake128 =
{
GCRY_MD_SHAKE128, {0, 1},
- "SHAKE128", shake128_asn, DIM (shake128_asn), oid_spec_shake128, 0,
- shake128_init, keccak_write, keccak_final, NULL, keccak_extract,
+ "SHAKE128", shake128_asn, DIM (shake128_asn), oid_spec_shake128, 32,
+ shake128_init, keccak_write, keccak_final, keccak_read, keccak_extract,
_gcry_shake128_hash_buffers,
sizeof (KECCAK_CONTEXT),
run_selftests
@@ -1639,8 +1639,8 @@ const gcry_md_spec_t _gcry_digest_spec_shake128 =
const gcry_md_spec_t _gcry_digest_spec_shake256 =
{
GCRY_MD_SHAKE256, {0, 1},
- "SHAKE256", shake256_asn, DIM (shake256_asn), oid_spec_shake256, 0,
- shake256_init, keccak_write, keccak_final, NULL, keccak_extract,
+ "SHAKE256", shake256_asn, DIM (shake256_asn), oid_spec_shake256, 64,
+ shake256_init, keccak_write, keccak_final, keccak_read, keccak_extract,
_gcry_shake256_hash_buffers,
sizeof (KECCAK_CONTEXT),
run_selftests
--
More information about the Gcrypt-devel
mailing list