Struct openssl::dsa::Dsa
[−]
pub struct Dsa(_);
Object representing DSA keys.
A DSA object contains the parameters p, q, and g. There is a private and public key. The values p, g, and q are:
p
: DSA prime parameterq
: DSA sub-prime parameterg
: DSA base parameter
These values are used to calculate a pair of asymetrical keys used for signing.
OpenSSL documentation at DSA_new
Examples
use openssl::dsa::Dsa; use openssl::error::ErrorStack; fn create_dsa() -> Result< Dsa, ErrorStack > { let sign = Dsa::generate(2048)?; Ok(sign) }
Methods
impl Dsa
[src]
pub fn generate(bits: u32) -> Result<Dsa, ErrorStack>
[src]
Generate a DSA key pair.
Calls DSA_generate_parameters_ex
to populate the p
, g
, and q
values.
These values are used to generate the key pair with DSA_generate_key
.
The bits
parameter coresponds to the length of the prime p
.
pub fn private_key_from_pem(pem: &[u8]) -> Result<Dsa, ErrorStack>
[src]
Deserializes a PEM-formatted private key.
pub fn private_key_from_pem_passphrase(
pem: &[u8],
passphrase: &[u8]
) -> Result<Dsa, ErrorStack>
[src]
pem: &[u8],
passphrase: &[u8]
) -> Result<Dsa, ErrorStack>
Deserializes a PEM-formatted private key, using the supplied password if the key is encrypted.
Panics
Panics if passphrase
contains an embedded null.
pub fn private_key_from_pem_callback<F>(
pem: &[u8],
callback: F
) -> Result<Dsa, ErrorStack> where
F: FnOnce(&mut [u8]) -> Result<usize, ErrorStack>,
[src]
pem: &[u8],
callback: F
) -> Result<Dsa, 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.
pub fn private_key_from_der(der: &[u8]) -> Result<Dsa, ErrorStack>
[src]
Deserializes a private key from DER-formatted data.
pub fn public_key_from_pem(pem: &[u8]) -> Result<Dsa, ErrorStack>
[src]
Deserializes a public key from PEM-formatted data.
pub fn public_key_from_der(der: &[u8]) -> Result<Dsa, ErrorStack>
[src]
Deserializes a public key from DER-formatted data.
pub fn private_key_from_pem_cb<F>(
buf: &[u8],
pass_cb: F
) -> Result<Dsa, ErrorStack> where
F: FnOnce(&mut [c_char]) -> usize,
[src]
buf: &[u8],
pass_cb: F
) -> Result<Dsa, ErrorStack> where
F: FnOnce(&mut [c_char]) -> usize,
: use private_key_from_pem_callback
Methods from Deref<Target = DsaRef>
pub fn private_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack>
[src]
Serializes the private key to PEM.
pub fn private_key_to_pem_passphrase(
&self,
cipher: Cipher,
passphrase: &[u8]
) -> Result<Vec<u8>, ErrorStack>
[src]
&self,
cipher: Cipher,
passphrase: &[u8]
) -> Result<Vec<u8>, ErrorStack>
Serializes the private key to PEM, encrypting it with the specified symmetric cipher and passphrase.
pub fn public_key_to_pem(&self) -> Result<Vec<u8>, ErrorStack>
[src]
Serializes a public key to PEM.
pub fn private_key_to_der(&self) -> Result<Vec<u8>, ErrorStack>
[src]
Serializes the private key to DER.
pub fn public_key_to_der(&self) -> Result<Vec<u8>, ErrorStack>
[src]
Serializes the public key to DER.
pub fn size(&self) -> Option<u32>
[src]
Returns the maximum size of the signature output by self
in bytes. Returns
None if the keys are uninitialized.
OpenSSL documentation at DSA_size
pub fn p(&self) -> Option<&BigNumRef>
[src]
Returns the DSA prime parameter of self
.
pub fn q(&self) -> Option<&BigNumRef>
[src]
Returns the DSA sub-prime parameter of self
.
pub fn g(&self) -> Option<&BigNumRef>
[src]
Returns the DSA base parameter of self
.
pub fn has_public_key(&self) -> bool
[src]
Returns whether the DSA includes a public key, used to confirm the authenticity of the message.
pub fn has_private_key(&self) -> bool
[src]
Returns whether the DSA includes a private key, used to prove the authenticity of a message.
Trait Implementations
impl ForeignType for Dsa
type CType = DSA
The raw C type.
type Ref = DsaRef
The type representing a reference to this type.
unsafe fn from_ptr(ptr: *mut DSA) -> Dsa
Constructs an instance of this type from its raw type.
fn as_ptr(&self) -> *mut DSA
Returns a raw pointer to the wrapped value.
impl Drop for Dsa
impl Deref for Dsa
type Target = DsaRef
The resulting type after dereferencing.
fn deref(&self) -> &DsaRef
Dereferences the value.