@@ -155,13 +155,10 @@ static int pqdsa_priv_decode(EVP_PKEY *out, CBS *oid, CBS *params, CBS *key, CBS
155
155
}
156
156
157
157
// Try to parse as one of the three ASN.1 formats defined in ML-DSA-XX-PrivateKey
158
- // Currently only the following cases are supported:
158
+ // https://datatracker.ietf.org/doc/draft-ietf-lamps-dilithium-certificates/
159
159
// Case 1: seed [0] OCTET STRING
160
160
// Case 2: expandedKey OCTET STRING
161
-
162
- // Once https://datatracker.ietf.org/doc/draft-ietf-lamps-dilithium-certificates/
163
- // is stable we will implement:
164
- // Case 3: both SEQUENCE { seed, expandedKey }
161
+ // Case 3: both SEQUENCE {seed, expandedKey}
165
162
166
163
if (CBS_peek_asn1_tag (key , CBS_ASN1_CONTEXT_SPECIFIC | 0 )) {
167
164
// Case 1: seed [0] OCTET STRING
@@ -191,6 +188,17 @@ static int pqdsa_priv_decode(EVP_PKEY *out, CBS *oid, CBS *params, CBS *key, CBS
191
188
}
192
189
193
190
return PQDSA_KEY_set_raw_private_key (out -> pkey .pqdsa_key , & expanded_key );
191
+ } else if (CBS_peek_asn1_tag (key , CBS_ASN1_SEQUENCE )) {
192
+ // Case 3: both SEQUENCE {seed, expandedKey}
193
+ CBS sequence , seed , expanded_key ;
194
+ if (!CBS_get_asn1 (key , & sequence , CBS_ASN1_SEQUENCE ) ||
195
+ !CBS_get_asn1 (& sequence , & seed , CBS_ASN1_OCTETSTRING ) ||
196
+ !CBS_get_asn1 (& sequence , & expanded_key , CBS_ASN1_OCTETSTRING )) {
197
+ OPENSSL_PUT_ERROR (EVP , EVP_R_DECODE_ERROR );
198
+ return 0 ;
199
+ }
200
+
201
+ return PQDSA_KEY_set_raw_keypair_from_both (out -> pkey .pqdsa_key , & seed , & expanded_key );
194
202
} else {
195
203
OPENSSL_PUT_ERROR (EVP , EVP_R_DECODE_ERROR );
196
204
return 0 ;
0 commit comments