2 #![cfg_attr(docsrs, feature(doc_cfg))]
4 html_logo_url
= "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
5 html_favicon_url
= "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
7 #![forbid(unsafe_code)]
8 #![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
9 #![doc = include_str!("../README.md")]
11 //! ## `serde` support
13 //! When the `serde` feature of this crate is enabled, `Serialize` and
14 //! `Deserialize` are impl'd for the following types:
18 //! - [`ecdsa::VerifyingKey`]
20 //! Please see type-specific documentation for more information.
22 #[cfg(feature = "arithmetic")]
25 #[cfg(feature = "ecdh")]
26 #[cfg_attr(docsrs, doc(cfg(feature = "ecdh")))]
29 #[cfg(feature = "ecdsa-core")]
30 #[cfg_attr(docsrs, doc(cfg(feature = "ecdsa-core")))]
33 #[cfg(any(feature = "test-vectors", test))]
34 #[cfg_attr(docsrs, doc(cfg(feature = "test-vectors")))]
37 pub use elliptic_curve
::{self, bigint::U384}
;
39 #[cfg(feature = "arithmetic")]
40 pub use arithmetic
::{affine::AffinePoint, projective::ProjectivePoint, scalar::Scalar}
;
42 #[cfg(feature = "expose-field")]
43 pub use arithmetic
::field
::FieldElement
;
45 #[cfg(feature = "pkcs8")]
46 #[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))]
47 pub use elliptic_curve
::pkcs8
;
49 use elliptic_curve
::{consts::U49, generic_array::GenericArray}
;
51 /// NIST P-384 elliptic curve.
52 #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
55 impl elliptic_curve
::Curve
for NistP384
{
56 /// 384-bit integer type used for internally representing field elements.
59 /// Order of NIST P-384's elliptic curve group (i.e. scalar modulus).
60 const ORDER
: U384
= U384
::from_be_hex("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973");
63 impl elliptic_curve
::PrimeCurve
for NistP384 {}
65 impl elliptic_curve
::PointCompression
for NistP384
{
66 /// NIST P-384 points are typically uncompressed.
67 const COMPRESS_POINTS
: bool
= false;
70 impl elliptic_curve
::PointCompaction
for NistP384
{
71 /// NIST P-384 points are typically uncompressed.
72 const COMPACT_POINTS
: bool
= false;
75 #[cfg(feature = "jwk")]
76 #[cfg_attr(docsrs, doc(cfg(feature = "jwk")))]
77 impl elliptic_curve
::JwkParameters
for NistP384
{
78 const CRV
: &'
static str = "P-384";
81 #[cfg(feature = "pkcs8")]
82 impl pkcs8
::AssociatedOid
for NistP384
{
83 const OID
: pkcs8
::ObjectIdentifier
= pkcs8
::ObjectIdentifier
::new_unwrap("1.3.132.0.34");
86 /// Compressed SEC1-encoded NIST P-384 curve point.
87 pub type CompressedPoint
= GenericArray
<u8, U49
>;
89 /// NIST P-384 field element serialized as bytes.
91 /// Byte array containing a serialized field element value (base field or
93 pub type FieldBytes
= elliptic_curve
::FieldBytes
<NistP384
>;
95 /// NIST P-384 SEC1 encoded point.
96 pub type EncodedPoint
= elliptic_curve
::sec1
::EncodedPoint
<NistP384
>;
98 /// Non-zero NIST P-384 scalar field element.
99 #[cfg(feature = "arithmetic")]
100 pub type NonZeroScalar
= elliptic_curve
::NonZeroScalar
<NistP384
>;
102 /// NIST P-384 public key.
103 #[cfg(feature = "arithmetic")]
104 pub type PublicKey
= elliptic_curve
::PublicKey
<NistP384
>;
106 /// NIST P-384 secret key.
107 pub type SecretKey
= elliptic_curve
::SecretKey
<NistP384
>;
109 #[cfg(not(feature = "arithmetic"))]
110 impl elliptic_curve
::sec1
::ValidatePublicKey
for NistP384 {}
112 /// Bit representation of a NIST P-384 scalar field element.
113 #[cfg(feature = "bits")]
114 #[cfg_attr(docsrs, doc(cfg(feature = "bits")))]
115 pub type ScalarBits
= elliptic_curve
::ScalarBits
<NistP384
>;
117 #[cfg(feature = "voprf")]
118 #[cfg_attr(docsrs, doc(cfg(feature = "voprf")))]
119 impl elliptic_curve
::VoprfParameters
for NistP384
{
120 /// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.4-1.2>.
121 type Hash
= sha2
::Sha384
;
123 /// See <https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-4.4-1.3>.
124 const ID
: u16 = 0x0004;