Skip to content

Commit

Permalink
bign-curve256v1 (RustCrypto#796)
Browse files Browse the repository at this point in the history
bign curve (STB 34.101.45-2013)
  • Loading branch information
makavity authored May 20, 2023
1 parent 1ccab73 commit b2e2818
Show file tree
Hide file tree
Showing 25 changed files with 17,063 additions and 0 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/bign256.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: bign256

on:
pull_request:
paths:
- ".github/workflows/bign256.yml"
- "bign256/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: bign256

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"
RUSTDOCFLAGS: "-Dwarnings"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.65.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8

test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# 32-bit Linux
- target: i686-unknown-linux-gnu
rust: 1.65.0 # MSRV
deps: sudo apt update && sudo apt install gcc-multilib
- target: i686-unknown-linux-gnu
rust: stable
deps: sudo apt update && sudo apt install gcc-multilib

# 64-bit Linux
- target: x86_64-unknown-linux-gnu
rust: 1.65.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: ${{ matrix.deps }}
- run: cargo check --target ${{ matrix.target }} --all-features
- run: cargo test --release --target ${{ matrix.target }} --no-default-features
- run: cargo test --release --target ${{ matrix.target }}
- run: cargo test --release --target ${{ matrix.target }} --all-features

cross:
strategy:
matrix:
include:
# ARM32
- target: armv7-unknown-linux-gnueabihf
rust: 1.65.0 # MSRV (cross)
- target: armv7-unknown-linux-gnueabihf
rust: stable

# ARM64
- target: aarch64-unknown-linux-gnu
rust: 1.65.0 # MSRV (cross)
- target: aarch64-unknown-linux-gnu
rust: stable

# PPC32
- target: powerpc-unknown-linux-gnu
rust: 1.65.0 # MSRV (cross)
- target: powerpc-unknown-linux-gnu
rust: stable

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: ${{ matrix.deps }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cross-install@master
- run: cross test --release --target ${{ matrix.target }} --all-features

doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- run: cargo doc --all-features
28 changes: 28 additions & 0 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 = [
"bign256",
"bp256",
"bp384",
"k256",
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NOTE: Most crates have field/point arithmetic implementations gated under the

| Name | Curve | `arithmetic`? | Crates.io | Documentation | Build Status |
|-----------|--------------------|---------------|-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [`bign256`] | bign-curve256v1 || [![crates.io](https://img.shields.io/crates/v/bign256.svg)](https://crates.io/crates/bign256) | [![Documentation](https://docs.rs/bign256/badge.svg)](https://docs.rs/bign256) | ![build](https://github.com/RustCrypto/elliptic-curves/workflows/bign256/badge.svg?branch=master&event=push) |
| [`bp256`] | brainpoolP256r1/t1 | 🚧 | [![crates.io](https://img.shields.io/crates/v/bp256.svg)](https://crates.io/crates/bp256) | [![Documentation](https://docs.rs/bp256/badge.svg)](https://docs.rs/bp256) | ![build](https://github.com/RustCrypto/elliptic-curves/workflows/bp256/badge.svg?branch=master&event=push) |
| [`bp384`] | brainpoolP384r1/t1 | 🚧 | [![crates.io](https://img.shields.io/crates/v/bp384.svg)](https://crates.io/crates/bp384) | [![Documentation](https://docs.rs/bp384/badge.svg)](https://docs.rs/bp384) | ![build](https://github.com/RustCrypto/elliptic-curves/workflows/bp384/badge.svg?branch=master&event=push) |
| [`k256`] | [secp256k1] || [![crates.io](https://img.shields.io/crates/v/k256.svg)](https://crates.io/crates/k256) | [![Documentation](https://docs.rs/k256/badge.svg)](https://docs.rs/k256) | ![build](https://github.com/RustCrypto/elliptic-curves/workflows/k256/badge.svg?branch=master&event=push) |
Expand Down Expand Up @@ -64,6 +65,7 @@ dual licensed as above, without any additional terms or conditions.

[//]: # (crates)

[`bign256`]: ./bign256
[`bp256`]: ./bp256
[`bp384`]: ./bp384
[`k256`]: ./k256
Expand All @@ -83,6 +85,7 @@ dual licensed as above, without any additional terms or conditions.
[NIST P-384]: https://neuromancer.sk/std/nist/P-384
[NIST P-521]: https://neuromancer.sk/std/nist/P-521
[SM2]: https://neuromancer.sk/std/oscaa/SM2
[BIGN P-256]: https://apmi.bsu.by/assets/files/std/bign-spec294.pdf

[//]: # (links)

Expand Down
2 changes: 2 additions & 0 deletions bign256/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/Cargo.lock
6 changes: 6 additions & 0 deletions bign256/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

45 changes: 45 additions & 0 deletions bign256/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
name = "bign256"
version = "0.0.0"
description = """
Pure Rust implementation of the Bign P-256 (a.k.a. bign-curve256v1)
elliptic curve as defined in STB 34.101.45-2013, with
general purpose curve arithmetic
"""
authors = ["RustCrypto Developers"]
license = "Apache-2.0 OR MIT"
documentation = "https://docs.rs/bign-curve256v1"
repository = "https://github.com/RustCrypto/elliptic-curves/tree/master/bign256"
readme = "README.md"
categories = ["cryptography", "no-std"]
keywords = ["crypto", "ecc", "stb", "bign-curve256v1", "bignp256"]
edition = "2021"
rust-version = "1.65"

[dependencies]
elliptic-curve = { version = "0.13.1", features = ["hazmat", "sec1", "arithmetic"] }
primeorder = { version = "0.13", path = "../primeorder" }

ecdsa-core = { version = "0.16", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
serdect = { version = "0.2", optional = true, default-features = false }
belt-hash = { version = "0.1.0", optional = true }

[dev-dependencies]
hex-literal = "0.4"
criterion = "0.4"


[features]
default = ["pkcs8", "std"]
alloc = ["ecdsa-core?/alloc", "elliptic-curve/alloc"]
std = ["alloc", "ecdsa-core?/std", "elliptic-curve/std"]

pkcs8 = ["ecdsa-core/pkcs8", "elliptic-curve/pkcs8"]

[[bench]]
name = "field"
harness = false

[[bench]]
name = "scalar"
harness = false
Loading

0 comments on commit b2e2818

Please sign in to comment.