Skip to content

Commit

Permalink
fix msrv
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Jul 12, 2024
1 parent 97ef4bd commit ca8066d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/yescrypt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ jobs:
include:
# 32-bit Linux
- target: i686-unknown-linux-gnu
rust: 1.71.0 # MSRV
rust: 1.72.0 # MSRV
deps: sudo apt update && sudo apt install gcc-multilib
- target: i686-unknown-linux-gnu
rust: stable
deps: sudo apt update && sudo apt install gcc-multilib

# 64-bit Linux
- target: x86_64-unknown-linux-gnu
rust: 1.71.0 # MSRV
rust: 1.72.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable
steps:
Expand Down
2 changes: 1 addition & 1 deletion yescrypt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["crypto", "hashing", "password", "phf"]
categories = ["authentication", "cryptography", "no-std"]
readme = "README.md"
edition = "2021"
rust-version = "1.60"
rust-version = "1.72"

[dependencies]
libc = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion yescrypt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pure Rust implementation of the [yescrypt] password hashing function.

## Minimum Supported Rust Version

Rust **1.71** or higher.
Rust **1.72** or higher.

Minimum supported Rust version can be changed in the future, but it will be
done with a minor version bump.
Expand Down
2 changes: 1 addition & 1 deletion yescrypt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub unsafe fn yescrypt_r(
.wrapping_div(6),
)
.wrapping_add(1);
if !(need > buflen as usize || need < saltstrlen) {
if !(need > buflen || need < saltstrlen) {
if !(yescrypt_kdf(
shared,
local,
Expand Down
2 changes: 1 addition & 1 deletion yescrypt/src/salsa20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use salsa20::cipher::Unsigned;

use crate::{
common::{blkcpy, blkxor},
size_t, uint32_t,
uint32_t,
};

pub(crate) unsafe fn salsa20_2(mut B: *mut uint32_t) {
Expand Down
18 changes: 6 additions & 12 deletions yescrypt/src/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ pub unsafe fn SHA256_Buf(mut in_0: *const libc::c_void, mut len: size_t, mut dig
use sha2::digest::array::Array;
use sha2::Digest;
let mut ctx = sha2::Sha256::new();
ctx.update(&*core::ptr::slice_from_raw_parts(
in_0 as *const u8,
len as usize,
));
ctx.update(&*core::ptr::slice_from_raw_parts(in_0 as *const u8, len));
ctx.finalize_into(Array::from_mut_slice(
&mut *core::ptr::slice_from_raw_parts_mut(digest, 32),
));
Expand All @@ -34,17 +31,14 @@ pub unsafe fn HMAC_SHA256_Buf(
use hmac::KeyInit;
use hmac::Mac;

let key = &*core::ptr::slice_from_raw_parts(K as *const uint8_t, Klen as usize);
let key = &*core::ptr::slice_from_raw_parts(K as *const uint8_t, Klen);

let mut hmac = hmac::Hmac::<sha2::Sha256>::new_from_slice(key)
.expect("key length should always be valid with hmac");

let mut in_0 = in_0;
let mut len = len;
hmac.update(&*core::ptr::slice_from_raw_parts(
in_0 as *const u8,
len as usize,
));
hmac.update(&*core::ptr::slice_from_raw_parts(in_0 as *const u8, len));

let mac = hmac.finalize().into_bytes();
memcpy(digest as *mut _, mac.as_ptr() as *const _, 32);
Expand All @@ -59,9 +53,9 @@ pub unsafe fn PBKDF2_SHA256(
mut buf: *mut uint8_t,
mut dkLen: size_t,
) {
let passwd = core::ptr::slice_from_raw_parts(passwd, passwdlen as usize);
let salt = core::ptr::slice_from_raw_parts(salt, saltlen as usize);
let res = core::ptr::slice_from_raw_parts_mut(buf, dkLen as usize);
let passwd = core::ptr::slice_from_raw_parts(passwd, passwdlen);
let salt = core::ptr::slice_from_raw_parts(salt, saltlen);
let res = core::ptr::slice_from_raw_parts_mut(buf, dkLen);

pbkdf2::pbkdf2_hmac::<sha2::Sha256>(&*passwd, &*salt, c as u32, &mut *res);
}

0 comments on commit ca8066d

Please sign in to comment.