Struct openssl::dsa::Dsa

source ·
pub struct Dsa<T>(_, _);
Expand description

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 parameter
  • q: DSA sub-prime parameter
  • g: 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;
use openssl::pkey::Private;

fn create_dsa() -> Result<Dsa<Private>, ErrorStack> {
    let sign = Dsa::generate(2048)?;
    Ok(sign)
}

Implementations

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 corresponds to the length of the prime p.

Create a DSA key pair with the given parameters

p, q and g are the common parameters. priv_key is the private component of the key pair. pub_key is the public component of the key. Can be computed via g^(priv_key) mod p

Decodes a PEM-encoded SubjectPublicKeyInfo structure containing a DSA key.

The input should have a header of -----BEGIN PUBLIC KEY-----.

This corresponds to PEM_read_bio_DSA_PUBKEY.

Decodes a DER-encoded SubjectPublicKeyInfo structure containing a DSA key.

This corresponds to d2i_DSA_PUBKEY.

Create a new DSA key with only public components.

p, q and g are the common parameters. pub_key is the public component of the key.

Methods from Deref<Target = DsaRef<T>>

Serialies the public key into a PEM-encoded SubjectPublicKeyInfo structure.

The output will have a header of -----BEGIN PUBLIC KEY-----.

This corresponds to PEM_write_bio_DSA_PUBKEY.

Serializes the public key into a DER-encoded SubjectPublicKeyInfo structure.

This corresponds to i2d_DSA_PUBKEY.

Returns a reference to the public key component of self.

Returns a reference to the private key component of self.

Returns the maximum size of the signature output by self in bytes.

OpenSSL documentation at DSA_size

Returns the DSA prime parameter of self.

Returns the DSA sub-prime parameter of self.

Returns the DSA base parameter of self.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Executes the destructor for this type. Read more
The raw C type.
The type representing a reference to this type.
Constructs an instance of this type from its raw type.
Returns a raw pointer to the wrapped value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.