Page MenuHome GnuPG

encryption fails with "Invalid Length" error when using Kyber1024 keys
Open, HighPublic

Description

root@localhost:~# gpgconf -V
* GnuPG 2.5.11 (11ab27dfd7ca115d42d16453feab3ba781dfcdcd)
GNU/Linux

* Libgcrypt 1.11.2 (737cc636)
version:1.11.2:10b02:1.55:13700:
cc:110400:gcc:11.4.0:
ciphers:arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia:idea:salsa20:gost28147:chacha20:sm4:aria:
pubkeys:dsa:elgamal:rsa:ecc:kyber:
digests:crc:gostr3411-94::md4:md5:rmd160:sha1:sha256:sha512:sha3:tiger:whirlpool:stribog:blake2:sm3:
rnd-mod:getentropy:
cpu-arch:x86:amd64:
mpi-asm:amd64/mpih-add1.S:amd64/mpih-sub1.S:amd64/mpih-mul1.S:amd64/mpih-mul2.S:amd64/mpih-mul3.S:amd64/mpih-lshift.S:amd64/mpih-rshift.S:
mpi-powm:fixed-window
hwflist:intel-cpu:intel-fast-shld:intel-bmi2:intel-ssse3:intel-sse4.1:intel-pclmul:intel-aesni:intel-rdrand:intel-avx:intel-avx2:intel-fast-vpgather:intel-rdtsc:
fips-mode:n:::
rng-type:standard:1:3030000:1:
compliance:::

* GpgRT 1.55 (99381397a06564fd8ae1c623c11036a5da099a4f)

* nPth 1.8 (64905e765aad9de6054ef70a97fc30bd992ce999)

* Libassuan 3.0.2 (0f84595a4bc706d3afb969d59618244c7db3b59f)

* KSBA 1.6.7 (b14e68b)

* NTBTLS 0.3.2 (2c38007)

root@localhost:~#

Encryption tests with Kyber keys:

root@localhost:~# gpg --full-gen-key
gpg (GnuPG) 2.5.11; Copyright (C) 2025 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
   (7) DSA (set your own capabilities)
   (8) RSA (set your own capabilities)
   (9) ECC (sign and encrypt) *default*
  (10) ECC (sign only)
  (11) ECC (set your own capabilities)
  (13) Existing key
  (14) Existing key from card
  (16) ECC and Kyber
Your selection? 16
Please select the Kyber variant you want:
   (1) Kyber 768 *default*
   (2) Kyber 1024
   (3) Kyber 768 (X25519)
   (4) Kyber 1024 (X448)
Your selection? 
...
...

root@localhost:~# gpg -k
[keyboxd]
---------
pub   ed448/0x3634E4E4836D23EE 2025-08-23 [SC]
      3634E4E4836D23EEF67CD72D80E6E6DBDBA2A3121F2C315C1324861FCA9B1E17
uid                   [ultimate] Kyber1024-X448
sub   ky1024_cv448/0x0FD081C6FB1353A1 2025-08-23 [E]
      0FD081C6FB1353A108127F4C793EB9593982C0689261EE21295303F4ECC457BB

pub   ed25519/0x13AAA77D280BCF7C 2025-08-23 [SC]
      3D22960A7C4CEDD76F57C53513AAA77D280BCF7C
uid                   [ultimate] Kyber768-X25519
sub   ky768_cv25519/0x00E772737C84F0F7 2025-08-23 [E]
      00E772737C84F0F7367AB63665A12E8DA969B70640E7343CB510287019C60462

pub   brainpoolP256r1/0xB108C63C6DBDFA5C 2025-08-23 [SC]
      C9B9E2A2B3C0FE45541A4493B108C63C6DBDFA5C
uid                   [ultimate] Kyber768
sub   ky768_bp256/0x69A0D4BACC9A31BE 2025-08-23 [E]
      69A0D4BACC9A31BE1BCAEF6C67CB8B372D85F9AC5CE3B7DF3240589596206F9E

pub   brainpoolP384r1/0x5DB951683BEAD937 2025-08-23 [SC]
      D0CC4E69C02FFEDCCC8C34D35DB951683BEAD937
uid                   [ultimate] Kyber1024
sub   ky1024_bp384/0xA1B2A452320A3B69 2025-08-23 [E]
      A1B2A452320A3B697DBA9684F7D76E085EF5DDED6EFFC871543008E9024BB178

root@localhost:~#     
root@localhost:~# gpg -r Kyber768 -e 123.txt 
root@localhost:~# 
root@localhost:~# gpg -r Kyber1024 -e 123.txt 
gpg: pubkey_encrypt failed: Invalid length
gpg: 123.txt: encryption failed: Invalid length
root@localhost:~# 
root@localhost:~# gpg -r Kyber768-X25519 -e 123.txt 
root@localhost:~# 
root@localhost:~# gpg -r Kyber1024-X448 -e 123.txt 
gpg: pubkey_encrypt failed: Invalid length
gpg: 123.txt: encryption failed: Invalid length
root@localhost:~#

Details

Version
GnuPG 2.5.11

Event Timeline

William renamed this task from encryption fails with "Invalid Length" error when using ky1024_cv448 key to encryption fails with "Invalid Length" error when using Kyber1024 keys.Sat, Aug 23, 8:25 PM
William updated the task description. (Show Details)
werner added projects: gnupg26, PQC.