base32ct/lib.rs
1//! Pure Rust implementation of Base32 ([RFC 4648]).
2//!
3//! Implements Base32 variants without data-dependent branches
4//! or lookup tables, thereby providing portable "best effort" constant-time
5//! operation. Not constant-time with respect to message length (only data).
6//!
7//! Supports `no_std` environments and avoids heap allocations in the core API
8//! (but also provides optional `alloc` support for convenience).
9//!
10//! Adapted from: <https://github.com/paragonie/constant_time_encoding/blob/master/src/Base32.php>
11//!
12//! [RFC 4648]: https://tools.ietf.org/html/rfc4648
13
14// Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
15// Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com).
16//
17// Permission is hereby granted, free of charge, to any person obtaining a copy
18// of this software and associated documentation files (the "Software"), to deal
19// in the Software without restriction, including without limitation the rights
20// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21// copies of the Software, and to permit persons to whom the Software is
22// furnished to do so, subject to the following conditions:
23//
24// The above copyright notice and this permission notice shall be included in all
25// copies or substantial portions of the Software.
26//
27// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33// SOFTWARE.
34
35#![no_std]
36#![cfg_attr(docsrs, feature(doc_auto_cfg))]
37#![doc(
38 html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
39 html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
40)]
41#![warn(
42 clippy::mod_module_files,
43 clippy::unwrap_used,
44 missing_docs,
45 rust_2018_idioms,
46 unused_lifetimes,
47 unused_qualifications
48)]
49
50#[cfg(feature = "alloc")]
51#[macro_use]
52extern crate alloc;
53
54mod alphabet;
55mod encoding;
56mod error;
57
58pub use crate::{
59 alphabet::rfc4648::{Base32, Base32Unpadded, Base32Upper, Base32UpperUnpadded},
60 encoding::{Encoding, encoded_len},
61 error::{Error, Result},
62};