Skip to content

Commit fe5d1e3

Browse files
authored
sha-crypt v0.3.0 (RustCrypto#225)
1 parent 2c11f48 commit fe5d1e3

File tree

7 files changed

+31
-4
lines changed

7 files changed

+31
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sha-crypt/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.3.0 (2021-08-27)
9+
### Changed
10+
- Use `resolver = "2"`; MSRV 1.51+ ([#220])
11+
12+
[#220]: https://github.com/RustCrypto/password-hashes/pull/220
13+
814
## 0.2.1 (2021-07-20)
915
### Changed
1016
- Pin `subtle` dependency to v2.4 ([#190])

sha-crypt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sha-crypt"
3-
version = "0.2.1" # Also update html_root_url in lib.rs when bumping this
3+
version = "0.3.0" # Also update html_root_url in lib.rs when bumping this
44
description = """
55
Pure Rust implementation of the SHA-crypt password hash based on SHA-512
66
as implemented by the POSIX crypt C library

sha-crypt/src/defs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
/// Block size
12
pub const BLOCK_SIZE: usize = 64;
3+
4+
/// Maximum length of a salt
25
#[cfg(feature = "simple")]
36
pub const SALT_MAX_LEN: usize = 16;
7+
8+
/// Encoding table.
49
pub static TAB: &[u8] = b"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
10+
11+
/// Inverse encoding map.
512
pub const MAP: [(u8, u8, u8, u8); 22] = [
613
(42, 21, 0, 4),
714
(1, 43, 22, 4),

sha-crypt/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ use alloc::string::String;
88
#[cfg(feature = "std")]
99
use std::io;
1010

11+
/// Error type.
1112
#[derive(Debug)]
1213
pub enum CryptError {
1314
/// Should be within range defs::ROUNDS_MIN < defs::ROUNDS_MIN
1415
RoundsError,
16+
17+
/// RNG failed.
1518
RandomError,
19+
20+
/// I/O error.
1621
#[cfg(feature = "std")]
1722
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
1823
IoError(io::Error),
24+
25+
/// UTF-8 error.
1926
StringError(string::FromUtf8Error),
2027
}
2128

sha-crypt/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
#![doc(
3434
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg",
3535
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg",
36-
html_root_url = "https://docs.rs/sha-crypt/0.2.1"
36+
html_root_url = "https://docs.rs/sha-crypt/0.3.0"
3737
)]
3838
#![deny(unsafe_code)]
39-
#![warn(rust_2018_idioms)] // TODO(tarcieri): add `missing_docs`
39+
#![warn(missing_docs, rust_2018_idioms)]
4040

4141
// TODO(tarcieri): heapless support
4242
#[macro_use]

sha-crypt/src/params.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
use crate::errors;
44
use core::default::Default;
55

6+
/// Default number of rounds.
67
pub const ROUNDS_DEFAULT: usize = 5_000;
8+
9+
/// Minimum number of rounds allowed.
710
pub const ROUNDS_MIN: usize = 1_000;
11+
12+
/// Maximum number of rounds allowed.
813
pub const ROUNDS_MAX: usize = 999_999_999;
914

15+
/// Algorithm parameters.
1016
#[derive(Debug, Clone)]
1117
pub struct Sha512Params {
1218
pub(crate) rounds: usize,
@@ -21,6 +27,7 @@ impl Default for Sha512Params {
2127
}
2228

2329
impl Sha512Params {
30+
/// Create new algorithm parameters.
2431
pub fn new(rounds: usize) -> Result<Sha512Params, errors::CryptError> {
2532
if (ROUNDS_MIN..=ROUNDS_MAX).contains(&rounds) {
2633
Ok(Sha512Params { rounds })

0 commit comments

Comments
 (0)