@@ -6,6 +6,7 @@ use std::collections::hash_map::DefaultHasher;
66use std:: hash:: { Hash , Hasher } ;
77
88use crate :: backend:: { hashes, utils} ;
9+ use crate :: buf:: CffiBuf ;
910use crate :: error:: { CryptographyError , CryptographyResult } ;
1011use crate :: { exceptions, types} ;
1112
@@ -281,11 +282,12 @@ impl RsaPrivateKey {
281282 fn sign < ' p > (
282283 & self ,
283284 py : pyo3:: Python < ' p > ,
284- data : & [ u8 ] ,
285+ data : CffiBuf < ' _ > ,
285286 padding : & pyo3:: PyAny ,
286287 algorithm : & pyo3:: PyAny ,
287288 ) -> CryptographyResult < & ' p pyo3:: PyAny > {
288- let ( data, algorithm) = utils:: calculate_digest_and_algorithm ( py, data, algorithm) ?;
289+ let ( data, algorithm) =
290+ utils:: calculate_digest_and_algorithm ( py, data. as_bytes ( ) , algorithm) ?;
289291
290292 let mut ctx = openssl:: pkey_ctx:: PkeyCtx :: new ( & self . pkey ) ?;
291293 ctx. sign_init ( ) . map_err ( |_| {
@@ -419,18 +421,19 @@ impl RsaPublicKey {
419421 fn verify (
420422 & self ,
421423 py : pyo3:: Python < ' _ > ,
422- signature : & [ u8 ] ,
423- data : & [ u8 ] ,
424+ signature : CffiBuf < ' _ > ,
425+ data : CffiBuf < ' _ > ,
424426 padding : & pyo3:: PyAny ,
425427 algorithm : & pyo3:: PyAny ,
426428 ) -> CryptographyResult < ( ) > {
427- let ( data, algorithm) = utils:: calculate_digest_and_algorithm ( py, data, algorithm) ?;
429+ let ( data, algorithm) =
430+ utils:: calculate_digest_and_algorithm ( py, data. as_bytes ( ) , algorithm) ?;
428431
429432 let mut ctx = openssl:: pkey_ctx:: PkeyCtx :: new ( & self . pkey ) ?;
430433 ctx. verify_init ( ) ?;
431434 setup_signature_ctx ( py, & mut ctx, padding, algorithm, self . pkey . size ( ) , false ) ?;
432435
433- let valid = ctx. verify ( data, signature) . unwrap_or ( false ) ;
436+ let valid = ctx. verify ( data, signature. as_bytes ( ) ) . unwrap_or ( false ) ;
434437 if !valid {
435438 return Err ( CryptographyError :: from (
436439 exceptions:: InvalidSignature :: new_err ( ( ) ) ,
0 commit comments