@@ -58,7 +58,9 @@ fn from_public_bytes(data: &[u8]) -> pyo3::PyResult<MlDsa65PublicKey> {
5858 Ok ( MlDsa65PublicKey { pkey } )
5959}
6060
61+ // NO-COVERAGE-START
6162#[ pyo3:: pymethods]
63+ // NO-COVERAGE-END
6264impl MlDsa65PrivateKey {
6365 fn sign < ' p > (
6466 & self ,
@@ -104,11 +106,7 @@ impl MlDsa65PrivateKey {
104106 let pkcs8_der = self . pkey . private_key_to_pkcs8 ( ) ?;
105107 let pki =
106108 asn1:: parse_single :: < cryptography_key_parsing:: pkcs8:: PrivateKeyInfo < ' _ > > ( & pkcs8_der)
107- . map_err ( |_| {
108- pyo3:: exceptions:: PyValueError :: new_err (
109- "Cannot extract seed from this ML-DSA-65 private key" ,
110- )
111- } ) ?;
109+ . unwrap ( ) ;
112110 // The privateKey content is [0x80, 0x20, <32 bytes of seed>]
113111 // (context-specific tag 0, length 32)
114112 if pki. private_key . len ( ) == 2 + cryptography_openssl:: mldsa:: MLDSA65_SEED_BYTES
@@ -117,11 +115,16 @@ impl MlDsa65PrivateKey {
117115 {
118116 Ok ( pyo3:: types:: PyBytes :: new ( py, & pki. private_key [ 2 ..] ) )
119117 } else {
118+ // NO-COVERAGE-START
119+ // All supported ML-DSA variants use 32-byte seeds with the
120+ // [0x80, 0x20, <seed>] encoding. This branch is purely
121+ // defensive against future format changes.
120122 Err ( CryptographyError :: from (
121123 pyo3:: exceptions:: PyValueError :: new_err (
122124 "Cannot extract seed from this ML-DSA-65 private key" ,
123125 ) ,
124126 ) )
127+ // NO-COVERAGE-END
125128 }
126129 }
127130
@@ -165,7 +168,9 @@ impl MlDsa65PrivateKey {
165168 }
166169}
167170
171+ // NO-COVERAGE-START
168172#[ pyo3:: pymethods]
173+ // NO-COVERAGE-END
169174impl MlDsa65PublicKey {
170175 fn verify ( & self , signature : CffiBuf < ' _ > , data : CffiBuf < ' _ > ) -> CryptographyResult < ( ) > {
171176 let valid = cryptography_openssl:: mldsa:: verify (
0 commit comments