Make rsa::{self, public::{self, *}} public.

This commit is contained in:
Brian Smith 2021-09-22 11:31:52 -07:00
parent 6a6ea5893e
commit e05f7e1273
6 changed files with 12 additions and 6 deletions

View File

@ -105,7 +105,7 @@ pub mod pkcs8;
pub mod rand; pub mod rand;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
mod rsa; pub mod rsa;
pub mod signature; pub mod signature;

View File

@ -17,7 +17,7 @@
// naming conventions. Also the standard camelCase names are used for `KeyPair` // naming conventions. Also the standard camelCase names are used for `KeyPair`
// components. // components.
//! Low-level RSA primitives. //! RSA.
use crate::{ use crate::{
arithmetic::bigint, arithmetic::bigint,

View File

@ -12,7 +12,7 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//! Low-level RSA public key API. //! RSA public keys.
mod components; mod components;
mod exponent; mod exponent;

View File

@ -1,7 +1,7 @@
use crate::error; use crate::error;
use core::num::NonZeroU64; use core::num::NonZeroU64;
/// The exponent `e` of the RSA public key. /// The exponent `e` of an RSA public key.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub struct Exponent(NonZeroU64); pub struct Exponent(NonZeroU64);
@ -30,7 +30,7 @@ impl Exponent {
// stable. // stable.
const MAX: Self = Self(unsafe { NonZeroU64::new_unchecked((1u64 << 33) - 1) }); const MAX: Self = Self(unsafe { NonZeroU64::new_unchecked((1u64 << 33) - 1) });
pub fn from_be_bytes( pub(super) fn from_be_bytes(
input: untrusted::Input, input: untrusted::Input,
min_value: Self, min_value: Self,
) -> Result<Self, error::KeyRejected> { ) -> Result<Self, error::KeyRejected> {

View File

@ -15,6 +15,7 @@
use super::{Exponent, Modulus}; use super::{Exponent, Modulus};
use crate::{bits, error}; use crate::{bits, error};
/// An RSA Public Key.
#[derive(Debug)] #[derive(Debug)]
pub struct Key { pub struct Key {
n: Modulus, n: Modulus,
@ -22,7 +23,7 @@ pub struct Key {
} }
impl Key { impl Key {
pub fn from_modulus_and_exponent( pub(in super::super) fn from_modulus_and_exponent(
n: untrusted::Input, n: untrusted::Input,
e: untrusted::Input, e: untrusted::Input,
n_min_bits: bits::BitLength, n_min_bits: bits::BitLength,
@ -52,10 +53,14 @@ impl Key {
Ok(Self { n, e }) Ok(Self { n, e })
} }
/// The public modulus.
#[inline]
pub fn n(&self) -> &Modulus { pub fn n(&self) -> &Modulus {
&self.n &self.n
} }
/// The public exponent.
#[inline]
pub fn e(&self) -> Exponent { pub fn e(&self) -> Exponent {
self.e self.e
} }

View File

@ -1,6 +1,7 @@
use crate::{arithmetic::bigint, bits, error, rsa::N}; use crate::{arithmetic::bigint, bits, error, rsa::N};
use core::ops::RangeInclusive; use core::ops::RangeInclusive;
/// The modulus (n) of an RSA public key.
pub struct Modulus { pub struct Modulus {
value: bigint::Modulus<N>, value: bigint::Modulus<N>,
bits: bits::BitLength, bits: bits::BitLength,