Struct cosmian_crypto_core::RsaPrivateKey
source · pub struct RsaPrivateKey(/* private fields */);
Implementations§
source§impl RsaPrivateKey
impl RsaPrivateKey
sourcepub fn new<R: CryptoRngCore>(
rng: &mut R,
key_length: RsaKeyLength,
) -> Result<Self, CryptoCoreError>
pub fn new<R: CryptoRngCore>( rng: &mut R, key_length: RsaKeyLength, ) -> Result<Self, CryptoCoreError>
Generate a random private key
sourcepub fn key_length(&self) -> RsaKeyLength
pub fn key_length(&self) -> RsaKeyLength
Get the key length which is the modulus size in bits
source§impl RsaPrivateKey
impl RsaPrivateKey
Key wrapping support
sourcepub fn unwrap_key(
&self,
wrapping_algorithm: RsaKeyWrappingAlgorithm,
encrypted_key_material: &[u8],
) -> Result<Zeroizing<Vec<u8>>, CryptoCoreError>
pub fn unwrap_key( &self, wrapping_algorithm: RsaKeyWrappingAlgorithm, encrypted_key_material: &[u8], ) -> Result<Zeroizing<Vec<u8>>, CryptoCoreError>
Unwrap a key
source§impl RsaPrivateKey
impl RsaPrivateKey
Facades
sourcepub fn public_key(&self) -> <RsaPrivateKey as PrivateKey>::PublicKey
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
impl Clone for RsaPrivateKey
source§fn clone(&self) -> RsaPrivateKey
fn clone(&self) -> RsaPrivateKey
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RsaPrivateKey
impl Debug for RsaPrivateKey
source§impl DecodePrivateKey for RsaPrivateKey
impl DecodePrivateKey for RsaPrivateKey
source§fn from_pkcs8_der(bytes: &[u8]) -> Result<Self>
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>
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>
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>
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§impl EncodePrivateKey for RsaPrivateKey
impl EncodePrivateKey for RsaPrivateKey
source§fn to_pkcs8_der(&self) -> Result<SecretDocument>
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>
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>
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>
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>
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>
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
impl Hash for RsaPrivateKey
source§impl PartialEq for RsaPrivateKey
impl PartialEq for RsaPrivateKey
source§fn eq(&self, other: &RsaPrivateKey) -> bool
fn eq(&self, other: &RsaPrivateKey) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PrivateKey for RsaPrivateKey
impl PrivateKey for RsaPrivateKey
type PublicKey = RsaPublicKey
fn public_key(&self) -> Self::PublicKey
impl Eq for RsaPrivateKey
impl StructuralPartialEq for RsaPrivateKey
impl ZeroizeOnDrop for RsaPrivateKey
Auto Trait Implementations§
impl Freeze for RsaPrivateKey
impl RefUnwindSafe for RsaPrivateKey
impl Send for RsaPrivateKey
impl Sync for RsaPrivateKey
impl Unpin for RsaPrivateKey
impl UnwindSafe for RsaPrivateKey
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
Mutably borrows from an owned value. Read more
source§impl<T> EncodeEcPrivateKey for Twhere
T: EncodePrivateKey,
impl<T> EncodeEcPrivateKey for Twhere
T: EncodePrivateKey,
source§fn to_sec1_der(&self) -> Result<SecretDocument, Error>
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>
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 moresource§fn write_sec1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
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>
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 Twhere
T: EncodePrivateKey,
impl<T> EncodeRsaPrivateKey for Twhere
T: EncodePrivateKey,
source§fn to_pkcs1_der(&self) -> Result<SecretDocument, Error>
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>
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>
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>
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.