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

yescrypt: initial translation #509

Merged
merged 19 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

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"]
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
Loading