Struct openssl::rsa::Rsa
[−]
[src]
pub struct Rsa(_);
Methods
impl Rsa
[src]
fn from_public_components(n: BigNum, e: BigNum) -> Result<Rsa, ErrorStack>
only useful for associating the key material directly with the key, it's safer to use the supplied load and save methods for DER formatted keys.
fn from_private_components(n: BigNum,
e: BigNum,
d: BigNum,
p: BigNum,
q: BigNum,
dp: BigNum,
dq: BigNum,
qi: BigNum)
-> Result<Rsa, ErrorStack>
e: BigNum,
d: BigNum,
p: BigNum,
q: BigNum,
dp: BigNum,
dq: BigNum,
qi: BigNum)
-> Result<Rsa, ErrorStack>
fn generate(bits: u32) -> Result<Rsa, ErrorStack>
Generates a public/private key pair with the specified size.
The public exponent will be 65537.
fn private_key_from_pem(pem: &[u8]) -> Result<Rsa, ErrorStack>
Deserializes a PEM-formatted private key.
fn private_key_from_pem_passphrase(pem: &[u8],
passphrase: &[u8])
-> Result<Rsa, ErrorStack>
passphrase: &[u8])
-> Result<Rsa, ErrorStack>
Deserializes a PEM-formatted private key, using the supplied password if the key is encrypted.
Panics
Panics if passphrase
contains an embedded null.
fn private_key_from_pem_callback<F>(pem: &[u8],
callback: F)
-> Result<Rsa, ErrorStack> where F: FnOnce(&mut [u8]) -> Result<usize, ErrorStack>
callback: F)
-> Result<Rsa, ErrorStack> where F: FnOnce(&mut [u8]) -> Result<usize, ErrorStack>
Deserializes a PEM-formatted private key, using a callback to retrieve a password if the key is encrypted.
The callback should copy the password into the provided buffer and return the number of bytes written.
fn private_key_from_der(der: &[u8]) -> Result<Rsa, ErrorStack>
Deserializes a private key from DER-formatted data.
fn public_key_from_pem(pem: &[u8]) -> Result<Rsa, ErrorStack>
Deserializes a public key from PEM-formatted data.
fn public_key_from_der(der: &[u8]) -> Result<Rsa, ErrorStack>
Deserializes a public key from DER-formatted data.
fn private_key_from_pem_cb<F>(buf: &[u8], pass_cb: F) -> Result<Rsa, ErrorStack> where F: FnOnce(&mut [c_char]) -> usize
: use private_key_from_pem_callback
Methods from Deref<Target=RsaRef>
fn private_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack>
Serializes the private key to PEM.
fn private_key_to_pem_passphrase(&self,
cipher: Cipher,
passphrase: &[u8])
-> Result<Vec<u8>, ErrorStack>
cipher: Cipher,
passphrase: &[u8])
-> Result<Vec<u8>, ErrorStack>
Serializes the private key to PEM, encrypting it with the specified symmetric cipher and passphrase.
fn public_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack>
Serializes a public key to PEM.
fn private_key_to_der(&self) -> Result<Vec<u8>, ErrorStack>
Serializes the private key to DER.
fn public_key_to_der(&self) -> Result<Vec<u8>, ErrorStack>
Serializes the public key to DER.
fn size(&self) -> usize
fn private_decrypt(&self,
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
Decrypts data using the private key, returning the number of decrypted bytes.
Panics
Panics if self
has no private components, or if to
is smaller
than self.size()
.
fn private_encrypt(&self,
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
Encrypts data using the private key, returning the number of encrypted bytes.
Panics
Panics if self
has no private components, or if to
is smaller
than self.size()
.
fn public_decrypt(&self,
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
Decrypts data using the public key, returning the number of decrypted bytes.
Panics
Panics if to
is smaller than self.size()
.
fn public_encrypt(&self,
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
from: &[u8],
to: &mut [u8],
padding: Padding)
-> Result<usize, ErrorStack>
Encrypts data using the private key, returning the number of encrypted bytes.
Panics
Panics if to
is smaller than self.size()
.
fn n(&self) -> Option<&BigNumRef>
fn d(&self) -> Option<&BigNumRef>
fn e(&self) -> Option<&BigNumRef>
fn p(&self) -> Option<&BigNumRef>
fn q(&self) -> Option<&BigNumRef>
Trait Implementations
impl OpenSslType for Rsa
[src]
type CType = RSA
The raw C type.
type Ref = RsaRef
The type representing a reference to this type.
unsafe fn from_ptr(ptr: *mut RSA) -> Rsa
Constructs an instance of this type from its raw type.
impl Drop for Rsa
[src]
impl Deref for Rsa
[src]
type Target = RsaRef
The resulting type after dereferencing
fn deref(&self) -> &RsaRef
The method called to dereference a value