Skip to content

Commit 373e4fe

Browse files
authored
dsa: Add initial DSA implementation (#471)
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
1 parent 02dad1f commit 373e4fe

30 files changed

+2103
-2
lines changed

.github/workflows/dsa.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: dsa
2+
on:
3+
pull_request:
4+
paths:
5+
- "dsa/**"
6+
- "Cargo.*"
7+
push:
8+
branches: master
9+
10+
defaults:
11+
run:
12+
working-directory: dsa
13+
14+
env:
15+
CARGO_INCREMENTAL: 0
16+
RUSTFLAGS: "-Dwarnings"
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
target:
24+
- thumbv7em-none-eabi
25+
- wasm32-unknown-unknown
26+
toolchain:
27+
- 1.57.0 # MSRV
28+
- stable
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: actions-rs/toolchain@v1
32+
with:
33+
target: ${{ matrix.target }}
34+
toolchain: ${{ matrix.toolchain }}
35+
override: true
36+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
37+
38+
test:
39+
strategy:
40+
matrix:
41+
platform:
42+
- ubuntu-latest
43+
- macos-latest
44+
- windows-latest
45+
toolchain:
46+
- 1.57.0 # MSRV
47+
- stable
48+
runs-on: ${{ matrix.platform }}
49+
steps:
50+
- name: Enforce LF
51+
working-directory: .
52+
run: |
53+
git config --global core.autocrlf false
54+
git config --global core.eol lf
55+
56+
- uses: actions/checkout@v2
57+
- uses: actions-rs/toolchain@v1
58+
with:
59+
toolchain: ${{ matrix.toolchain }}
60+
override: true
61+
- run: cargo test --release --no-default-features
62+
- run: cargo test --release
63+
- run: cargo test --release --all-features

Cargo.lock

+139-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
resolver = "2"
33
members = [
4+
"dsa",
45
"ecdsa",
56
"ed25519",
67
"rfc6979"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and can be easily used for bare-metal or lightweight WebAssembly programming.
1313

1414
| Name | Algorithm | Crates.io | Documentation | Build |
1515
|-------------|-----------|-----------|---------------|-------|
16+
| [`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)
1617
| [`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) |
1718
| [`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)
1819
| [`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)

dsa/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target/
2+
Cargo.lock
3+
*.pem
4+
*.der

dsa/Cargo.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "dsa"
3+
version = "0.0.1"
4+
edition = "2021"
5+
license = "Apache-2.0 OR MIT"
6+
readme = "README.md"
7+
categories = ["cryptography"]
8+
keywords = ["crypto", "nist", "signature"]
9+
rust-version = "1.57"
10+
11+
[dependencies]
12+
digest = "0.10.3"
13+
num-bigint = { package = "num-bigint-dig", version = "0.8.1", default-features = false, features = ["prime", "rand", "zeroize"] }
14+
num-traits = { version = "0.2.15", default-features = false }
15+
opaque-debug = "0.3.0"
16+
paste = "1.0.7"
17+
pkcs8 = { version = "0.9.0", default-features = false, features = ["alloc"] }
18+
rand = { version = "0.8.5", default-features = false }
19+
rfc6979 = { version = "0.2.0", path = "../rfc6979" }
20+
signature = { version = ">= 1.5.0, < 1.6.0", default-features = false, features = ["digest-preview", "rand-preview"] }
21+
zeroize = { version = "1.5.5", default-features = false }
22+
23+
[features]
24+
default = []
25+
26+
[dev-dependencies]
27+
pkcs8 = { version = "0.9.0", default-features = false, features = ["pem"] }
28+
rand = "0.8.5"
29+
rand_chacha = "0.3.1"
30+
sha1 = "0.10.1"
31+
sha2 = "0.10.2"

0 commit comments

Comments
 (0)