Skip to main content

RawSigner

Struct RawSigner 

Source
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

Source

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
Source

pub fn set_params(&mut self, params: &Params<'_>) -> Result<(), ErrorStack>

Apply parameters after init (e.g. RSA padding mode, salt length).

§Errors
Source

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
Source

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()).

§Errors
Source

pub fn sign_alloc(&mut self, tbs: &[u8]) -> Result<Vec<u8>, ErrorStack>

Sign pre-hashed data, allocating the output buffer.

Convenience wrapper around sign_len + sign.

§Errors

Trait Implementations§

Source§

impl Drop for RawSigner

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for RawSigner

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.