GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add SLH-DSA algorithms to pkitesting CertificateBuilder (#16080) · chrisvest/netty@1eea56f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pkitesting/src
    • main/java/io/netty/pkitesting
      • Algorithms.java
      • CertificateBuilder.java
    • test/java/io/netty/pkitesting
      • CertificateBuilderTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pkitesting/src/main/java/io/netty/pkitesting/Algorithms.java‎

Copy file name to clipboardExpand all lines: pkitesting/src/main/java/io/netty/pkitesting/Algorithms.java
+40-4Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@ static String oidForAlgorithmName(String algorithmIdentifier) {
5454
return "2.16.840.1.101.3.4.3.18";
5555
case "ml-dsa-87":
5656
return "2.16.840.1.101.3.4.3.19";
57+
case "slh-dsa-sha2-128s":
58+
return "2.16.840.1.101.3.4.3.20";
59+
case "slh-dsa-sha2-128f":
60+
return "2.16.840.1.101.3.4.3.21";
61+
case "slh-dsa-shake-128s":
62+
return "2.16.840.1.101.3.4.3.22";
63+
case "slh-dsa-shake-128f":
64+
return "2.16.840.1.101.3.4.3.23";
65+
case "slh-dsa-sha2-192s":
66+
return "2.16.840.1.101.3.4.3.24";
67+
case "slh-dsa-sha2-192f":
68+
return "2.16.840.1.101.3.4.3.25";
69+
case "slh-dsa-shake-192s":
70+
return "2.16.840.1.101.3.4.3.26";
71+
case "slh-dsa-shake-192f":
72+
return "2.16.840.1.101.3.4.3.27";
73+
case "slh-dsa-sha2-256s":
74+
return "2.16.840.1.101.3.4.3.28";
75+
case "slh-dsa-sha2-256f":
76+
return "2.16.840.1.101.3.4.3.29";
77+
case "slh-dsa-shake-256s":
78+
return "2.16.840.1.101.3.4.3.30";
79+
case "slh-dsa-shake-256f":
80+
return "2.16.840.1.101.3.4.3.31";
5781
default:
5882
throw new UnsupportedOperationException("Algorithm not supported: " + algorithmIdentifier);
5983
}
@@ -62,13 +86,25 @@ static String oidForAlgorithmName(String algorithmIdentifier) {
6286
static KeyPairGenerator keyPairGenerator(String keyType, AlgorithmParameterSpec spec,
6387
SecureRandom rng, Provider provider) throws GeneralSecurityException {
6488
try {
65-
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(keyType);
66-
keyGen.initialize(spec, rng);
89+
KeyPairGenerator keyGen;
90+
if (provider == null) {
91+
keyGen = KeyPairGenerator.getInstance(keyType);
92+
} else {
93+
keyGen = KeyPairGenerator.getInstance(keyType, provider);
94+
}
95+
try {
96+
keyGen.initialize(spec, rng);
97+
} catch (UnsupportedOperationException ignore) {
98+
// The key generators for some algorithms, in some providers, don't support key gen initialization.
99+
}
67100
return keyGen;
68101
} catch (GeneralSecurityException e) {
102+
if (provider != null) {
103+
// Don't fall back to BouncyCastle if we were explicitly told to use a specific provider.
104+
throw e;
105+
}
69106
try {
70-
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(keyType,
71-
provider != null ? provider : bouncyCastle());
107+
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(keyType, bouncyCastle());
72108
keyGen.initialize(spec, rng);
73109
return keyGen;
74110
} catch (GeneralSecurityException ex) {
Collapse file

‎pkitesting/src/main/java/io/netty/pkitesting/CertificateBuilder.java‎

Copy file name to clipboardExpand all lines: pkitesting/src/main/java/io/netty/pkitesting/CertificateBuilder.java
+99-2Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ public enum Algorithm {
972972
/**
973973
* The ML-KEM-512 algorithm is the NIST FIPS 203 version of the post-quantum Kyber algorithm.
974974
* It has 128-bits of classical security strength, and is claimed to meet NIST Level 1
975-
* quantum security strength (equivalent to finding the key for an AES-1128 block).
975+
* quantum security strength (equivalent to finding the key for an AES-128 block).
976976
* <p>
977977
* This algorithm was added in Java 24, and may not be supported everywhere.
978978
*/
@@ -992,7 +992,104 @@ public enum Algorithm {
992992
* <p>
993993
* This algorithm was added in Java 24, and may not be supported everywhere.
994994
*/
995-
mlKem1024("ML-KEM", namedParameterSpec("ML-KEM-1024"), UNSUPPORTED_SIGN);
995+
mlKem1024("ML-KEM", namedParameterSpec("ML-KEM-1024"), UNSUPPORTED_SIGN),
996+
/**
997+
* The SLH-DSA-SHA2-128s algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
998+
* It has 128-bits of classical security strength, and is claimed to meet NIST Level 1
999+
* quantum security strength (equivalent to finding the key for an AES-128 block).
1000+
* <p>
1001+
* SLH-DSA algorithms with the 's' suffix have relatively smaller signatures but are much slower.
1002+
*/
1003+
slhDsaSha2_128s("SLH-DSA", namedParameterSpec("SLH-DSA-SHA2-128s"), "SLH-DSA-SHA2-128s"),
1004+
/**
1005+
* The SLH-DSA-SHA2-128f algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1006+
* It has 128-bits of classical security strength, and is claimed to meet NIST Level 1
1007+
* quantum security strength (equivalent to finding the key for an AES-128 block).
1008+
* <p>
1009+
* SLH-DSA algorithms with the 'f' suffix have larger signatures but are much faster.
1010+
*/
1011+
slhDsaSha2_128f("SLH-DSA", namedParameterSpec("SLH-DSA-SHA2-128f"), "SLH-DSA-SHA2-128f"),
1012+
/**
1013+
* The SLH-DSA-SHAKE-128s algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1014+
* It has 128-bits of classical security strength, and is claimed to meet NIST Level 1
1015+
* quantum security strength (equivalent to finding the key for an AES-128 block).
1016+
* <p>
1017+
* SLH-DSA algorithms with the 's' suffix have relatively smaller signatures but are much slower.
1018+
*/
1019+
slhDsaShake_128s("SLH-DSA", namedParameterSpec("SLH-DSA-SHAKE-128s"), "SLH-DSA-SHAKE-128s"),
1020+
/**
1021+
* The SLH-DSA-SHAKE-128f algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1022+
* It has 128-bits of classical security strength, and is claimed to meet NIST Level 1
1023+
* quantum security strength (equivalent to finding the key for an AES-128 block).
1024+
* <p>
1025+
* SLH-DSA algorithms with the 'f' suffix have larger signatures but are much faster.
1026+
*/
1027+
slhDsaShake_128f("SLH-DSA", namedParameterSpec("SLH-DSA-SHAKE-128f"), "SLH-DSA-SHAKE-128f"),
1028+
/**
1029+
* The SLH-DSA-SHA2-192 algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1030+
* It has 192-bits of classical security strength, and is claimed to meet NIST Level 3
1031+
* quantum security strength (equivalent to finding the key for an AES-192 block).
1032+
* <p>
1033+
* SLH-DSA algorithms with the 's' suffix have relatively smaller signatures but are much slower.
1034+
*/
1035+
slhDsaSha2_192s("SLH-DSA", namedParameterSpec("SLH-DSA-SHA2-192s"), "SLH-DSA-SHA2-192s"),
1036+
/**
1037+
* The SLH-DSA-SHA2-192f algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1038+
* It has 192-bits of classical security strength, and is claimed to meet NIST Level 3
1039+
* quantum security strength (equivalent to finding the key for an AES-192 block).
1040+
* <p>
1041+
* SLH-DSA algorithms with the 'f' suffix have larger signatures but are much faster.
1042+
*/
1043+
slhDsaSha2_192f("SLH-DSA", namedParameterSpec("SLH-DSA-SHA2-192f"), "SLH-DSA-SHA2-192f"),
1044+
/**
1045+
* The SLH-DSA-SHAKE-192s algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1046+
* It has 192-bits of classical security strength, and is claimed to meet NIST Level 3
1047+
* quantum security strength (equivalent to finding the key for an AES-192 block).
1048+
* <p>
1049+
* SLH-DSA algorithms with the 's' suffix have relatively smaller signatures but are much slower.
1050+
*/
1051+
slhDsaShake_192s("SLH-DSA", namedParameterSpec("SLH-DSA-SHAKE-192s"), "SLH-DSA-SHAKE-192s"),
1052+
/**
1053+
* The SLH-DSA-SHAKE-192f algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1054+
* It has 192-bits of classical security strength, and is claimed to meet NIST Level 3
1055+
* quantum security strength (equivalent to finding the key for an AES-192 block).
1056+
* <p>
1057+
* SLH-DSA algorithms with the 'f' suffix have larger signatures but are much faster.
1058+
*/
1059+
slhDsaShake_192f("SLH-DSA", namedParameterSpec("SLH-DSA-SHAKE-192f"), "SLH-DSA-SHAKE-192f"),
1060+
/**
1061+
* The SLH-DSA-SHA2-256s algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1062+
* It has 256-bits of classical security strength, and is claimed to meet NIST Level 5
1063+
* quantum security strength (equivalent to finding the key for an AES-256 block).
1064+
* <p>
1065+
* SLH-DSA algorithms with the 's' suffix have relatively smaller signatures but are much slower.
1066+
*/
1067+
slhDsaSha2_256s("SLH-DSA", namedParameterSpec("SLH-DSA-SHA2-256s"), "SLH-DSA-SHA2-256s"),
1068+
/**
1069+
* The SLH-DSA-SHA2-256f algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1070+
* It has 256-bits of classical security strength, and is claimed to meet NIST Level 5
1071+
* quantum security strength (equivalent to finding the key for an AES-256 block).
1072+
* <p>
1073+
* SLH-DSA algorithms with the 'f' suffix have larger signatures but are much faster.
1074+
*/
1075+
slhDsaSha2_256f("SLH-DSA", namedParameterSpec("SLH-DSA-SHA2-256f"), "SLH-DSA-SHA2-256f"),
1076+
/**
1077+
* The SLH-DSA-SHAKE-256s algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1078+
* It has 256-bits of classical security strength, and is claimed to meet NIST Level 5
1079+
* quantum security strength (equivalent to finding the key for an AES-256 block).
1080+
* <p>
1081+
* SLH-DSA algorithms with the 's' suffix have relatively smaller signatures but are much slower.
1082+
*/
1083+
slhDsaShake_256s("SLH-DSA", namedParameterSpec("SLH-DSA-SHAKE-256s"), "SLH-DSA-SHAKE-256s"),
1084+
/**
1085+
* The SLH-DSA-SHAKE-256f algorithm is the NIST FIPS 205 of the post-quantum SPHINCS+ algorithm.
1086+
* It has 256-bits of classical security strength, and is claimed to meet NIST Level 5
1087+
* quantum security strength (equivalent to finding the key for an AES-256 block).
1088+
* <p>
1089+
* SLH-DSA algorithms with the 'f' suffix have larger signatures but are much faster.
1090+
*/
1091+
slhDsaShake_256f("SLH-DSA", namedParameterSpec("SLH-DSA-SHAKE-256f"), "SLH-DSA-SHAKE-256f"),
1092+
;
9961093

9971094
final String keyType;
9981095
final AlgorithmParameterSpec parameterSpec;
Collapse file

‎pkitesting/src/test/java/io/netty/pkitesting/CertificateBuilderTest.java‎

Copy file name to clipboardExpand all lines: pkitesting/src/test/java/io/netty/pkitesting/CertificateBuilderTest.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.netty.pkitesting.CertificateBuilder.KeyUsage;
2020
import io.netty.util.internal.PlatformDependent;
2121

22+
import org.bouncycastle.jce.provider.BouncyCastleProvider;
2223
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
2324
import org.junit.jupiter.api.Test;
2425
import org.junit.jupiter.api.condition.EnabledForJreRange;
@@ -108,7 +109,7 @@ void createKeyPairOfEveryKeyType(Algorithm algorithm) throws Exception {
108109
void createKeyPairWithProvider(Algorithm algorithm) throws Exception {
109110
assumeTrue(algorithm.isSupported());
110111

111-
KeyPair keyPair = algorithm.generateKeyPair(RNG, new BouncyCastleJsseProvider());
112+
KeyPair keyPair = algorithm.generateKeyPair(RNG, new BouncyCastleProvider());
112113
assertNotNull(keyPair);
113114
assertNotNull(keyPair.getPrivate());
114115
assertNotNull(keyPair.getPublic());

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.