Home GnuPG

cipher: Fix Kyber key in SEXP, and its keygrip computation.

Description

cipher: Fix Kyber key in SEXP, and its keygrip computation.

* cipher/kem.c (kem_generate): Include public key part in SEXP of
private key.
(kem_compute_keygrip): Fix keygrip computation.
  • Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

Details

Provenance
gniibeAuthored on Mar 4 2024, 5:09 AM
Parents
rCb757f4130af9: mpi: Fix ECC computation on hppa.
Branches
Unknown
Tags
Unknown

Event Timeline

werner added inline comments.
/cipher/kem.c
264

Thanks.

313

FWIW: This change is not required. NAME is a c-string and thuis includes the nul. As stated in the description .namelen is only used to avoid calling strlen when looping over key_infos.

/cipher/kem.c
313

It's sexp_nth_data, we use here. I observed 0x03 instead of 0x00.
If sexp_nth_string, it worked.

/cipher/kem.c
313

I think you mixed up NAME and ALGO. For ALGO your description would be okay. For NAME we have:

  • We are passing NAME with ALGOLEN+1 to _gcry_md_write.
  • NAME is set in the condition of the above for-loop.
  • Thus NAME points to a string in the kem_infos table and there is a trailing nul.
  • ALGOLEN has the same value as strlen (name).
  • Adding 1 to ALGOLEN thus passes the nul also to _gcry_md_write

Or did I miss something?

/cipher/kem.c
313

You are right. I was confused. I'm going to revert the change.