From 07ff6341afc6662b07cad872a3144623d74cd1ee Mon Sep 17 00:00:00 2001 From: Nick Hynes Date: Wed, 28 Jul 2021 15:01:39 +0800 Subject: [PATCH] Bump dependencies --- Cargo.toml | 14 +++++++------- rust-toolchain | 1 + src/lib.rs | 16 ++++++---------- 3 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 rust-toolchain diff --git a/Cargo.toml b/Cargo.toml index f40484a..234b701 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jsonwebkey" -version = "0.3.2" +version = "0.3.4" authors = ["Nick Hynes "] description = "JSON Web Key (JWK) (de)serialization, generation, and conversion." readme = "README.md" @@ -10,18 +10,18 @@ license = "MIT" edition = "2018" [dependencies] -base64 = "0.12" +base64 = "0.13" bitflags = "1.2" generic-array = "0.14" jsonwebtoken = { version = "7.2", optional = true } -num-bigint = { version = "0.2", optional = true } -p256 = { version = "0.3", optional = true } -rand = { version = "0.7", optional = true } +num-bigint = { version = "0.4", optional = true } +p256 = { version = "0.9", optional = true, features = ["arithmetic"] } +rand = { version = "0.8", optional = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -yasna = { version = "0.3", optional = true, features = ["num-bigint"] } -zeroize = { version = "1.1", features = ["zeroize_derive"] } +yasna = { version = "0.4", optional = true, features = ["num-bigint"] } +zeroize = { version = "1.4", features = ["zeroize_derive"] } [features] pkcs-convert = ["num-bigint", "yasna"] diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..2bf5ad0 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +stable diff --git a/src/lib.rs b/src/lib.rs index 8f685f4..4a3b72a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -410,20 +410,16 @@ impl Key { /// Used with the ES256 algorithm. #[cfg(feature = "generate")] pub fn generate_p256() -> Self { - use p256::elliptic_curve::generic_array::GenericArray; - use rand::RngCore; + use p256::elliptic_curve::{self as elliptic_curve, sec1::ToEncodedPoint}; - let mut sk_bytes = GenericArray::default(); - rand::thread_rng().fill_bytes(&mut sk_bytes); - let sk = p256::SecretKey::new(sk_bytes); - let sk_scalar = p256::arithmetic::Scalar::from_secret(sk).unwrap(); + let sk = elliptic_curve::SecretKey::random(&mut rand::thread_rng()); + let sk_scalar = p256::Scalar::from(&sk); - let pk = p256::arithmetic::ProjectivePoint::generator() * &sk_scalar; + let pk = p256::ProjectivePoint::generator() * sk_scalar; let pk_bytes = &pk .to_affine() - .unwrap() - .to_uncompressed_pubkey() - .into_bytes()[1..]; + .to_encoded_point(false /* compress */) + .to_bytes()[1..]; let (x_bytes, y_bytes) = pk_bytes.split_at(32); Self::EC {