1// Copyright 2017-2023 Brian Smith.
2//
3// Permission to use, copy, modify, and/or distribute this software for any
4// purpose with or without fee is hereby granted, provided that the above
5// copyright notice and this permission notice appear in all copies.
6//
7// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
8// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
10// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15pub(crate) use self::{constant::limbs_from_hex, limb_slice_error::LimbSliceError};
16use crate::{error::LenMismatchError, limb::LIMB_BITS};
17
18#[macro_use]
19mod ffi;
20mod aarch64_mont;
21mod x86_64_mont;
22
23mod constant;
24
25#[cfg(feature = "alloc")]
26pub mod bigint;
27
28pub(crate) mod inout;
29mod limbs512;
30pub mod montgomery;
31
32mod n0;
33
34// The minimum number of limbs allowed for any `&[Limb]` operation.
35//
36// TODO: Use `256 / LIMB_BITS` so that the limit is independent of limb size.
37pub const MIN_LIMBS: usize = 4;
38
39// The maximum number of limbs allowed for any `&[Limb]` operation.
40pub const MAX_LIMBS: usize = 8192 / LIMB_BITS;
41
42cold_exhaustive_error! {
43 enum limb_slice_error::LimbSliceError {
44 len_mismatch => LenMismatch(LenMismatchError),
45 too_short => TooShort(usize),
46 too_long => TooLong(usize),
47 }
48}
49