Skip to content

Commit

Permalink
Implement VoprfParameters for NistP256 and NistP384 (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Jan 14, 2022
1 parent 273830e commit 455dd3e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/p256.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha256
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic,bits,ecdh,ecdsa,jwk,pem,pkcs8,serde,sha256
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features voprf
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic,bits,ecdh,ecdsa,jwk,pem,pkcs8,serde,sha256,voprf

test:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/p384.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ jobs:
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha384
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa,jwk,pem,pkcs8,serde,sha384
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features voprf
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa,jwk,pem,pkcs8,serde,sha384,voprf

test:
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion p256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ edition = "2021"
rust-version = "1.56"

[dependencies]
elliptic-curve = { version = "0.11.6", default-features = false, features = ["hazmat", "sec1"] }
elliptic-curve = { version = "0.11.7", default-features = false, features = ["hazmat", "sec1"] }
sec1 = { version = "0.2", default-features = false }

# optional dependencies
Expand Down Expand Up @@ -46,6 +46,7 @@ serde = ["ecdsa-core/serde", "elliptic-curve/serde", "sec1/serde"]
sha256 = ["digest", "sha2"]
std = ["ecdsa-core/std", "elliptic-curve/std"] # TODO: use weak activation for `ecdsa-core/std` when available
test-vectors = ["hex-literal"]
voprf = ["elliptic-curve/voprf", "sha2"]

[package.metadata.docs.rs]
all-features = true
Expand Down
10 changes: 10 additions & 0 deletions p256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,13 @@ impl elliptic_curve::sec1::ValidatePublicKey for NistP256 {}
#[cfg(feature = "bits")]
#[cfg_attr(docsrs, doc(cfg(feature = "bits")))]
pub type ScalarBits = elliptic_curve::ScalarBits<NistP256>;

#[cfg(feature = "voprf")]
#[cfg_attr(docsrs, doc(cfg(feature = "voprf")))]
impl elliptic_curve::VoprfParameters for NistP256 {
/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.3-1.3>.
const ID: u16 = 0x0003;

/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.3-1.2>.
type Hash = sha2::Sha256;
}
3 changes: 2 additions & 1 deletion p384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rust-version = "1.56"

[dependencies]
ecdsa = { version = "0.13", optional = true, default-features = false, features = ["der"] }
elliptic-curve = { version = "0.11", default-features = false, features = ["hazmat", "sec1"] }
elliptic-curve = { version = "0.11.7", default-features = false, features = ["hazmat", "sec1"] }
sec1 = { version = "0.2", default-features = false }
sha2 = { version = "0.9", optional = true, default-features = false }

Expand All @@ -30,6 +30,7 @@ pkcs8 = ["elliptic-curve/pkcs8"]
serde = ["ecdsa/serde", "elliptic-curve/serde", "sec1/serde"]
sha384 = ["ecdsa/digest", "ecdsa/hazmat", "sha2"]
std = ["elliptic-curve/std"]
voprf = ["elliptic-curve/voprf", "sha2"]

[package.metadata.docs.rs]
all-features = true
Expand Down
10 changes: 10 additions & 0 deletions p384/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,13 @@ pub type ScalarCore = elliptic_curve::ScalarCore<NistP384>;
pub type SecretKey = elliptic_curve::SecretKey<NistP384>;

impl elliptic_curve::sec1::ValidatePublicKey for NistP384 {}

#[cfg(feature = "voprf")]
#[cfg_attr(docsrs, doc(cfg(feature = "voprf")))]
impl elliptic_curve::VoprfParameters for NistP384 {
/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.4-1.3>.
const ID: u16 = 0x0004;

/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.4-1.2>.
type Hash = sha2::Sha384;
}

0 comments on commit 455dd3e

Please sign in to comment.