pub struct RawSigner { /* private fields */ }Expand description
Raw (no-digest) signing context wrapping EVP_PKEY_CTX after EVP_PKEY_sign_init.
Use this for algorithms where the caller has already hashed the data, such
as raw ECDSA (data is the hash) or raw RSA with explicit padding. For
algorithms that hash internally, use Signer or MessageSigner.
The context is reusable: after a successful sign call the
init state is preserved, so the same padding parameters apply to further
sign calls with the same key.
Implementations§
Source§impl RawSigner
impl RawSigner
Sourcepub fn new(
key: &Pkey<Private>,
libctx: Option<&Arc<LibCtx>>,
) -> Result<Self, ErrorStack>
pub fn new( key: &Pkey<Private>, libctx: Option<&Arc<LibCtx>>, ) -> Result<Self, ErrorStack>
Create and initialise a sign context (EVP_PKEY_CTX_new_from_pkey +
EVP_PKEY_sign_init).
Pass libctx = Some(ctx) to restrict provider lookup to that library
context; None uses the key’s own library context.
§Errors
Sourcepub fn set_params(&mut self, params: &Params<'_>) -> Result<(), ErrorStack>
pub fn set_params(&mut self, params: &Params<'_>) -> Result<(), ErrorStack>
Apply parameters after init (e.g. RSA padding mode, salt length).
§Errors
Sourcepub fn sign_len(&mut self, tbs_len: usize) -> Result<usize, ErrorStack>
pub fn sign_len(&mut self, tbs_len: usize) -> Result<usize, ErrorStack>
Query the signature output size for the given input length.
Calls EVP_PKEY_sign with a null output pointer — does not consume
the signing state.
§Errors
Sourcepub fn sign(&mut self, tbs: &[u8], sig: &mut [u8]) -> Result<usize, ErrorStack>
pub fn sign(&mut self, tbs: &[u8], sig: &mut [u8]) -> Result<usize, ErrorStack>
Sign pre-hashed data into sig. Returns the number of bytes written.
sig.len() must be >= sign_len(tbs.len()).