Struct cosmian_crypto_core::RsaPrivateKey

source ·
pub struct RsaPrivateKey(/* private fields */);

Implementations§

source§

impl RsaPrivateKey

source

pub fn new<R: CryptoRngCore>( rng: &mut R, key_length: RsaKeyLength, ) -> Result<Self, CryptoCoreError>

Generate a random private key

source

pub fn key_length(&self) -> RsaKeyLength

Get the key length which is the modulus size in bits

source§

impl RsaPrivateKey

Key wrapping support

source

pub fn unwrap_key( &self, wrapping_algorithm: RsaKeyWrappingAlgorithm, encrypted_key_material: &[u8], ) -> Result<Zeroizing<Vec<u8>>, CryptoCoreError>

Unwrap a key

source§

impl RsaPrivateKey

Facades

source

pub fn public_key(&self) -> <RsaPrivateKey as PrivateKey>::PublicKey

Get the public key

This is a facade for PrivateKey::public_key

Trait Implementations§

source§

impl Clone for RsaPrivateKey

source§

fn clone(&self) -> RsaPrivateKey

Returns a copy 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 Debug for RsaPrivateKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DecodePrivateKey for RsaPrivateKey

source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<Self>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
source§

fn from_pkcs8_encrypted_der( bytes: &[u8], password: impl AsRef<[u8]>, ) -> Result<Self, Error>

Deserialize encrypted PKCS#8 private key from ASN.1 DER-encoded data (binary format) and attempt to decrypt it using the provided password.
source§

fn from_pkcs8_pem(s: &str) -> Result<Self, Error>

Deserialize PKCS#8-encoded private key from PEM. Read more
source§

fn from_pkcs8_encrypted_pem( s: &str, password: impl AsRef<[u8]>, ) -> Result<Self, Error>

Deserialize encrypted PKCS#8-encoded private key from PEM and attempt to decrypt it using the provided password. Read more
source§

fn read_pkcs8_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#8 private key from an ASN.1 DER-encoded file on the local filesystem (binary format).
source§

fn read_pkcs8_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#8 private key from a PEM-encoded file on the local filesystem.
source§

impl EncodePrivateKey for RsaPrivateKey

source§

fn to_pkcs8_der(&self) -> Result<SecretDocument>

Serialize a SecretDocument containing a PKCS#8-encoded private key.
source§

fn to_pkcs8_encrypted_der( &self, rng: impl CryptoRng + RngCore, password: impl AsRef<[u8]>, ) -> Result<SecretDocument>

Create an SecretDocument containing the ciphertext of a PKCS#8 encoded private key encrypted under the given password.
source§

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

Serialize this private key as PEM-encoded PKCS#8 with the given LineEnding.
source§

fn to_pkcs8_encrypted_pem( &self, rng: impl CryptoRng + RngCore, password: impl AsRef<[u8]>, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>

Serialize this private key as an encrypted PEM-encoded PKCS#8 private key using the provided to derive an encryption key.
source§

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

Write ASN.1 DER-encoded PKCS#8 private key to the given path
source§

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

Write ASN.1 DER-encoded PKCS#8 private key to the given path
source§

impl Hash for RsaPrivateKey

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for RsaPrivateKey

source§

fn eq(&self, other: &RsaPrivateKey) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PrivateKey for RsaPrivateKey

source§

impl Eq for RsaPrivateKey

source§

impl StructuralPartialEq for RsaPrivateKey

source§

impl ZeroizeOnDrop for RsaPrivateKey

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

source§

fn to_sec1_der(&self) -> Result<SecretDocument, Error>

Serialize a SecretDocument containing a SEC1-encoded private key.
source§

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

Serialize this private key as PEM-encoded SEC1 with the given LineEnding. Read more
source§

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

Write ASN.1 DER-encoded SEC1 private key to the given path.
source§

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

Write ASN.1 DER-encoded SEC1 private key to the given path.
source§

impl<T> EncodeRsaPrivateKey for T

source§

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

Serialize a SecretDocument containing a PKCS#1-encoded private key.
source§

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

Serialize this private key as PEM-encoded PKCS#1 with the given LineEnding.
source§

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

Write ASN.1 DER-encoded PKCS#1 private 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 PKCS#1 private 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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