p192/ecdsa.rs
1//! Elliptic Curve Digital Signature Algorithm (ECDSA)
2//!
3//! This module contains support for computing and verifying ECDSA signatures.
4//! To use it, you will need to enable one of the two following Cargo features:
5//!
6//! - `ecdsa-core`: provides only the [`Signature`] type (which represents an
7//! ECDSA/P-192 signature). Does not require the `arithmetic` feature. This is
8//! useful for 3rd-party crates which wish to use the `Signature` type for
9//! interoperability purposes. Example use cases for this include other
10//! software implementations of ECDSA/P-192 and wrappers for cloud KMS
11//! services or hardware devices (HSM or crypto hardware wallet).
12//! - `ecdsa`: provides `ecdsa-core` features plus [`VerifyingKey`] types
13//! which natively implement ECDSA/P-192 verification.
14//!
15//! ## Verification only
16//!
17//! Following guidance from [NIST Special Publication 800-131A Revision 2]:
18//! "Transitioning the Use of Cryptographic Algorithms and Key Lengths", this
19//! crate only supports ECDSA verification, not signing.
20//!
21//! From Section 3: Digital Signatures:
22//!
23//! > <112 bits of security strength: ECDSA: len(n) < 224
24//! >
25//! > [...]
26//! >
27//! > Digital signature generation:
28//! >
29//! > Private-key lengths providing less than 112 bits of security **shall not** be used to
30//! > generate digital signatures.
31//!
32//! [NIST Special Publication 800-131A Revision 2]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
33
34pub use ecdsa_core::signature::{self, Error};
35#[cfg(feature = "ecdsa")]
36use {crate::AffinePoint, ecdsa_core::hazmat::VerifyPrimitive};
37
38use super::NistP192;
39
40/// ECDSA/P-192 signature (fixed-size)
41pub type Signature = ecdsa_core::Signature<NistP192>;
42
43/// ECDSA/P-192 signature (ASN.1 DER encoded)
44pub type DerSignature = ecdsa_core::der::Signature<NistP192>;
45
46/// ECDSA/P-192 verification key (i.e. public key)
47#[cfg(feature = "ecdsa")]
48pub type VerifyingKey = ecdsa_core::VerifyingKey<NistP192>;
49
50#[cfg(feature = "ecdsa")]
51impl VerifyPrimitive<NistP192> for AffinePoint {}
52
53#[cfg(all(test, feature = "ecdsa"))]
54mod tests {
55 mod verify {
56 use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP192};
57 ecdsa_core::new_verification_test!(NistP192, ECDSA_TEST_VECTORS);
58 }
59}