pub struct SignatureContext { /* private fields */ }Expand description
Signature context for digital signature operations
Implementations§
Source§impl SignatureContext
impl SignatureContext
Sourcepub fn new() -> SignatureContext
pub fn new() -> SignatureContext
Create a new signature context with no provider
Sourcepub fn with_provider(provider: Box<dyn CryptoProvider>) -> SignatureContext
pub fn with_provider(provider: Box<dyn CryptoProvider>) -> SignatureContext
Create a new signature context with a provider
Sourcepub fn with_default_provider() -> SignatureContext
pub fn with_default_provider() -> SignatureContext
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, Error>
pub fn generate_keypair( &mut self, algorithm: Algorithm, randomness: Option<&[u8]>, ) -> Result<SigKeypair, Error>
Generate a keypair for the specified algorithm
Sourcepub fn sign(
&self,
algorithm: Algorithm,
secret_key: &SigSecretKey,
message: &[u8],
randomness: Option<&[u8]>,
) -> Result<Vec<u8>, Error>
pub fn sign( &self, algorithm: Algorithm, secret_key: &SigSecretKey, message: &[u8], randomness: Option<&[u8]>, ) -> Result<Vec<u8>, Error>
Sign a message using the given secret key
Sourcepub fn verify(
&self,
algorithm: Algorithm,
public_key: &SigPublicKey,
message: &[u8],
signature: &[u8],
) -> Result<bool, Error>
pub fn verify( &self, algorithm: Algorithm, public_key: &SigPublicKey, message: &[u8], signature: &[u8], ) -> Result<bool, Error>
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>, Error>
pub fn sign_with_context( &self, algorithm: Algorithm, secret_key: &SigSecretKey, message: &[u8], context: &[u8], randomness: Option<&[u8]>, ) -> Result<Vec<u8>, Error>
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, Error>
pub fn verify_with_context( &self, algorithm: Algorithm, public_key: &SigPublicKey, message: &[u8], context: &[u8], signature: &[u8], ) -> Result<bool, Error>
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
Trait Implementations§
Source§impl Default for SignatureContext
Available on crate feature alloc only.
impl Default for SignatureContext
alloc only.Source§fn default() -> SignatureContext
fn default() -> SignatureContext
Auto Trait Implementations§
impl !RefUnwindSafe for SignatureContext
impl !UnwindSafe for SignatureContext
impl Freeze for SignatureContext
impl Send for SignatureContext
impl Sync for SignatureContext
impl Unpin for SignatureContext
impl UnsafeUnpin for SignatureContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more