#constant-time #base64 #security #hex #bech32 #bech32-constant-time

no-std subtle-encoding

Encoders and decoders for common data encodings (base64, bech32, hex) which avoid data-dependent branching/table lookups and therefore provide "best effort" constant time. Useful for encoding/decoding secret values such as cryptographic keys.

12 releases

0.5.1 Feb 8, 2020
0.5.0 Oct 14, 2019
0.4.1 Oct 7, 2019
0.3.7 Jun 5, 2019
0.3.0 Nov 25, 2018

#546 in Cryptography

Download history 20277/week @ 2024-12-14 8650/week @ 2024-12-21 12306/week @ 2024-12-28 23857/week @ 2025-01-04 25354/week @ 2025-01-11 22890/week @ 2025-01-18 28739/week @ 2025-01-25 25735/week @ 2025-02-01 30429/week @ 2025-02-08 23957/week @ 2025-02-15 23956/week @ 2025-02-22 25779/week @ 2025-03-01 30595/week @ 2025-03-08 26000/week @ 2025-03-15 22688/week @ 2025-03-22 17525/week @ 2025-03-29

100,476 downloads per month
Used in 497 crates (66 directly)

Apache-2.0 OR MIT

51KB
1K SLoC

subtle-encoding iqlusion

Crate Docs Apache 2.0/MIT Licensed MSRV Safety Dance Build Status Gitter Chat

Rust crate for encoding/decoding binary data to/from base64 and hex encodings while avoiding data-dependent branching/table lookups, and therefore providing "best effort" constant-time operation.

Also includes a non-constant-time Bech32 encoder/decoder gated under the bech32-preview Cargo feature (with a goal of eventually making it constant-time).

Useful for encoding/decoding secret values such as cryptographic keys.

Documentation

Minimum Supported Rust Version

  • Rust 1.39

Security Notice

While this crate takes care to avoid data-dependent branching, that does not actually make it "constant time", which is an architecture-dependent property.

This crate is a "best effort" attempt at providing a constant time encoding library, however it presently provides no guarantees, nor has it been independently audited for security vulnerabilities.

Use at your own risk.

License

Copyright © 2018-2020 iqlusion

subtle-encoding is distributed under the terms of either the MIT license or the Apache License (Version 2.0), at your option.

See LICENSE (Apache License, Version 2.0) file in the iqlusioninc/crates toplevel directory of this repository or LICENSE-MIT for details.

Dependencies