Struct openssl::pkey::PKey
[−]
[src]
pub struct PKey(_);
Methods
impl PKey
[src]
fn from_rsa(rsa: Rsa) -> Result<PKey, ErrorStack>
Creates a new PKey
containing an RSA key.
fn from_dsa(dsa: Dsa) -> Result<PKey, ErrorStack>
Creates a new PKey
containing a DSA key.
fn from_dh(dh: Dh) -> Result<PKey, ErrorStack>
Creates a new PKey
containing a Diffie-Hellman key.
fn from_ec_key(ec_key: EcKey) -> Result<PKey, ErrorStack>
Creates a new PKey
containing an elliptic curve key.
fn hmac(key: &[u8]) -> Result<PKey, ErrorStack>
Creates a new PKey
containing an HMAC key.
fn private_key_from_pem(pem: &[u8]) -> Result<PKey, ErrorStack>
Deserializes a PEM-formatted private key.
fn private_key_from_pem_passphrase(pem: &[u8],
passphrase: &[u8])
-> Result<PKey, ErrorStack>
passphrase: &[u8])
-> Result<PKey, 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<PKey, ErrorStack> where F: FnOnce(&mut [u8]) -> Result<usize, ErrorStack>
callback: F)
-> Result<PKey, 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 public_key_from_pem(pem: &[u8]) -> Result<PKey, ErrorStack>
Deserializes a public key from PEM-formatted data.
fn private_key_from_pem_cb<F>(buf: &[u8],
pass_cb: F)
-> Result<PKey, ErrorStack> where F: FnOnce(&mut [c_char]) -> usize
pass_cb: F)
-> Result<PKey, ErrorStack> where F: FnOnce(&mut [c_char]) -> usize
: use private_key_from_pem_callback
Methods from Deref<Target=PKeyRef>
fn rsa(&self) -> Result<Rsa, ErrorStack>
Returns a copy of the internal RSA key.
fn dsa(&self) -> Result<Dsa, ErrorStack>
Returns a copy of the internal DSA key.
fn dh(&self) -> Result<Dh, ErrorStack>
Returns a copy of the internal DH key.
fn ec_key(&self) -> Result<EcKey, ErrorStack>
Returns a copy of the internal elliptic curve key.
fn public_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack>
Serializes a public key to PEM.
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 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 bits(&self) -> u32
Returns the size of the key.
This corresponds to the bit length of the modulus of an RSA key, and the bit length of the group order for an elliptic curve key, for example.
fn public_eq(&self, other: &PKeyRef) -> bool
Compares the public component of this key with another.
Trait Implementations
impl OpenSslType for PKey
[src]
type CType = EVP_PKEY
The raw C type.
type Ref = PKeyRef
The type representing a reference to this type.
unsafe fn from_ptr(ptr: *mut EVP_PKEY) -> PKey
Constructs an instance of this type from its raw type.
impl Drop for PKey
[src]
impl Deref for PKey
[src]
type Target = PKeyRef
The resulting type after dereferencing
fn deref(&self) -> &PKeyRef
The method called to dereference a value