1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.gordianknot.api.keypair;
18
19 import org.bouncycastle.asn1.ASN1ObjectIdentifier;
20 import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
21 import org.bouncycastle.jcajce.spec.MLDSAParameterSpec;
22 import org.bouncycastle.pqc.crypto.mldsa.MLDSAParameters;
23
24
25
26
27 public enum GordianMLDSASpec {
28
29
30
31 MLDSA44,
32
33
34
35
36 MLDSA65,
37
38
39
40
41 MLDSA87,
42
43
44
45
46 MLDSA44SHA,
47
48
49
50
51 MLDSA65SHA,
52
53
54
55
56 MLDSA87SHA;
57
58
59
60
61
62
63 public boolean isHash() {
64 switch (this) {
65 case MLDSA44SHA:
66 case MLDSA65SHA:
67 case MLDSA87SHA:
68 return true;
69 case MLDSA44:
70 case MLDSA65:
71 case MLDSA87:
72 default:
73 return false;
74 }
75 }
76
77
78
79
80
81
82 public MLDSAParameters getParameters() {
83 switch (this) {
84 case MLDSA44:
85 return MLDSAParameters.ml_dsa_44;
86 case MLDSA65:
87 return MLDSAParameters.ml_dsa_65;
88 case MLDSA87:
89 return MLDSAParameters.ml_dsa_87;
90 case MLDSA44SHA:
91 return MLDSAParameters.ml_dsa_44_with_sha512;
92 case MLDSA65SHA:
93 return MLDSAParameters.ml_dsa_65_with_sha512;
94 case MLDSA87SHA:
95 return MLDSAParameters.ml_dsa_87_with_sha512;
96 default:
97 throw new IllegalArgumentException();
98 }
99 }
100
101
102
103
104
105
106 public MLDSAParameterSpec getParameterSpec() {
107 switch (this) {
108 case MLDSA44:
109 return MLDSAParameterSpec.ml_dsa_44;
110 case MLDSA65:
111 return MLDSAParameterSpec.ml_dsa_65;
112 case MLDSA87:
113 return MLDSAParameterSpec.ml_dsa_87;
114 case MLDSA44SHA:
115 return MLDSAParameterSpec.ml_dsa_44_with_sha512;
116 case MLDSA65SHA:
117 return MLDSAParameterSpec.ml_dsa_65_with_sha512;
118 case MLDSA87SHA:
119 return MLDSAParameterSpec.ml_dsa_87_with_sha512;
120 default:
121 throw new IllegalArgumentException();
122 }
123 }
124
125
126
127
128
129
130 public ASN1ObjectIdentifier getIdentifier() {
131 switch (this) {
132 case MLDSA44:
133 return NISTObjectIdentifiers.id_ml_dsa_44;
134 case MLDSA65:
135 return NISTObjectIdentifiers.id_ml_dsa_65;
136 case MLDSA87:
137 return NISTObjectIdentifiers.id_ml_dsa_87;
138 case MLDSA44SHA:
139 return NISTObjectIdentifiers.id_hash_ml_dsa_44_with_sha512;
140 case MLDSA65SHA:
141 return NISTObjectIdentifiers.id_hash_ml_dsa_65_with_sha512;
142 case MLDSA87SHA:
143 return NISTObjectIdentifiers.id_hash_ml_dsa_87_with_sha512;
144 default:
145 throw new IllegalArgumentException();
146 }
147 }
148 }