RustCrypto: B64 encoding

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Pure Rust implementation of [B64], a subset of the standard Base64 encoding ([RFC 4648]) used by the [PHC string format].

Implemented without data-dependent branches or look up tables, thereby providing "best effort" constant-time operation.

Supports no_std environments and avoids heap allocations in the core API (but also provides optional alloc support for convenience).

Documentation

About B64

The following description of [B64] is quoted from the [PHC string format] spec:

The B64 encoding is the standard Base64 encoding (RFC 4648, section 4) except that the padding = signs are omitted, and extra characters (whitespace) are not allowed:

A B64-encoded value thus yields a string whose length, taken modulo 4, can be equal to 0, 2 or 3, but not to 1. Take note that a sequence of characters of the right length may still be an invalid encoding if it defines some non-zero trailing bits in the last incomplete group; producers MUST set the trailing bits to 0, while consumers MAY ignore them, or MAY reject such invalid encodings.

License

Licensed under either of:

at your option.

Contribution

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.