diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/ecdsa/src/der.rs | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/ecdsa/src/der.rs')
-rw-r--r-- | vendor/ecdsa/src/der.rs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/vendor/ecdsa/src/der.rs b/vendor/ecdsa/src/der.rs index cb774232e..b4b03c172 100644 --- a/vendor/ecdsa/src/der.rs +++ b/vendor/ecdsa/src/der.rs @@ -1,4 +1,7 @@ -//! Support for ECDSA signatures encoded as ASN.1 DER. +//! Support for ASN.1 DER-encoded ECDSA signatures as specified in +//! [RFC5912 Appendix A]. +//! +//! [RFC5912 Appendix A]: https://www.rfc-editor.org/rfc/rfc5912#appendix-A use crate::{Error, Result}; use core::{ @@ -16,6 +19,7 @@ use elliptic_curve::{ use { alloc::{boxed::Box, vec::Vec}, signature::SignatureEncoding, + spki::{der::asn1::BitString, SignatureBitStringEncoding}, }; #[cfg(feature = "serde")] @@ -43,9 +47,16 @@ pub type MaxSize<C> = <<FieldBytesSize<C> as Add>::Output as Add<MaxOverhead>>:: /// Byte array containing a serialized ASN.1 signature type SignatureBytes<C> = GenericArray<u8, MaxSize<C>>; -/// ASN.1 DER-encoded signature. +/// ASN.1 DER-encoded signature as specified in [RFC5912 Appendix A]: /// -/// Generic over the scalar size of the elliptic curve. +/// ```text +/// ECDSA-Sig-Value ::= SEQUENCE { +/// r INTEGER, +/// s INTEGER +/// } +/// ``` +/// +/// [RFC5912 Appendix A]: https://www.rfc-editor.org/rfc/rfc5912#appendix-A pub struct Signature<C> where C: PrimeCurve, @@ -299,6 +310,18 @@ where } } +#[cfg(feature = "alloc")] +impl<C> SignatureBitStringEncoding for Signature<C> +where + C: PrimeCurve, + MaxSize<C>: ArrayLength<u8>, + <FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>, +{ + fn to_bitstring(&self) -> der::Result<BitString> { + BitString::new(0, self.to_vec()) + } +} + #[cfg(feature = "serde")] impl<C> Serialize for Signature<C> where |