From 3043589095ec04279f9885db62b43e77e7e0a2d0 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Wed, 16 Sep 2026 19:43:00 +0200 Subject: [PATCH] test_pkey.rb: Add PQC algorithm SLH-DSA (FIPS 205) test Add PQC algorithm SLH-DSA (FIPS 205) test as well as existing ML-KEM (FIPS 203) and ML-DSA (FIPS 204) in test/openssl/test_pkey.rb. https://csrc.nist.gov/projects/post-quantum-cryptography OpenSSL 3.5.0 supports PQC algorithm SLH-DSA. It seems LibreSSL and AWS-LC don't support SLH-DSA yet. https://openssl-library.org/post/2025-04-08-openssl-35-final-release/ Note we don't add SLH-DSA tests in test/openssl/test_ssl.rb. SLH-DSA is used for the signature case like ML-DSA. But SLH-DSA's signature size is larger than ML-DSA's. So, I am not sure that SLH-DSA is used in SSL/TLS signature case. The used SLH-DSA parameter set in test_slh_dsa is SLH-DSA-SHA2-128s which is one of the total 12 parameter sets. This is the lowest security strength (security category 1) with small key and signature sizes. This aligns with ML-DSA-44 used in test_ml_dsa. ML-DSA-44 also has the lowest security strength (security category 2) in the 3 ML-DSA parameter sets, ML-DSA-44, ML-DSA-65, ML-DSA-87. References: * SLH-DSA parameter sets: FIPS 205 Section 11 Parameter Sets - https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.205.pdf * ML-DSA parameter sets: FIPS 204 Section 4 Parameter Sets - https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.204.pdf Assisted-by: Claude:Opus 4.6 --- test/openssl/test_pkey.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/openssl/test_pkey.rb b/test/openssl/test_pkey.rb index d9503c4e7..3cf3a329b 100644 --- a/test/openssl/test_pkey.rb +++ b/test/openssl/test_pkey.rb @@ -290,6 +290,29 @@ def test_ml_dsa assert_equal(true, pub3.verify(nil, sig, "data")) end + def test_slh_dsa + # SLH-DSA (FIPS 205) is supported on OpenSSL 3.5 or later. + return unless openssl?(3, 5, 0) + + pkey = OpenSSL::PKey.generate_key("SLH-DSA-SHA2-128s") + assert_match(/type_name=SLH-DSA-SHA2-128s/, pkey.inspect) + sig = pkey.sign(nil, "data") + # See FIPS 205 Section 11 Parameter Sets - Table 2. SLH-DSA parameter sets - + # row: SLH-DSA-SHA2-128s, column: sig bytes + assert_equal(7856, sig.bytesize) + assert_equal(true, pkey.verify(nil, sig, "data")) + + pub2 = OpenSSL::PKey.read(pkey.public_to_der) + assert_equal(true, pub2.verify(nil, sig, "data")) + + raw_public_key = pkey.raw_public_key + # See FIPS 205 Section 11 Parameter Sets - Table 2. SLH-DSA parameter sets - + # row: SLH-DSA-SHA2-128s, column: pk bytes + assert_equal(32, raw_public_key.bytesize) + pub3 = OpenSSL::PKey.new_raw_public_key("SLH-DSA-SHA2-128s", raw_public_key) + assert_equal(true, pub3.verify(nil, sig, "data")) + end + def test_ml_kem # EVP_PKEY KEM APIs were added in OpenSSL 3.0. omit "ML-KEM is not supported" unless openssl?(3, 5, 0)