Crate dsa

source ·
Expand description

§RustCrypto: DSA

crate Docs Build Status Apache2/MIT licensed MSRV Project Chat

Digital Signature Algorithm (DSA) as specified in FIPS 186-4 (Digital Signature Standard).



This crate provides an implementation of DSA in pure Rust.

It utilises the signature crate to provide an interface for creating and verifying signatures.

§⚠️ Security Warning

The DSA implementation contained in this crate has never been independently audited for security.

It may contain timing variabilities or other sidechannels which could potentially disclose secret information, including secret keys.


§Minimum Supported Rust Version

This crate requires Rust 1.65 at a minimum.

We may change the MSRV in the future, but it will be accompanied by a minor version bump.


All crates licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


Generate a DSA keypair

let mut csprng = rand::thread_rng();
let components = Components::generate(&mut csprng, KeySize::DSA_2048_256);
let signing_key = SigningKey::generate(&mut csprng, components);
let verifying_key = signing_key.verifying_key();

Create keypair from existing components

let (p, q, g) = read_common_parameters();
let components = Components::from_components(p, q, g)?;

let x = read_public_component();
let verifying_key = VerifyingKey::from_components(components, x)?;

let y = read_private_component();
let signing_key = SigningKey::from_components(verifying_key, y)?;




  • DSA object identifier as defined by [RFC3279 § 2.3.2].