Skip to content

Commit

Permalink
dsa: Add initial DSA implementation (#471)
Browse files Browse the repository at this point in the history
Adds an initial implementation of DSA (see #8)  

The following things work when tested against OpenSSL:

- The generated keys are valid and can be imported and exported from/to their DER/PEM representation
- Signatures generated by this library can be successfully verified
- Signatures can be imported and exported from/into their DER representation
- Signatures generated by OpenSSL can be successfully imported and verified
  • Loading branch information
aumetra authored May 16, 2022
1 parent 02dad1f commit 373e4fe
Show file tree
Hide file tree
Showing 30 changed files with 2,103 additions and 2 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/dsa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: dsa
on:
pull_request:
paths:
- "dsa/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: dsa

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- thumbv7em-none-eabi
- wasm32-unknown-unknown
toolchain:
- 1.57.0 # MSRV
- stable
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: ${{ matrix.toolchain }}
override: true
- run: cargo build --target ${{ matrix.target }} --release --no-default-features

test:
strategy:
matrix:
platform:
- ubuntu-latest
- macos-latest
- windows-latest
toolchain:
- 1.57.0 # MSRV
- stable
runs-on: ${{ matrix.platform }}
steps:
- name: Enforce LF
working-directory: .
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
- run: cargo test --release --no-default-features
- run: cargo test --release
- run: cargo test --release --all-features
141 changes: 139 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
resolver = "2"
members = [
"dsa",
"ecdsa",
"ed25519",
"rfc6979"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and can be easily used for bare-metal or lightweight WebAssembly programming.

| Name | Algorithm | Crates.io | Documentation | Build |
|-------------|-----------|-----------|---------------|-------|
| [`dsa`] | [DSA](https://en.wikipedia.org/wiki/Digital_Signature_Algorithm) | [![crates.io](https://img.shields.io/crates/v/dsa.svg)](https://crates.io/crates/dsa) | [![Documentation](https://docs.rs/dsa/badge.svg)](https://docs.rs/dsa) | [![dsa build](https://github.com/RustCrypto/signatures/workflows/dsa/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Adsa)
| [`ecdsa`] | [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) | [![crates.io](https://img.shields.io/crates/v/ecdsa.svg)](https://crates.io/crates/ecdsa) | [![Documentation](https://docs.rs/ecdsa/badge.svg)](https://docs.rs/ecdsa) | [![ecdsa build](https://github.com/RustCrypto/signatures/workflows/ecdsa/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Aecdsa) |
| [`ed25519`] | [Ed25519](https://en.wikipedia.org/wiki/EdDSA) | [![crates.io](https://img.shields.io/crates/v/ed25519.svg)](https://crates.io/crates/ed25519) | [![Documentation](https://docs.rs/ed25519/badge.svg)](https://docs.rs/ed25519) | [![ed25519 build](https://github.com/RustCrypto/signatures/workflows/ed25519/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Aed25519)
| [`rfc6979`] | [RFC6979](https://datatracker.ietf.org/doc/html/rfc6979) | [![crates.io](https://img.shields.io/crates/v/rfc6979.svg)](https://crates.io/crates/rfc6979) | [![Documentation](https://docs.rs/rfc6979/badge.svg)](https://docs.rs/rfc6979) | [![rfc6979 build](https://github.com/RustCrypto/signatures/actions/workflows/rfc6979.yml/badge.svg)](https://github.com/RustCrypto/signatures/actions/workflows/rfc6979.yml)
Expand Down
4 changes: 4 additions & 0 deletions dsa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/
Cargo.lock
*.pem
*.der
31 changes: 31 additions & 0 deletions dsa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "dsa"
version = "0.0.1"
edition = "2021"
license = "Apache-2.0 OR MIT"
readme = "README.md"
categories = ["cryptography"]
keywords = ["crypto", "nist", "signature"]
rust-version = "1.57"

[dependencies]
digest = "0.10.3"
num-bigint = { package = "num-bigint-dig", version = "0.8.1", default-features = false, features = ["prime", "rand", "zeroize"] }
num-traits = { version = "0.2.15", default-features = false }
opaque-debug = "0.3.0"
paste = "1.0.7"
pkcs8 = { version = "0.9.0", default-features = false, features = ["alloc"] }
rand = { version = "0.8.5", default-features = false }
rfc6979 = { version = "0.2.0", path = "../rfc6979" }
signature = { version = ">= 1.5.0, < 1.6.0", default-features = false, features = ["digest-preview", "rand-preview"] }
zeroize = { version = "1.5.5", default-features = false }

[features]
default = []

[dev-dependencies]
pkcs8 = { version = "0.9.0", default-features = false, features = ["pem"] }
rand = "0.8.5"
rand_chacha = "0.3.1"
sha1 = "0.10.1"
sha2 = "0.10.2"
Loading

0 comments on commit 373e4fe

Please sign in to comment.