pub struct ParamBuilder<'a> { /* private fields */ }Expand description
Builder for OSSL_PARAM arrays.
use native_ossl::params::ParamBuilder;
let params = ParamBuilder::new()
.push_int(c"key_bits", 2048)?
.push_utf8_ptr(c"pad-mode", c"oaep")?
.build()?;Implementations§
Source§impl<'a> ParamBuilder<'a>
impl<'a> ParamBuilder<'a>
Sourcepub fn new() -> Result<Self, ErrorStack>
pub fn new() -> Result<Self, ErrorStack>
Sourcepub fn push_int(self, key: &CStr, val: i32) -> Result<Self, ErrorStack>
pub fn push_int(self, key: &CStr, val: i32) -> Result<Self, ErrorStack>
Push a signed integer parameter.
§Errors
Returns Err if the push fails (allocation error or key too long).
Sourcepub fn push_uint(self, key: &CStr, val: u32) -> Result<Self, ErrorStack>
pub fn push_uint(self, key: &CStr, val: u32) -> Result<Self, ErrorStack>
Push an unsigned integer parameter.
§Errors
Sourcepub fn push_uint64(self, key: &CStr, val: u64) -> Result<Self, ErrorStack>
pub fn push_uint64(self, key: &CStr, val: u64) -> Result<Self, ErrorStack>
Push a 64-bit unsigned integer parameter.
Used for parameters such as the scrypt N cost factor.
§Errors
Sourcepub fn push_size(self, key: &CStr, val: usize) -> Result<Self, ErrorStack>
pub fn push_size(self, key: &CStr, val: usize) -> Result<Self, ErrorStack>
Push a size_t parameter.
§Errors
Sourcepub fn push_octet_slice(
self,
key: &CStr,
val: &[u8],
) -> Result<Self, ErrorStack>
pub fn push_octet_slice( self, key: &CStr, val: &[u8], ) -> Result<Self, ErrorStack>
Push an octet-string parameter — copies val into the param array.
Use this when val may be dropped before the resulting Params is consumed.
If val is guaranteed to outlive Params, prefer push_octet_ptr.
§Errors
Sourcepub fn push_octet_ptr<'b>(
self,
key: &CStr,
val: &'b [u8],
) -> Result<ParamBuilder<'b>, ErrorStack>where
'a: 'b,
pub fn push_octet_ptr<'b>(
self,
key: &CStr,
val: &'b [u8],
) -> Result<ParamBuilder<'b>, ErrorStack>where
'a: 'b,
Push an octet-string parameter — stores a pointer into val.
Zero-copy: no allocation occurs. The lifetime 'b of val must be at
least 'a to prevent the reference from being invalidated before the
Params array is consumed.
§Errors
Sourcepub fn push_utf8_string(
self,
key: &CStr,
val: &CStr,
) -> Result<Self, ErrorStack>
pub fn push_utf8_string( self, key: &CStr, val: &CStr, ) -> Result<Self, ErrorStack>
Push a UTF-8 string parameter — copies val into the param array.
§Errors
Sourcepub fn push_utf8_ptr(
self,
key: &CStr,
val: &'static CStr,
) -> Result<Self, ErrorStack>
pub fn push_utf8_ptr( self, key: &CStr, val: &'static CStr, ) -> Result<Self, ErrorStack>
Push a UTF-8 string parameter — stores a pointer into val.
Zero-copy: no allocation occurs. Use only for 'static literals such as
algorithm names (c"oaep", c"SHA-256").
§Errors
Sourcepub fn push_bn(
self,
key: &CStr,
bigendian_bytes: &[u8],
) -> Result<Self, ErrorStack>
pub fn push_bn( self, key: &CStr, bigendian_bytes: &[u8], ) -> Result<Self, ErrorStack>
Push a BIGNUM parameter from big-endian bytes.
Converts bigendian_bytes to an OpenSSL BIGNUM and pushes it into the
builder. The BIGNUM is copied into the builder’s internal storage so
the caller’s slice is not referenced after this call returns.
§Errors
Returns Err if the allocation fails or the push fails.