1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpg: Implement Kyber encryption.

* g10/build-packet.c (do_pubkey_enc): Support Kyber.
* g10/pkglue.c (do_encrypt_kem): Implement.
--

Note that the code does only work for ky768_cv25519 for now.

GnuPG-bug-id: 6815
This commit is contained in:
Werner Koch 2024-04-15 12:16:40 +02:00
parent 4c20d2d273
commit c736052e9c
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 214 additions and 4 deletions

View file

@ -987,9 +987,14 @@ do_pubkey_enc( IOBUF out, int ctb, PKT_pubkey_enc *enc )
if (enc->pubkey_algo == PUBKEY_ALGO_KYBER && i == 2)
iobuf_put (a, enc->seskey_algo);
if (enc->pubkey_algo == PUBKEY_ALGO_ECDH && i == 1)
if (i == 1 && enc->pubkey_algo == PUBKEY_ALGO_ECDH)
rc = gpg_mpi_write_opaque_nohdr (a, enc->data[i]);
else if (enc->pubkey_algo == PUBKEY_ALGO_ECDH)
else if (i == 1 && enc->pubkey_algo == PUBKEY_ALGO_KYBER)
rc = gpg_mpi_write_opaque_32 (a, enc->data[i], NULL);
else if (i == 2 && enc->pubkey_algo == PUBKEY_ALGO_KYBER)
rc = gpg_mpi_write_opaque_nohdr (a, enc->data[i]);
else if (enc->pubkey_algo == PUBKEY_ALGO_ECDH
|| enc->pubkey_algo == PUBKEY_ALGO_KYBER)
rc = sos_write (a, enc->data[i], NULL);
else
rc = gpg_mpi_write (a, enc->data[i], NULL);