PublicKey

Struct PublicKey 

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

A raw public key for use with the certificate builder

Implementations§

Source§

impl PublicKey

Source

pub fn new(oid: &str, key: &[u8]) -> Result<Self, QuantCryptError>

Create a new public key

§Arguments
  • oid - The OID for the DSA / KEM
  • key - The key material
§Returns

A new public key

§Errors

KeyError::InvalidPublicKey will be returned if the OID is invalid or the key is invalid

Source

pub fn from_composite( composite_pk: &CompositePublicKey, ) -> Result<Self, QuantCryptError>

Create a new public key from a composite public key

§Arguments
  • composite_pk - The composite public key
§Returns

A new public key

§Errors

KeyError::InvalidPublicKey will be returned if the public key is invalid

Source

pub fn get_oid(&self) -> &str

Get the OID for the DSA / KEM public key algorithm

§Returns

The OID for the DSA / KEM public key algorithm

Source

pub fn get_key(&self) -> &[u8]

Get the key material

§Returns

The key material

Source

pub fn is_composite(&self) -> bool

Is it a composite key

§Returns

True if it is a composite key, false otherwise

Source

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

Convert the public key to a PEM-encoded string

§Returns

The PEM-encoded public key

§Errors

KeyError::InvalidPublicKey will be returned if the public key is invalid

Source

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

Convert the public key to a DER-encoded byte array. The raw public key is wrapped in a SubjectPublicKeyInfo structure.

§Returns

The DER-encoded byte array

§Errors

KeyError::InvalidPublicKey will be returned if the public key is invalid

Source

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

Create a new public key from a PEM-encoded string

§Arguments
  • pem - The PEM-encoded public key
§Returns

A new public key

§Errors

KeyError::InvalidPublicKey will be returned if the public key is invalid

Source

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

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

§Arguments
  • der - The DER-encoded public key
§Returns

A new public key

§Errors

KeyError::InvalidPublicKey will be returned if the public key is invalid

Source

pub fn verify( &self, message: &[u8], signature: &[u8], ) -> Result<bool, QuantCryptError>

Verify a signature

§Arguments
  • message - The message to verify
  • signature - The signature
§Returns

A boolean indicating if the signature is valid

§Errors

QuantCryptError::UnsupportedOperation will be returned if the OID is not a DSA key

Source

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

Encapsulate to get a shared secret and a ciphertext based on this public key

§Returns

A tuple containing the ciphertext and the shared secret (ct, ss)

Trait Implementations§

Source§

impl Clone for PublicKey

Source§

fn clone(&self) -> PublicKey

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl EncodePublicKey for PublicKey

Source§

fn to_public_key_der(&self) -> Result<Document, Error>

Serialize a Document containing a SPKI-encoded public key.
Source§

fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>

Serialize this public key as PEM-encoded SPKI with the given LineEnding.
Source§

fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path
Source§

fn write_public_key_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> EncodeRsaPublicKey for T
where T: EncodePublicKey,

Source§

fn to_pkcs1_der(&self) -> Result<Document, Error>

Serialize a Document containing a PKCS#1-encoded public key.
Source§

fn to_pkcs1_pem(&self, line_ending: LineEnding) -> Result<String, Error>

Serialize this public key as PEM-encoded PKCS#1 with the given line ending.
Source§

fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path.
Source§

fn write_pkcs1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>

Write ASN.1 DER-encoded public key to the given path.
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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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