Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.lock

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

10 changes: 3 additions & 7 deletions ecdsa/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ use {crate::verify::VerifyingKey, elliptic_curve::PublicKey};

#[cfg(feature = "pkcs8")]
use crate::elliptic_curve::{
consts::U1,
ops::Add,
pkcs8::{self, FromPrivateKey},
sec1::{FromEncodedPoint, ToEncodedPoint, UncompressedPointSize, UntaggedPointSize},
sec1::{self, FromEncodedPoint, ToEncodedPoint},
AffinePoint, AlgorithmParameters,
};

Expand Down Expand Up @@ -278,10 +276,9 @@ impl<C> FromPrivateKey for SigningKey<C>
where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: sec1::ModulusSize,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
{
fn from_pkcs8_private_key_info(
private_key_info: pkcs8::PrivateKeyInfo<'_>,
Expand All @@ -296,10 +293,9 @@ impl<C> FromStr for SigningKey<C>
where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: sec1::ModulusSize,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
{
type Err = Error;

Expand Down
40 changes: 10 additions & 30 deletions ecdsa/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ use crate::{
hazmat::{DigestPrimitive, FromDigest, VerifyPrimitive},
Error, Result, Signature, SignatureSize,
};
use core::{cmp::Ordering, convert::TryFrom, fmt::Debug, ops::Add};
use core::{cmp::Ordering, convert::TryFrom, fmt::Debug};
use elliptic_curve::{
consts::U1,
generic_array::ArrayLength,
sec1::{
EncodedPoint, FromEncodedPoint, ToEncodedPoint, UncompressedPointSize, UntaggedPointSize,
},
sec1::{self, EncodedPoint, FromEncodedPoint, ToEncodedPoint},
AffinePoint, FieldSize, PointCompression, PrimeCurve, ProjectiveArithmetic, PublicKey, Scalar,
};
use signature::{digest::Digest, DigestVerifier, Verifier};
Expand Down Expand Up @@ -41,8 +38,7 @@ impl<C> VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
/// Initialize [`VerifyingKey`] from a SEC1-encoded public key.
pub fn from_sec1_bytes(bytes: &[u8]) -> Result<Self> {
Expand Down Expand Up @@ -99,8 +95,7 @@ impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>
where
C: PrimeCurve + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
fn from(verifying_key: &VerifyingKey<C>) -> EncodedPoint<C> {
verifying_key.to_encoded_point(C::COMPRESS_POINTS)
Expand Down Expand Up @@ -143,21 +138,11 @@ where
}
}

impl<C> Eq for VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
{
}
impl<C> Eq for VerifyingKey<C> where C: PrimeCurve + ProjectiveArithmetic {}

impl<C> PartialEq for VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
{
fn eq(&self, other: &Self) -> bool {
self.inner.eq(&other.inner)
Expand All @@ -168,8 +153,7 @@ impl<C> PartialOrd for VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.inner.partial_cmp(&other.inner)
Expand All @@ -180,8 +164,7 @@ impl<C> Ord for VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
fn cmp(&self, other: &Self) -> Ordering {
self.inner.cmp(&other.inner)
Expand All @@ -192,8 +175,7 @@ impl<C> TryFrom<&[u8]> for VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
type Error = Error;

Expand All @@ -208,8 +190,7 @@ impl<C> FromPublicKey for VerifyingKey<C>
where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
fn from_spki(spki: pkcs8::SubjectPublicKeyInfo<'_>) -> pkcs8::Result<Self> {
PublicKey::from_spki(spki).map(|inner| Self { inner })
Expand All @@ -222,8 +203,7 @@ impl<C> FromStr for VerifyingKey<C>
where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic + PointCompression,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
UntaggedPointSize<C>: Add<U1> + ArrayLength<u8>,
UncompressedPointSize<C>: ArrayLength<u8>,
FieldSize<C>: sec1::ModulusSize,
{
type Err = Error;

Expand Down