Skip to content

Commit 23b3622

Browse files
authored
base64ct: deprecate Base64Crypt (#2135)
Closes #2133 `Base64ShaCrypt` is, as far as I can tell, the standard Base64 alphabet used by all `crypt(3)` hashes. The only exception is `bcrypt` which uses a completely different alphabet (`./A-Za-z0-9`). As far as I can tell all algorithms that actually use the `./0-9A-Za-z` alphabet do so with the little endian packing implemented in `Base64ShaCrypt`. I'm uncertain about the provenance of the test vectors for `Base64Crypt` but as far as I can tell it's actually a non-standard packing for this particular alphabet. As such, this deprecates `Base64Crypt`, steering people towards `Base64ShaCrypt` for now. Perhaps in the future we can find better names.
1 parent e2a2a4b commit 23b3622

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

base64ct/src/alphabet/crypt.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
//! `crypt(3)` Base64 encoding.
22
3+
#![allow(deprecated)]
4+
35
use super::{Alphabet, DecodeStep, EncodeStep};
46

5-
/// `crypt(3)` Base64 encoding.
7+
/// DEPRECATED: non-standard big endian variant of the `crypt(3)` Base64 encoding.
68
///
79
/// ```text
810
/// [.-9] [A-Z] [a-z]
911
/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
1012
/// ```
1113
///
12-
/// Note this encodes using a big endian variant of Base64. Most modern algorithms which can be
13-
/// used via `crypt(3)` use the little endian [`Base64ShaCrypt`][`crate::Base64ShaCrypt`] variant.
14+
/// <div class="warning">
15+
/// This encodes using a big endian variant of Base64. Most modern algorithms which can be
16+
/// used via `crypt(3)` use the [`Base64ShaCrypt`][`crate::Base64ShaCrypt`] encoding.
17+
/// </div>
18+
#[deprecated(
19+
since = "1.8.2",
20+
note = "non-standard encoding. Use Base64ShaCrypt for all crypt(3) algorithms"
21+
)]
1422
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1523
pub struct Base64Crypt;
1624

base64ct/src/alphabet/shacrypt.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use super::{Alphabet, DecodeStep, EncodeStep};
44

5-
/// Little endian variant of the `crypt(3)` Base64 encoding.
5+
/// `crypt(3)` Base64 encoding.
66
///
7-
/// Used by the following schemes:
7+
/// This is the standard Base64 encoding used by password hashes for the following schemes:
88
/// - MD5-Crypt
99
/// - scrypt
1010
/// - SHA1-Crypt
@@ -16,9 +16,6 @@ use super::{Alphabet, DecodeStep, EncodeStep};
1616
/// [.-9] [A-Z] [a-z]
1717
/// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
1818
/// ```
19-
///
20-
/// This uses the same alphabet as [`Base64Crypt`][`crate::Base64Crypt`], but uses a little endian
21-
/// variant of Base64.
2219
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2320
pub struct Base64ShaCrypt;
2421

base64ct/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ mod test_vectors;
8989
pub use crate::{
9090
alphabet::{
9191
bcrypt::Base64Bcrypt,
92-
crypt::Base64Crypt,
9392
shacrypt::Base64ShaCrypt,
9493
standard::{Base64, Base64Unpadded},
9594
url::{Base64Url, Base64UrlUnpadded},
@@ -101,5 +100,8 @@ pub use crate::{
101100
line_ending::LineEnding,
102101
};
103102

103+
#[allow(deprecated)]
104+
pub use crate::alphabet::crypt::Base64Crypt;
105+
104106
/// Minimum supported line width.
105107
const MIN_LINE_WIDTH: usize = 4;

base64ct/tests/crypt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! `crypt(3)` Base64 tests
22
3+
#![allow(deprecated)]
4+
35
#[macro_use]
46
mod common;
57

0 commit comments

Comments
 (0)