Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will Base64ShaCrypt ever be supported ? #466

Closed
SteelAlloy opened this issue Sep 30, 2023 · 1 comment
Closed

Will Base64ShaCrypt ever be supported ? #466

SteelAlloy opened this issue Sep 30, 2023 · 1 comment

Comments

@SteelAlloy
Copy link

Hi there,

After debugging my code for a few hours, I discovered that SHA and bcrypt encoding are quite close but not similar.
RustCrypto/traits#507 confirmed what I thought.

Currently the only supported encoding are :

pub enum Encoding {
    /// "B64" encoding: standard Base64 without padding.
    ///
    /// ```text
    /// [A-Z]      [a-z]      [0-9]      +     /
    /// 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f
    /// ```
    /// <https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md#b64>
    B64,

    /// bcrypt encoding.
    ///
    /// ```text
    /// ./         [A-Z]      [a-z]     [0-9]
    /// 0x2e-0x2f, 0x41-0x5a, 0x61-0x7a, 0x30-0x39
    /// ```
    Bcrypt,

    /// `crypt(3)` encoding.
    ///
    /// ```text
    /// [.-9]      [A-Z]      [a-z]
    /// 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
    /// ```
    Crypt,
}

But from what I saw in the source code it wouldn't be hard to add the Base64ShaCrypt variant :

    pub fn decode(self, src: impl AsRef<[u8]>, dst: &mut [u8]) -> Result<&[u8], B64Error> {
        match self {
            Self::B64 => B64::decode(src, dst),
            Self::Bcrypt => Base64Bcrypt::decode(src, dst),
            Self::Crypt => Base64Crypt::decode(src, dst),
            // <-- here
        }
    }

Is there a reason why Base64ShaCrypt isn't there, or is it just a matter of someone doing a PR?

@SteelAlloy
Copy link
Author

SteelAlloy commented Oct 1, 2023

I've just noticed that base64ct is in version 1.1.1 on this repository (the latest being 1.6.0).

Will work on a PR (RustCrypto/traits#1352)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant