Skip to content

Commit 455dd3e

Browse files
authored
Implement VoprfParameters for NistP256 and NistP384 (#506)
1 parent 273830e commit 455dd3e

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed

.github/workflows/p256.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ jobs:
4646
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
4747
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
4848
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha256
49-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic,bits,ecdh,ecdsa,jwk,pem,pkcs8,serde,sha256
49+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features voprf
50+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features arithmetic,bits,ecdh,ecdsa,jwk,pem,pkcs8,serde,sha256,voprf
5051

5152
test:
5253
runs-on: ubuntu-latest

.github/workflows/p384.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ jobs:
4545
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
4646
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde
4747
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sha384
48-
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa,jwk,pem,pkcs8,serde,sha384
48+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features voprf
49+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features ecdsa,jwk,pem,pkcs8,serde,sha384,voprf
4950

5051
test:
5152
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

p256/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ edition = "2021"
1717
rust-version = "1.56"
1818

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

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

5051
[package.metadata.docs.rs]
5152
all-features = true

p256/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,13 @@ impl elliptic_curve::sec1::ValidatePublicKey for NistP256 {}
150150
#[cfg(feature = "bits")]
151151
#[cfg_attr(docsrs, doc(cfg(feature = "bits")))]
152152
pub type ScalarBits = elliptic_curve::ScalarBits<NistP256>;
153+
154+
#[cfg(feature = "voprf")]
155+
#[cfg_attr(docsrs, doc(cfg(feature = "voprf")))]
156+
impl elliptic_curve::VoprfParameters for NistP256 {
157+
/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.3-1.3>.
158+
const ID: u16 = 0x0003;
159+
160+
/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.3-1.2>.
161+
type Hash = sha2::Sha256;
162+
}

p384/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.56"
1414

1515
[dependencies]
1616
ecdsa = { version = "0.13", optional = true, default-features = false, features = ["der"] }
17-
elliptic-curve = { version = "0.11", default-features = false, features = ["hazmat", "sec1"] }
17+
elliptic-curve = { version = "0.11.7", default-features = false, features = ["hazmat", "sec1"] }
1818
sec1 = { version = "0.2", default-features = false }
1919
sha2 = { version = "0.9", optional = true, default-features = false }
2020

@@ -30,6 +30,7 @@ pkcs8 = ["elliptic-curve/pkcs8"]
3030
serde = ["ecdsa/serde", "elliptic-curve/serde", "sec1/serde"]
3131
sha384 = ["ecdsa/digest", "ecdsa/hazmat", "sha2"]
3232
std = ["elliptic-curve/std"]
33+
voprf = ["elliptic-curve/voprf", "sha2"]
3334

3435
[package.metadata.docs.rs]
3536
all-features = true

p384/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,13 @@ pub type ScalarCore = elliptic_curve::ScalarCore<NistP384>;
106106
pub type SecretKey = elliptic_curve::SecretKey<NistP384>;
107107

108108
impl elliptic_curve::sec1::ValidatePublicKey for NistP384 {}
109+
110+
#[cfg(feature = "voprf")]
111+
#[cfg_attr(docsrs, doc(cfg(feature = "voprf")))]
112+
impl elliptic_curve::VoprfParameters for NistP384 {
113+
/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.4-1.3>.
114+
const ID: u16 = 0x0004;
115+
116+
/// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.4-1.2>.
117+
type Hash = sha2::Sha384;
118+
}

0 commit comments

Comments
 (0)