pub struct SignatureContext { /* private fields */ }Expand description
Signature context for digital signature operations
Implementations§
Source§impl SignatureContext
impl SignatureContext
Sourcepub fn with_provider(provider: Box<dyn CryptoProvider>) -> Self
pub fn with_provider(provider: Box<dyn CryptoProvider>) -> Self
Create a new signature context with a provider
Sourcepub fn with_default_provider() -> Self
pub fn with_default_provider() -> Self
Create a new signature context with the default provider
Sourcepub fn set_provider(&mut self, provider: Box<dyn CryptoProvider>)
pub fn set_provider(&mut self, provider: Box<dyn CryptoProvider>)
Set the cryptographic provider
Sourcepub fn provider(&self) -> Option<&dyn CryptoProvider>
pub fn provider(&self) -> Option<&dyn CryptoProvider>
Get the current provider
Sourcepub fn generate_keypair(
&mut self,
algorithm: Algorithm,
randomness: Option<&[u8]>,
) -> Result<SigKeypair>
pub fn generate_keypair( &mut self, algorithm: Algorithm, randomness: Option<&[u8]>, ) -> Result<SigKeypair>
Generate a keypair for the specified algorithm
Sourcepub fn sign(
&self,
algorithm: Algorithm,
secret_key: &SigSecretKey,
message: &[u8],
randomness: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn sign( &self, algorithm: Algorithm, secret_key: &SigSecretKey, message: &[u8], randomness: Option<&[u8]>, ) -> Result<Vec<u8>>
Sign a message using the given secret key
Sourcepub fn verify(
&self,
algorithm: Algorithm,
public_key: &SigPublicKey,
message: &[u8],
signature: &[u8],
) -> Result<bool>
pub fn verify( &self, algorithm: Algorithm, public_key: &SigPublicKey, message: &[u8], signature: &[u8], ) -> Result<bool>
Verify a signature for the given message and public key
Sourcepub fn sign_with_context(
&self,
algorithm: Algorithm,
secret_key: &SigSecretKey,
message: &[u8],
context: &[u8],
randomness: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn sign_with_context( &self, algorithm: Algorithm, secret_key: &SigSecretKey, message: &[u8], context: &[u8], randomness: Option<&[u8]>, ) -> Result<Vec<u8>>
Sign a message under a signing context (FIPS-204 / FIPS-205 domain separation)
An empty context is equivalent to Self::sign. A non-empty context requires a
provider that supports contexts; others return
NotImplemented.
Sourcepub fn verify_with_context(
&self,
algorithm: Algorithm,
public_key: &SigPublicKey,
message: &[u8],
context: &[u8],
signature: &[u8],
) -> Result<bool>
pub fn verify_with_context( &self, algorithm: Algorithm, public_key: &SigPublicKey, message: &[u8], context: &[u8], signature: &[u8], ) -> Result<bool>
Verify a signature under a signing context (FIPS-204 / FIPS-205 domain separation)
An empty context is equivalent to Self::verify. A non-empty context requires a
provider that supports contexts; others return
NotImplemented rather than a true/false
verdict computed without the context.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the context is initialized