RustCrypto: Cryptographic Big Integers
Pure Rust implementation of a big integer library which has been designed from the ground-up for use in cryptographic applications.
Provides constant-time, no_std-friendly implementations of modern formulas
using const generics.
- Supports
no_std-friendly const generic stack-allocated big integers. - Constant-time by default. Variable-time functions are explicitly marked as such.
- Leverage what is possible today with const generics on
stablerust. - Support
const fnas much as possible with the goal of being able to compute values at compile-time. - Optional heap-allocated
Boxed*types gated under anallocfeature.
This crate is designed to operate in constant-time on the following CPU architectures:
arm(32-bit)aarch64✅riscv32✅riscv64thumbv6✅thumbv7(with checks forthumbv7em✅)x86x86_64✅wasm32
✅: indicates architectures where we use cargo checkct / BINSEC in CI to
ensure that, for functions with checkct assertions, changes do not introduce
variable-time operations.
Other architectures are officially unsupported, however a use-at-your-own-risk
portable fallback implementation based on bitwise arithmetic and black_box is
provided without constant-time codegen guarantees. Please do not open issues
about codegen problems on unsupported CPU architectures: they will be closed
noting they're unsupported. If you would like such problems addressed, please
open a pull request that addresses the issue instead.
Notably this library is NOT suitable for use on processors with a variable-time multiplication operation, e.g. short circuit on multiply-by-zero / multiply-by-one, such as certain 32-bit PowerPC CPUs and microcontrollers.
This crate has been audited by NCC Group with no significant findings. We would like to thank Entropy for funding the audit. Note that the implementation has diverged significantly since the last audit.
All functions contained in the crate are designed to execute in constant
time unless explicitly specified otherwise (via a *_vartime name suffix).
MSRV increases are not considered breaking changes and can happen in patch releases.
The crate MSRV accounts for all supported targets and crate feature combinations, excluding explicitly unstable features.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.