Skip to content

Commit

Permalink
yescrypt: initial translation (#509)
Browse files Browse the repository at this point in the history
Translation of the reference implementation as implemented in C, as of
this commit:

commit e5873f89015c9c7c4ae56e3a6d17cefd47fef239
Author: Solar Designer <[email protected]>
Date:   Sun Sep 24 16:00:15 2023 +0200

Uses `hmac`, `pbkdf2`, `salsa20`, and `sha2` crates in place of C
translation.

Co-authored-by: Conrad Ludgate <[email protected]>
  • Loading branch information
tarcieri and conradludgate authored Aug 18, 2024
1 parent ae579fb commit 347986e
Show file tree
Hide file tree
Showing 12 changed files with 3,133 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/yescrypt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: yescrypt

on:
pull_request:
paths:
- "yescrypt/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: yescrypt

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
minimal-versions:
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
with:
working-directory: ${{ github.workflow }}

test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# 32-bit Linux
- target: i686-unknown-linux-gnu
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.72.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable
steps:
- uses: actions/checkout@v4
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: ${{ matrix.deps }}
- run: cargo test

# TODO(tarcieri): 32-bit support
# cross:
# strategy:
# matrix:
# include:
# - target: powerpc-unknown-linux-gnu
# rust: 1.60.0 # MSRV
# - target: powerpc-unknown-linux-gnu
# rust: stable
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - run: ${{ matrix.deps }}
# - uses: dtolnay/rust-toolchain@master
# with:
# toolchain: ${{ matrix.rust }}
# targets: ${{ matrix.target }}
# - uses: RustCrypto/actions/cross-install@master
# - run: cross test --release --target ${{ matrix.target }}
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ members = [
"password-auth",
"pbkdf2",
"scrypt",
"sha-crypt"
"sha-crypt",
"yescrypt"
]
exclude = ["benches"]

Expand Down
6 changes: 6 additions & 0 deletions yescrypt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
30 changes: 30 additions & 0 deletions yescrypt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "yescrypt"
version = "0.0.0"
description = """
Pure Rust implementation of the yescrypt password hashing function
"""
authors = ["RustCrypto Developers"]
license = "BSD-2-Clause"
documentation = "https://docs.rs/yescrypt"
homepage = "https://github.com/RustCrypto/password-hashes/tree/master/yescrypt"
repository = "https://github.com/RustCrypto/password-hashes"
keywords = ["crypto", "hashing", "password", "phf"]
categories = ["authentication", "cryptography", "no-std"]
readme = "README.md"
edition = "2021"
rust-version = "1.72"

[dependencies]
libc = "0.2"
hmac = { version = "0.13.0-pre.4", default-features = false }
pbkdf2 = { version = "=0.13.0-pre.1", path = "../pbkdf2" }
salsa20 = { version = "=0.11.0-pre.1", default-features = false }
sha2 = { version = "=0.11.0-pre.4", default-features = false }

#[dev-dependencies]
hex-literal = "0.4"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
28 changes: 28 additions & 0 deletions yescrypt/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright 2009 Colin Percival
Copyright 2013-2018 Alexander Peslyak
Copyright 2024 RustCrypto Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

This file was originally written by Colin Percival as part of the Tarsnap
online backup system.
56 changes: 56 additions & 0 deletions yescrypt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# RustCrypto: yescrypt

[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
[![Build Status][build-image]][build-link]
![Apache2/MIT licensed][license-image]
![Rust Version][rustc-image]
[![Project Chat][chat-image]][chat-link]

Pure Rust implementation of the [yescrypt] password hashing function.

[Documentation][docs-link]

## Minimum Supported Rust Version

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.

## SemVer Policy

- All on-by-default features of this library are covered by SemVer
- MSRV is considered exempt from SemVer as noted above

## License

Licensed under either of:

* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

[//]: # (badges)

[crate-image]: https://buildstats.info/crate/yescrypt
[crate-link]: https://crates.io/crates/yescrypt
[docs-image]: https://docs.rs/yescrypt/badge.svg
[docs-link]: https://docs.rs/yescrypt/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260046-password-hashes
[build-image]: https://github.com/RustCrypto/password-hashes/workflows/yescrypt/badge.svg?branch=master&event=push
[build-link]: https://github.com/RustCrypto/password-hashes/actions?query=workflow%3Ayescrypt

[//]: # (links)

[yescrypt]: https://www.openwall.com/yescrypt/
Loading

0 comments on commit 347986e

Please sign in to comment.