@@ -65,11 +65,14 @@ fn from_mldsa44_seed_bytes(data: CffiBuf<'_>) -> pyo3::PyResult<MlDsa44PrivateKe
6565}
6666
6767#[ pyo3:: pyfunction]
68- fn from_mldsa44_public_bytes ( data : & [ u8 ] ) -> pyo3:: PyResult < MlDsa44PublicKey > {
69- let pkey = cryptography_openssl:: mldsa:: new_raw_public_key ( MlDsaVariant :: MlDsa44 , data)
70- . map_err ( |_| {
71- pyo3:: exceptions:: PyValueError :: new_err ( "An ML-DSA-44 public key is 1312 bytes long" )
72- } ) ?;
68+ fn from_mldsa44_public_bytes ( data : CffiBuf < ' _ > ) -> pyo3:: PyResult < MlDsa44PublicKey > {
69+ let pkey =
70+ cryptography_openssl:: mldsa:: new_raw_public_key ( MlDsaVariant :: MlDsa44 , data. as_bytes ( ) )
71+ . map_err ( |_| {
72+ pyo3:: exceptions:: PyValueError :: new_err (
73+ "An ML-DSA-44 public key is 1312 bytes long" ,
74+ )
75+ } ) ?;
7376 Ok ( MlDsa44PublicKey { pkey } )
7477}
7578
@@ -266,11 +269,14 @@ fn from_mldsa65_seed_bytes(data: CffiBuf<'_>) -> pyo3::PyResult<MlDsa65PrivateKe
266269}
267270
268271#[ pyo3:: pyfunction]
269- fn from_mldsa65_public_bytes ( data : & [ u8 ] ) -> pyo3:: PyResult < MlDsa65PublicKey > {
270- let pkey = cryptography_openssl:: mldsa:: new_raw_public_key ( MlDsaVariant :: MlDsa65 , data)
271- . map_err ( |_| {
272- pyo3:: exceptions:: PyValueError :: new_err ( "An ML-DSA-65 public key is 1952 bytes long" )
273- } ) ?;
272+ fn from_mldsa65_public_bytes ( data : CffiBuf < ' _ > ) -> pyo3:: PyResult < MlDsa65PublicKey > {
273+ let pkey =
274+ cryptography_openssl:: mldsa:: new_raw_public_key ( MlDsaVariant :: MlDsa65 , data. as_bytes ( ) )
275+ . map_err ( |_| {
276+ pyo3:: exceptions:: PyValueError :: new_err (
277+ "An ML-DSA-65 public key is 1952 bytes long" ,
278+ )
279+ } ) ?;
274280 Ok ( MlDsa65PublicKey { pkey } )
275281}
276282
@@ -470,11 +476,14 @@ fn from_mldsa87_seed_bytes(data: CffiBuf<'_>) -> pyo3::PyResult<MlDsa87PrivateKe
470476}
471477
472478#[ pyo3:: pyfunction]
473- fn from_mldsa87_public_bytes ( data : & [ u8 ] ) -> pyo3:: PyResult < MlDsa87PublicKey > {
474- let pkey = cryptography_openssl:: mldsa:: new_raw_public_key ( MlDsaVariant :: MlDsa87 , data)
475- . map_err ( |_| {
476- pyo3:: exceptions:: PyValueError :: new_err ( "An ML-DSA-87 public key is 2592 bytes long" )
477- } ) ?;
479+ fn from_mldsa87_public_bytes ( data : CffiBuf < ' _ > ) -> pyo3:: PyResult < MlDsa87PublicKey > {
480+ let pkey =
481+ cryptography_openssl:: mldsa:: new_raw_public_key ( MlDsaVariant :: MlDsa87 , data. as_bytes ( ) )
482+ . map_err ( |_| {
483+ pyo3:: exceptions:: PyValueError :: new_err (
484+ "An ML-DSA-87 public key is 2592 bytes long" ,
485+ )
486+ } ) ?;
478487 Ok ( MlDsa87PublicKey { pkey } )
479488}
480489
0 commit comments