-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b3b46a8
Showing
59 changed files
with
5,160 additions
and
0 deletions.
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,12 @@ | ||
cmake-build-debug/ | ||
cmake-build-release/ | ||
.idea/ | ||
*.o | ||
fuzzing/phc-winner-argon2/ | ||
aflbuild/ | ||
fuzzing/phc-winner-argon/ | ||
fuzzing/fuzz | ||
fuzzing/fuzz.txt | ||
ubuntu/ | ||
.DS_Store | ||
build/ |
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 @@ | ||
language: c++ | ||
sudo: false | ||
|
||
install: | ||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" | ||
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} | ||
- | | ||
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then | ||
CMAKE_URL="https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.tar.gz" | ||
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake | ||
export PATH=${DEPS_DIR}/cmake/bin:${PATH} | ||
else | ||
brew upgrade cmake || brew install cmake | ||
fi | ||
script: | ||
- mkdir -p "${TRAVIS_BUILD_DIR}/build" | ||
- cd "${TRAVIS_BUILD_DIR}/build" | ||
- cmake -DCMAKE_BUILD_TYPE=Release "${TRAVIS_BUILD_DIR}" | ||
- make | ||
- ./test/test_cpuid | ||
- ./test/test_ref | ||
- ./test/test_sse2 | ||
- ./test/test_ssse3 | ||
- ./test/test_sse41 | ||
- ./test/test_sde | ||
|
||
matrix: | ||
include: | ||
- os: linux | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-5 | ||
env: | ||
- MATRIX_EVAL="CC=gcc-5 CXX=g++-5" | ||
|
||
- os: linux | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-6 | ||
env: | ||
- MATRIX_EVAL="CC=gcc-6 CXX=g++-6" | ||
|
||
- os: osx | ||
osx_image: xcode8 | ||
env: | ||
- MATRIX_EVAL="" | ||
|
||
before_install: | ||
- eval "${MATRIX_EVAL}" |
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,3 @@ | ||
The following authors have created the source code of "Argonishche" published and distributed by YANDEX LLC as the owner: | ||
|
||
Evgeny Sidorov <[email protected]> |
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,52 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(argon2) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall") | ||
|
||
option(BUILD_TESTS "Build tests." ON) | ||
option(BUILD_BENCHMARK "Build benchmark." ON) | ||
|
||
option(BUILD_WITH_OPENMP "Use OpenMP" ON) | ||
if(BUILD_WITH_OPENMP) | ||
find_package(OpenMP) | ||
if(OPENMP_FOUND) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
else() | ||
message(WARNING | ||
"OpenMP package not found! Argon2 will process sequentially that may result in lower performance if threads > 1 are used!") | ||
endif() | ||
endif() | ||
|
||
include_directories(.) | ||
|
||
set(SOURCE_FILES_LIB | ||
internal/proxies/ref/proxy_ref.cpp | ||
internal/proxies/sse2/proxy_sse2.cpp | ||
internal/proxies/ssse3/proxy_ssse3.cpp | ||
internal/proxies/sse41/proxy_sse41.cpp | ||
internal/proxies/avx2/proxy_avx2.cpp | ||
cpuid/cpuid.cpp | ||
factory/factory.cpp | ||
factory/utils.cpp | ||
) | ||
|
||
set_source_files_properties(internal/proxies/ref/proxy_ref.cpp PROPERTIES COMPILE_FLAGS "-m64") | ||
set_source_files_properties(internal/proxies/sse2/proxy_sse2.cpp PROPERTIES COMPILE_FLAGS "-msse2") | ||
set_source_files_properties(internal/proxies/ssse3/proxy_ssse3.cpp PROPERTIES COMPILE_FLAGS "-mssse3") | ||
set_source_files_properties(internal/proxies/sse41/proxy_sse41.cpp PROPERTIES COMPILE_FLAGS "-msse4.1") | ||
set_source_files_properties(internal/proxies/avx2/proxy_avx2.cpp PROPERTIES COMPILE_FLAGS "-mavx2 -mbmi2") | ||
|
||
add_library(argonishche STATIC ${SOURCE_FILES_LIB}) | ||
add_library(argonishche_sh SHARED ${SOURCE_FILES_LIB}) | ||
set_target_properties(argonishche_sh PROPERTIES OUTPUT_NAME argonishche) | ||
|
||
if(BUILD_TESTS) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
if(BUILD_BENCHMARK) | ||
add_subdirectory(benchmark) | ||
endif() |
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,35 @@ | ||
# Notice to external contributors | ||
|
||
|
||
## General info | ||
|
||
Hello! In order for us (YANDEX LLC) to accept patches and other contributions from you, you will have to adopt our Yandex Contributor License Agreement (the “**CLA**”). The current version of the CLA you may find here: | ||
1) https://yandex.ru/legal/cla/?lang=en (in English) and | ||
2) https://yandex.ru/legal/cla/?lang=ru (in Russian). | ||
|
||
By adopting the CLA, you state the following: | ||
|
||
* You obviously wish and are willingly licensing your contributions to us for our open source projects under the terms of the CLA, | ||
* You has read the terms and conditions of the CLA and agree with them in full, | ||
* You are legally able to provide and license your contributions as stated, | ||
* We may use your contributions for our open source projects and for any other our project too, | ||
* We rely on your assurances concerning the rights of third parties in relation to your contributes. | ||
|
||
If you agree with these principles, please read and adopt our CLA. By providing us your contributions, you hereby declare that you has already read and adopt our CLA, and we may freely merge your contributions with our corresponding open source project and use it in further in accordance with terms and conditions of the CLA. | ||
|
||
## Provide contributions | ||
|
||
If you have already adopted terms and conditions of the CLA, you are able to provide your contributes. When you submit your pull request, please add the following information into it: | ||
|
||
``` | ||
I hereby agree to the terms of the CLA available at: [link]. | ||
``` | ||
|
||
Replace the bracketed text as follows: | ||
* [link] is the link at the current version of the CLA (you may add here a link https://yandex.ru/legal/cla/?lang=en (in English) or a link https://yandex.ru/legal/cla/?lang=ru (in Russian). | ||
|
||
It is enough to provide us such notification at once. | ||
|
||
## Other questions | ||
|
||
If you have any questions, please mail us at [email protected]. |
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,22 @@ | ||
Copyright (c) 2017, YANDEX LLC | ||
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. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 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,101 @@ | ||
Argonishche | ||
=========== | ||
|
||
[![Build Status](https://travis-ci.org/luc-lynx/argon2.svg?branch=master)](https://travis-ci.org/luc-lynx/argon2) | ||
|
||
# Overview | ||
|
||
The library comprises an implementation of Argon2 (i, d, id) and Blake2B algorithms that features the following: | ||
* C++14 interface | ||
* constexpr and partial templates to get rid of useless branches | ||
* SSE2, SSSE3, SSE4.1, AVX2 optimized implementations of Argon2 and Blake2B | ||
* Runtime CPU dispatching (a partiular implementation is chosen runtime depending on SIMD extentions available in the CPU) | ||
* OpenMP for multithreading in contrast to pthread in the [Argon2 reference implementation](github.com/P-H-C/phc-winner-argon2) | ||
* In contrast to the [Argon2 reference implementation](github.com/P-H-C/phc-winner-argon2) the library uses SIMD-optimized Blake2B | ||
|
||
# How to use | ||
|
||
``` | ||
#include <argonishche.h> | ||
uint32_t tcost = 1; /* one pass */ | ||
uint32_t mcost = 32; /* in KB */ | ||
uint32_t threads = 1; /* one thread version */ | ||
bool runTest = false; /* by default factory runs a quick runtime test; pass 'false' to disable it */ | ||
argonishche::Argon2Factory afactory(runTest); | ||
std::unique_ptr<argonishche::Argon2Base> argon2 = afactory.Create(argonishche::Argon2Type::Argon2_d, tcost, mcost, threads, key, keylen); | ||
argon2->Hash(input, insize, salt, saltsize, out, outlen); | ||
bool result = argon2->Verify(pwd, pwdlen, salt, saltlen, hash, hashlen, aad, addlen); | ||
argonishche::Blake2BFactory bfactory(runTest); | ||
uint32_t outlen = 32; | ||
std::unique_ptr<argonishche::Blake2Base> blake2b = bfactory.Create(outlen, key, keylen); | ||
blake2b->Update(in, inlen); | ||
blake2b->Final(out, outlen); | ||
``` | ||
|
||
There are also `HashWithCustomMemory` and `VerifyWithCustomMemory` methods to which you can pass a memory area to use it for computations and to save a little on memory allocation. `GetMemorySize` method returns the size of memory area that required for a particular instance. | ||
|
||
# Benchmark results | ||
|
||
On my OS X 10.11, MacBook Pro (Early 2015, Core i5 2,7 GHz, 16 GB 1867 MHz DDR3) for `(Argon2_d, 1, 2048, 1)` it gives: | ||
|
||
| Implementation | Speed per one core (H/s) | | ||
|------------------------------|--------------------------| | ||
| REF (x64 w/o optimizations) | 458.51 | | ||
| SSE2 | 665.17 | | ||
| SSSE3 | 743.86 | | ||
| SSE4.1 | 723.41 | | ||
| AVX2 | 1120.14 | | ||
|
||
On Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz for `(Argon2_d, 1, 2048, 1)` it gives: | ||
|
||
| Implementation | Speed per one core (H/s) | | ||
|------------------------------|--------------------------| | ||
| REF (x64 w/o optimizations) | 423.9 | | ||
| SSE2 | 663.42 | | ||
| SSSE3 | 715.33 | | ||
| SSE4.1 | 720.12 | | ||
| AVX2 | 1130.36 | | ||
|
||
# How to add your own Argon2 configuration | ||
|
||
The library uses constexpr to calculate some values at compile time. mcost value is a template variable, so the library doesn't support arbitrary mcost values except for predefined ones (in practise you usually don't need it). | ||
|
||
To add a new mcost value just modify the file `internal/proxy/proxy_macros.h` and add appropriate `ARGON2_INSTANCE_DECL` declaration. | ||
|
||
# cmake options | ||
|
||
You can use the following cmake options: | ||
|
||
| Option |Default value | Description | | ||
|---------------------|--------------|----------------------------------------------| | ||
| BUILD_WITH_OPENMP | ON | Use OpenMP if it's available | | ||
| BUILD_TESTS | ON | Build library tests | | ||
| BUILD_BENCHMARK | ON | Build openssl speed like benchmarking tool | | ||
|
||
# Testing with Intel SDE | ||
|
||
One of the tests is intended to run under Intel SDE emulator. Make sure you have SDE in your PATH and run `test_sde.sh <build_folder>/test/test_sde`. | ||
|
||
# Other documentation | ||
|
||
`argonishche.h` contains some Doxygen comments so Doxygen can be used to generate documentation. | ||
|
||
# About the name | ||
|
||
Just "Argon" and Russian suffix "-ищ" (-ishch). In Russian suffix "-ищ" (-ishch) means something that is bigger than ordinary and that scares small children. In this case - something that is bigger than Argon :) | ||
|
||
# Acknowledgements | ||
|
||
This project uses some ideas and pieces of code from the following projects licensed under CC0: | ||
* https://github.com/P-H-C/phc-winner-argon2 | ||
* https://github.com/BLAKE2/BLAKE2 | ||
|
||
And it wouldn't be possible to make the library without work of the following people: | ||
* Alex Biryukov, Daniel Dinu, Dmitry Khovratovich who designed Argon2 algorithm | ||
* Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn, Christian Winnerlein who designed Blake2 algorithm | ||
|
||
I'm also thankful to Igor Klevanets for his fruitful feedback and code reviews. | ||
|
Oops, something went wrong.