diff options
Diffstat (limited to 'vendor/elliptic-curve/src')
-rw-r--r-- | vendor/elliptic-curve/src/public_key.rs | 12 | ||||
-rw-r--r-- | vendor/elliptic-curve/src/secret_key.rs | 20 |
2 files changed, 15 insertions, 17 deletions
diff --git a/vendor/elliptic-curve/src/public_key.rs b/vendor/elliptic-curve/src/public_key.rs index e2d71b3f0..485b0ecfd 100644 --- a/vendor/elliptic-curve/src/public_key.rs +++ b/vendor/elliptic-curve/src/public_key.rs @@ -6,9 +6,6 @@ use crate::{ use core::fmt::Debug; use group::{Curve, Group}; -#[cfg(feature = "alloc")] -use alloc::boxed::Box; - #[cfg(feature = "jwk")] use crate::{JwkEcKey, JwkParameters}; @@ -26,12 +23,15 @@ use { FieldBytesSize, }, core::cmp::Ordering, - subtle::CtOption, + subtle::{Choice, CtOption}, }; #[cfg(all(feature = "alloc", feature = "pkcs8"))] use pkcs8::EncodePublicKey; +#[cfg(all(feature = "alloc", feature = "sec1"))] +use alloc::boxed::Box; + #[cfg(any(feature = "jwk", feature = "pem"))] use alloc::string::{String, ToString}; @@ -138,7 +138,7 @@ where /// (page 10). /// /// <http://www.secg.org/sec1-v2.pdf> - #[cfg(feature = "alloc")] + #[cfg(all(feature = "alloc", feature = "sec1"))] pub fn to_sec1_bytes(&self) -> Box<[u8]> where C: PointCompression, @@ -231,7 +231,7 @@ where /// Initialize [`PublicKey`] from an [`EncodedPoint`] fn from_encoded_point(encoded_point: &EncodedPoint<C>) -> CtOption<Self> { AffinePoint::<C>::from_encoded_point(encoded_point).and_then(|point| { - let is_identity = ProjectivePoint::<C>::from(point).is_identity(); + let is_identity = Choice::from(encoded_point.is_identity() as u8); CtOption::new(PublicKey { point }, !is_identity) }) } diff --git a/vendor/elliptic-curve/src/secret_key.rs b/vendor/elliptic-curve/src/secret_key.rs index 97b3d58bd..a8da65ccd 100644 --- a/vendor/elliptic-curve/src/secret_key.rs +++ b/vendor/elliptic-curve/src/secret_key.rs @@ -14,16 +14,6 @@ use generic_array::typenum::Unsigned; use subtle::{Choice, ConstantTimeEq}; use zeroize::{Zeroize, ZeroizeOnDrop}; -#[cfg(all(feature = "alloc", feature = "arithmetic"))] -use { - crate::{ - sec1::{FromEncodedPoint, ToEncodedPoint}, - AffinePoint, - }, - alloc::vec::Vec, - zeroize::Zeroizing, -}; - #[cfg(feature = "arithmetic")] use crate::{rand_core::CryptoRngCore, CurveArithmetic, NonZeroScalar, PublicKey}; @@ -34,7 +24,15 @@ use crate::jwk::{JwkEcKey, JwkParameters}; use sec1::der; #[cfg(all(feature = "alloc", feature = "arithmetic", feature = "sec1"))] -use sec1::der::Encode; +use { + crate::{ + sec1::{FromEncodedPoint, ToEncodedPoint}, + AffinePoint, + }, + alloc::vec::Vec, + sec1::der::Encode, + zeroize::Zeroizing, +}; #[cfg(all(feature = "arithmetic", any(feature = "jwk", feature = "pem")))] use alloc::string::String; |