Struct rsa_cortex_m4::numbers::Unsigned [−][src]
Multi-precision unsigned integer with at most $D + E$ digits (places) – two Limb
s.
Workaround type for limitations of const generics on stable; the interesting cases are:
The former is used for RSA prime pairs $(P, Q)$, the latter for RSA public keys $N = PQ$.
Mnemonics: D
for digits, E
for "extra" digits.
Implementations
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn checked_add(&self, summand: &Self) -> Option<Self>
[src]
pub fn wrapping_add_assign(&mut self, summand: &Self)
[src]
pub fn wrapping_add(&self, summand: &Self) -> Self
[src]
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn wrapping_neg(&self) -> Self
[src]
pub fn checked_sub(&self, subtrahend: &Self) -> Option<Self>
[src]
pub fn wrapping_sub_assign<T: Number>(&mut self, subtrahend: &T)
[src]
pub fn wrapping_sub(&self, subtrahend: &Self) -> Self
[src]
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn wrapping_mul(&self, factor: &Self) -> Self
[src]
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn wrapping_inv(&self) -> Result<Self>
[src]
The wrapping inverse, i.e., the exact inverse w.r.t wrapping multiplication.
Exists if and only if the number is odd.
This uses $\mathcal{O}(\log n)$ loops in Self::BITS
, very efficient (!)
Source: Fig. 1 from GCD-Free Algorithms for Computing Modular Inverses (2003)
Note that this source is highly confusing! What they mean to say is to iterate $y \leftarrow y(2 - ey)$ in $\mathbb{Z}/2^{|f|}$, where the output is an inverse of $e$ modulo $2^{2i}$. In other words, the $\text{mod }2^i$ is a typo, and should be $\text{mod }2^{|f|}$.
cf. also Crypto StackExchange.
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn modulo<'n, const F: usize, const G: usize>(
&self,
n: &'n Convenient<F, G>
) -> Modular<'n, F, G>
[src]
&self,
n: &'n Convenient<F, G>
) -> Modular<'n, F, G>
The associated residue class modulo n.
Note that storage requirements of the residue class are the same as the modulus (+ reference to it), not the original integer.
This uses incomplete reduction ([Self::partially_reduce
]) for efficiency.
pub fn modulo_prime<'p, const F: usize, const G: usize>(
&self,
p: &'p Prime<F, G>
) -> PrimeModular<'p, F, G>
[src]
&self,
p: &'p Prime<F, G>
) -> PrimeModular<'p, F, G>
pub fn reduce<const F: usize, const G: usize>(
&self,
n: &Unsigned<F, G>
) -> Unsigned<F, G>
[src]
&self,
n: &Unsigned<F, G>
) -> Unsigned<F, G>
The canonical (completely) reduced representative of the associated residue class modulo $n$.
Cf. Modular
.
impl Unsigned<D, 0_usize>
[src]
pub const fn from_digit(digit: Digit) -> Self
[src]
const
implementation
pub const fn digit(&self) -> Digit
[src]
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn to_bytes(&self) -> BigEndian<D, E, 1>
[src]
Return buffer that dereferences as big-endian bytes.
impl<const D: usize, const E: usize> Unsigned<D, E>
[src]
pub fn from_slice(slice: &[Digit]) -> Self
[src]
pub fn try_from_slice(slice: &[Digit]) -> Result<Self>
[src]
pub fn leading_digit(&self) -> Option<Digit>
[src]
pub fn significant_digits(&self) -> &[Digit]
[src]
pub fn to_unsigned<const M: usize, const N: usize>(
&self
) -> Result<Unsigned<M, N>>
[src]
&self
) -> Result<Unsigned<M, N>>
Trait Implementations
impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> Add<&'b Unsigned<F, G>> for Modular<'a, D, E>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, summand: &'b Unsigned<F, G>) -> Self::Output
[src]
impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> AddAssign<&'b Unsigned<F, G>> for Modular<'a, D, E>
[src]
fn add_assign(&mut self, summand: &'b Unsigned<F, G>)
[src]
impl<const D: usize, const E: usize> AsRef<Unsigned<D, E>> for Convenient<D, E>
[src]
impl<const D: usize, const E: usize> Clone for Unsigned<D, E>
[src]
fn clone(&self) -> Unsigned<D, E>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<const D: usize, const E: usize> Debug for Unsigned<D, E>
[src]
fn fmt(&self, f: &mut Formatter<'_>) -> Result
[src]
TODO: Do we want debug output to be big-endian bytes (as currently implemented)? Or stick with internal representation?
impl<const D: usize, const E: usize> Default for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> Deref for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> DerefMut for Unsigned<D, E>
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Div<&'a Unsigned<F, G>> for &'a Unsigned<D, E>
[src]
type Output = Unsigned<D, E>
The resulting type after applying the /
operator.
fn div(self, modulus: &'a Unsigned<F, G>) -> Self::Output
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Div<&'a Unsigned<F, G>> for Unsigned<D, E>
[src]
type Output = Unsigned<D, E>
The resulting type after applying the /
operator.
fn div(self, modulus: &'a Unsigned<F, G>) -> Self::Output
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Div<Unsigned<F, G>> for &'a Unsigned<D, E>
[src]
type Output = Unsigned<D, E>
The resulting type after applying the /
operator.
fn div(self, modulus: Unsigned<F, G>) -> Self::Output
[src]
impl<const D: usize, const E: usize, const F: usize, const G: usize> Div<Unsigned<F, G>> for Unsigned<D, E>
[src]
type Output = Unsigned<D, E>
The resulting type after applying the /
operator.
fn div(self, modulus: Unsigned<F, G>) -> Self::Output
[src]
impl<const D: usize, const E: usize> Eq for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> From<[u64; D]> for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> From<Convenient<D, E>> for Unsigned<D, E>
[src]
fn from(convenient: Convenient<D, E>) -> Self
[src]
impl<const D: usize, const E: usize> From<Modular<'_, D, E>> for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> From<Odd<D, E>> for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> From<u64> for Unsigned<D, E>
[src]
Fails for D + E = 0, bound not expressable.
impl<const D: usize, const E: usize> Mul<&'_ Unsigned<D, E>> for &Unsigned<D, E>
[src]
type Output = Product<D, E>
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self::Output
[src]
not product-scanning implementation of multiplication, that overflowed
impl<const D: usize, const E: usize> Number for Unsigned<D, E>
[src]
const BITS: usize
[src]
const DIGITS: usize
[src]
fn significant_digits(&self) -> &[Digit]
[src]
fn leading_digit(&self) -> Option<Digit>
[src]
fn to_unsigned<const D: usize, const E: usize>(&self) -> Result<Unsigned<D, E>>
[src]
fn zero() -> Self
[src]
fn is_zero(&self) -> bool
[src]
fn is_one(&self) -> bool
[src]
fn is_digit(&self) -> bool
[src]
fn is_odd(&self) -> bool
[src]
fn cmp(&self, other: &impl Number) -> Ordering
[src]
fn eq(&self, other: &impl Number) -> bool
[src]
fn deref(&self) -> &[Digit]
[src]
fn deref_mut(&mut self) -> &mut Self::Target
[src]
impl<const D: usize, const E: usize> NumberMut for Unsigned<D, E>
[src]
fn from_slice(slice: &[Digit]) -> Self
[src]
fn try_from_slice(slice: &[Digit]) -> Result<Self>
[src]
fn from_bytes(bytes: &[u8]) -> Self
[src]
fn set_zero(&mut self)
[src]
fn one() -> Self
[src]
fn swap_order(self) -> Self
[src]
fn random(rng: impl CryptoRng + RngCore) -> Self
[src]
impl<const D: usize, const E: usize> Ord for Unsigned<D, E>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T, const D: usize, const E: usize> PartialEq<T> for Unsigned<D, E> where
T: Number,
[src]
T: Number,
impl<T, const D: usize, const E: usize> PartialOrd<T> for Unsigned<D, E> where
T: Number,
[src]
T: Number,
fn partial_cmp(&self, other: &T) -> Option<Ordering>
[src]
This is little endian ordering, as opposed to the default ordering on arrays and slices!
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Rem<&'a Unsigned<F, G>> for &'a Unsigned<D, E>
[src]
type Output = Unsigned<F, G>
The resulting type after applying the %
operator.
fn rem(self, modulus: &'a Unsigned<F, G>) -> Self::Output
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Rem<&'a Unsigned<F, G>> for Unsigned<D, E>
[src]
type Output = Unsigned<F, G>
The resulting type after applying the %
operator.
fn rem(self, modulus: &'a Unsigned<F, G>) -> Self::Output
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize, const L: usize> Rem<&'a Unsigned<F, G>> for &'a Array<D, E, L>
[src]
type Output = Unsigned<F, G>
The resulting type after applying the %
operator.
fn rem(self, modulus: &'a Unsigned<F, G>) -> Self::Output
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Rem<Unsigned<F, G>> for &'a Unsigned<D, E>
[src]
type Output = Unsigned<F, G>
The resulting type after applying the %
operator.
fn rem(self, modulus: Unsigned<F, G>) -> Self::Output
[src]
impl<'a, const D: usize, const E: usize, const F: usize, const G: usize> Rem<Unsigned<F, G>> for Unsigned<D, E>
[src]
type Output = Unsigned<F, G>
The resulting type after applying the %
operator.
fn rem(self, modulus: Unsigned<F, G>) -> Self::Output
[src]
impl<const D: usize, const E: usize> Shl<usize> for &Unsigned<D, E>
[src]
type Output = Unsigned<D, E>
The resulting type after applying the <<
operator.
fn shl(self, bits: usize) -> Self::Output
[src]
impl<const D: usize, const E: usize> ShlAssign<usize> for Unsigned<D, E>
[src]
fn shl_assign(&mut self, bits: usize)
[src]
impl<const D: usize, const E: usize> ShrAssign<usize> for Unsigned<D, E>
[src]
fn shr_assign(&mut self, bits: usize)
[src]
impl<const D: usize, const E: usize> StructuralEq for Unsigned<D, E>
[src]
impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> Sub<&'b Unsigned<F, G>> for Modular<'a, D, E>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, subtrahend: &'b Unsigned<F, G>) -> Self::Output
[src]
impl<'a, 'b, const D: usize, const E: usize, const F: usize, const G: usize> SubAssign<&'b Unsigned<F, G>> for Modular<'a, D, E>
[src]
fn sub_assign(&mut self, subtrahend: &'b Unsigned<F, G>)
[src]
impl<'a, const D: usize, const E: usize> TryFrom<&'a Unsigned<D, E>> for &'a Odd<D, E>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(unsigned: &'a Unsigned<D, E>) -> Result<Self>
[src]
Enforces odd parity.
impl<const D: usize, const E: usize> TryFrom<Unsigned<D, E>> for Odd<D, E>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(unsigned: Unsigned<D, E>) -> Result<Self>
[src]
Enforces odd parity.
impl<const D: usize, const E: usize> TryFrom<Unsigned<D, E>> for Convenient<D, E>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(unsigned: Unsigned<D, E>) -> Result<Self>
[src]
Enforces odd parity.
impl<const D: usize, const E: usize> Zeroize for Unsigned<D, E>
[src]
Auto Trait Implementations
impl<const D: usize, const E: usize> Send for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> Sync for Unsigned<D, E>
[src]
impl<const D: usize, const E: usize> Unpin for Unsigned<D, E>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Bits for T where
T: Number,
[src]
T: Number,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,