pub struct Signer { /* private fields */ }Expand description
Streaming DigestSign context.
Call update zero or more times, then finish to produce the signature.
Implementations§
Source§impl Signer
impl Signer
Sourcepub fn new(key: &Pkey<Private>, init: &SignInit<'_>) -> Result<Self, ErrorStack>
pub fn new(key: &Pkey<Private>, init: &SignInit<'_>) -> Result<Self, ErrorStack>
Create a signer.
§Errors
Sourcepub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Feed data into the hash.
§Errors
Sourcepub fn finish(&mut self) -> Result<Vec<u8>, ErrorStack>
pub fn finish(&mut self) -> Result<Vec<u8>, ErrorStack>
Finalise and return the signature.
Not supported by pure one-shot algorithms such as Ed25519 — use
sign_oneshot for those.
§Errors
Sourcepub fn sign_oneshot(&mut self, data: &[u8]) -> Result<Vec<u8>, ErrorStack>
pub fn sign_oneshot(&mut self, data: &[u8]) -> Result<Vec<u8>, ErrorStack>
One-shot sign over data.
Required for algorithms that do not support streaming (Ed25519, Ed448).
For algorithms that do support streaming, prefer update + finish.
§Errors
Sourcepub fn sign_into(
&mut self,
data: &[u8],
sig: &mut [u8],
) -> Result<usize, ErrorStack>
pub fn sign_into( &mut self, data: &[u8], sig: &mut [u8], ) -> Result<usize, ErrorStack>
One-shot sign over data into a caller-provided buffer sig.
The buffer must be at least as large as the maximum signature size for
the key (use EVP_PKEY_get_size or the algorithm’s known fixed length).
For algorithms with a fixed signature size (e.g. ML-DSA, Ed25519), the
caller can pre-allocate the exact size and avoid the null-output query.
Returns the number of bytes written. The caller should truncate sig
to the returned length if the actual size may differ from the buffer size.