-
Notifications
You must be signed in to change notification settings - Fork 80
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
yescrypt: initial translation #509
+3,133
−1
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0524a3b
[WIP] yescrypt
tarcieri a7e18fe
Refactor and silence warnings
tarcieri 9958eaa
Make modules non-pub; consolidate type definitions
tarcieri e80f023
yescrypt: eliminate usages of extern "C"
tarcieri 73c9705
Remove libcperciva_ function prefixes
tarcieri f5ad836
Remove #[no_mangle]
tarcieri 8454b07
Factor out `salsa20` and `util` modules
tarcieri 2e6376c
Refactoring
tarcieri 9100187
More idiomatic type names
tarcieri 7fc4f78
Add Known Answer Tests (KATs) from upstream
tarcieri 6b42830
clippy fixes
tarcieri 1e78728
CI config; MSRV 1.60
tarcieri 99863f8
More clippy fixups
tarcieri c70f7a2
static_mut_refs fix
tarcieri ac0dbc6
temp disable 32-bit support
tarcieri e9117f9
yescrypt cleanups (#510)
conradludgate fcee97e
bump deps
tarcieri 6c2c163
clippy
tarcieri 58d7cab
safe public API
tarcieri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
tarcieri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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] | ||
tarcieri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
hex-literal = "0.4" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think BSD-2-Clause is compatible with MIT/Apache-2.0, so we can change the license for our modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While they're "compatible" in that they're allowed to be used in the same program, that doesn't mean we can arbitrarily relicense code under one license under another.
We could potentially consider changing to
MIT OR Apache-2.0
when the code has been extensively rewritten and is no longer an obvious derived work of the original.Or we could attempt to get permission from the original authors to relicense it, which is what I've done (with a surprising amount of success) in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... The copyright notices effectively state the same thing, but with slightly different wording. It would be great to have a "greenfield" implementation based on algorithm specification, but I don't know how hard would it be to do compared to the automatic translation (+ cleanup).
Note that right now you state MIT/Apache-2.0 licensing terms in the crate README.