@@ -70,6 +70,8 @@ use crate::cipher::CipherRef;
70
70
use crate :: error:: ErrorStack ;
71
71
use crate :: md:: MdRef ;
72
72
use crate :: nid:: Nid ;
73
+ #[ cfg( ossl320) ]
74
+ use crate :: params:: ParamBuilder ;
73
75
#[ cfg( ossl300) ]
74
76
use crate :: params:: ParamsRef ;
75
77
#[ cfg( ossl300) ]
@@ -917,6 +919,14 @@ impl<T> PkeyCtxRef<T> {
917
919
}
918
920
}
919
921
922
+ /// Sets parameters on the given context
923
+ #[ corresponds( EVP_PKEY_CTX_set_params ) ]
924
+ #[ cfg( ossl300) ]
925
+ #[ allow( dead_code) ]
926
+ fn set_params ( & mut self , params : & ParamsRef < ' _ > ) -> Result < ( ) , ErrorStack > {
927
+ cvt ( unsafe { ffi:: EVP_PKEY_CTX_set_params ( self . as_ptr ( ) , params. as_ptr ( ) ) } ) . map ( |_| ( ) )
928
+ }
929
+
920
930
/// Sets the nonce type for a private key context.
921
931
///
922
932
/// The nonce for DSA and ECDSA can be either random (the default) or deterministic (as defined by RFC 6979).
@@ -926,17 +936,10 @@ impl<T> PkeyCtxRef<T> {
926
936
#[ cfg( ossl320) ]
927
937
#[ corresponds( EVP_PKEY_CTX_set_params ) ]
928
938
pub fn set_nonce_type ( & mut self , nonce_type : NonceType ) -> Result < ( ) , ErrorStack > {
929
- let nonce_field_name = c_str ( b"nonce-type\0 " ) ;
930
- let mut nonce_type = nonce_type. 0 ;
931
- unsafe {
932
- let param_nonce =
933
- ffi:: OSSL_PARAM_construct_uint ( nonce_field_name. as_ptr ( ) , & mut nonce_type) ;
934
- let param_end = ffi:: OSSL_PARAM_construct_end ( ) ;
935
-
936
- let params = [ param_nonce, param_end] ;
937
- cvt ( ffi:: EVP_PKEY_CTX_set_params ( self . as_ptr ( ) , params. as_ptr ( ) ) ) ?;
938
- }
939
- Ok ( ( ) )
939
+ let params = ParamBuilder :: new ( )
940
+ . push_uint ( c_str ( b"nonce-type\0 " ) , nonce_type. 0 ) ?
941
+ . build ( ) ?;
942
+ self . set_params ( & params)
940
943
}
941
944
942
945
/// Gets the nonce type for a private key context.
0 commit comments