Struct PrivateKey

Source
pub struct PrivateKey { /* private fields */ }
Expand description

A raw private key for use with the certificate builder

Implementations§

Source§

impl PrivateKey

Source

pub fn from_composite( public_key: Option<PublicKey>, composite_sk: &CompositePrivateKey, ) -> Result<Self, QuantCryptError>

Create a new private key from a composite private key

§Arguments
  • public_key - The public key (if available)
  • composite_sk - The composite private key
§Returns

A new private key

§Errors

KeyError::InvalidPrivateKey will be returned if the private key is invalid

Source

pub fn get_oid(&self) -> &str

Get the OID for the DSA / KEM

§Returns

The OID for the DSA / KEM

Source

pub fn get_public_key(&self) -> Option<&PublicKey>

Get the public key

§Returns

The public key (if available)

Source

pub fn is_composite(&self) -> bool

Check if the key is a composite key

§Returns

True if the key is a composite key, false otherwise

Source

pub fn to_der(&self) -> Result<Vec<u8>, QuantCryptError>

Get the key material as a DER-encoded byte array

§Returns

The DER-encoded byte array

§Errors

KeyError::InvalidPrivateKey will be returned if the private key is invalid

Source

pub fn to_pem(&self) -> Result<String, QuantCryptError>

Get the key material as a PEM-encoded string

§Returns

The PEM-encoded string

§Errors

KeyError::InvalidPrivateKey will be returned if the private key is invalid

Source

pub fn from_pem(pem: &str) -> Result<Self, QuantCryptError>

Create a new private key from a PEM-encoded string

§Arguments
  • pem - The PEM-encoded string
§Returns

A new private key

§Errors

KeyError::InvalidPrivateKey will be returned if the private key is invalid

Source

pub fn from_der(der: &[u8]) -> Result<Self, QuantCryptError>

Create a new private key from a DER-encoded byte array

§Arguments
  • der - The DER-encoded byte array
§Returns

A new private key

§Errors

KeyError::InvalidPrivateKey will be returned if the private key is invalid

Source

pub fn sign(&self, data: &[u8]) -> Result<Vec<u8>, QuantCryptError>

Sign a message

§Arguments
  • data - The data to sign
§Returns

The signature

Source

pub fn from_file(path: &str) -> Result<Self, QuantCryptError>

Load a private key from a file. The file can be in either DER or PEM format

§Arguments
  • path - The path to the file
§Returns

The private key

Source

pub fn to_pem_file(&self, path: &str) -> Result<(), QuantCryptError>

Save the private key to a file in PEM format

§Arguments
  • path - The path to the file
§Errors

QuantCryptError::FileWriteError will be returned if there is an error writing to the file

Source

pub fn to_der_file(&self, path: &str) -> Result<(), QuantCryptError>

Save the private key to a file in DER format

§Arguments
  • path - The path to the file
§Errors

QuantCryptError::FileWriteError will be returned if there is an error writing to the file

Trait Implementations§

Source§

impl DynSignatureAlgorithmIdentifier for PrivateKey

Source§

fn signature_algorithm_identifier( &self, ) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for the corresponding singature system.
Source§

impl Keypair for PrivateKey

Source§

type VerifyingKey = PublicKey

Verifying key type for this keypair.
Source§

fn verifying_key(&self) -> <Self as Keypair>::VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S, T> SignerMut<S> for T
where T: Signer<S>,

Source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V