Skip to main content

sec1/
lib.rs

1#![no_std]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![doc = include_str!("../README.md")]
4#![doc(
5    html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
6    html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
7)]
8#![forbid(unsafe_code)]
9#![warn(
10    clippy::mod_module_files,
11    clippy::unwrap_used,
12    missing_docs,
13    rust_2018_idioms,
14    unused_qualifications
15)]
16
17//! ## `serde` support
18//!
19//! When the `serde` feature of this crate is enabled, the [`EncodedPoint`]
20//! type receives impls of [`serde::Serialize`] and [`serde::Deserialize`].
21//!
22//! Additionally, when both the `alloc` and `serde` features are enabled, the
23//! serializers/deserializers will autodetect if a "human friendly" textual
24//! encoding is being used, and if so encode the points as hexadecimal.
25
26#[cfg(feature = "alloc")]
27#[allow(unused_extern_crates)]
28extern crate alloc;
29#[cfg(feature = "std")]
30extern crate std;
31
32#[cfg(feature = "point")]
33pub mod point;
34
35mod error;
36#[cfg(feature = "der")]
37mod parameters;
38#[cfg(feature = "der")]
39mod private_key;
40#[cfg(feature = "der")]
41mod traits;
42
43pub use crate::error::{Error, Result};
44
45#[cfg(feature = "point")]
46pub use crate::point::EncodedPoint;
47#[cfg(all(feature = "alloc", feature = "der"))]
48pub use crate::traits::EncodeEcPrivateKey;
49#[cfg(feature = "der")]
50pub use crate::{parameters::EcParameters, private_key::EcPrivateKey, traits::DecodeEcPrivateKey};
51#[cfg(feature = "der")]
52pub use der;
53#[cfg(feature = "pem")]
54pub use der::pem::{self, LineEnding};
55#[cfg(feature = "point")]
56pub use hybrid_array::typenum::consts;
57
58#[cfg(feature = "der")]
59use der::asn1::ObjectIdentifier;
60#[cfg(all(doc, feature = "serde"))]
61use serdect::serde;
62
63/// Algorithm [`ObjectIdentifier`] for elliptic curve public key cryptography (`id-ecPublicKey`).
64///
65/// <http://oid-info.com/get/1.2.840.10045.2.1>
66#[cfg(feature = "der")]
67pub const ALGORITHM_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.10045.2.1");