Skip to content

Commit

Permalink
Squashed 'vendor/liboqs/' changes from 7d2d392..d207fa5
Browse files Browse the repository at this point in the history
d207fa5 Add global namespace check to travis. (#29)
32220e7 Clean up test_kex output.
ff907b7 LICENSE and README updates for NewHope.
62f630f Code review of NewHope wrapper.
c6a9fae Comment updates (#25)
14b5f66 Adding prettyprint check to Travis (#27)
181e602 Cleanup global namespace.
fd12d8b Add NewHope.
962eaae Switch to HTTPS domain.

git-subtree-dir: vendor/liboqs
git-subtree-split: d207fa51daee9d7cde4f15b2e6e867fa821f17bd
  • Loading branch information
dstebila committed Oct 18, 2016
1 parent 2671329 commit 4728c3a
Show file tree
Hide file tree
Showing 17 changed files with 1,140 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .travis-global-namespace-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [[ $(nm -g liboqs.a | grep ' T ' | grep -E -v -i ' T [_]?OQS') ]];
then
tput setaf 1;
echo "Code contains the following non-namespaced global symbols; see https://github.com/open-quantum-safe/liboqs/wiki/Coding-conventions for function naming conventions.";
nm -g liboqs.a | grep ' T ' | grep -E -v -i ' T [_]?OQS'
exit 1;
else
tput setaf 2;
echo "Code adheres to the project standards.";
exit 0;
fi;
12 changes: 12 additions & 0 deletions .travis-style-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [[ $(make prettyprint | grep Formatted) ]];
then
tput setaf 1;
echo "Code does not adhere to the project standards. Run \"make prettyprint\".";
exit 1;
else
tput setaf 2;
echo "Code adheres to the project standards.";
exit 0;
fi;
23 changes: 21 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
before_install:
- wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz
- tar xzf astyle_2.05.1_linux.tar.gz
- cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../
- os: linux
compiler: gcc
env: CC_OQS=gcc-4.9
Expand All @@ -21,6 +25,10 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
before_install:
- wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz
- tar xzf astyle_2.05.1_linux.tar.gz
- cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../
- os: linux
compiler: gcc
env: CC_OQS=gcc-5
Expand All @@ -30,6 +38,10 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- gcc-5
before_install:
- wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz
- tar xzf astyle_2.05.1_linux.tar.gz
- cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../
- os: linux
compiler: gcc
env: CC_OQS=gcc-6
Expand All @@ -39,11 +51,18 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- gcc-6
before_install:
- wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz
- tar xzf astyle_2.05.1_linux.tar.gz
- cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../
- os: osx
compiler: clang
env: CC_OQS=clang

before_install:
- brew install astyle

script:
- make
- make check
- make check
- bash .travis-style-check.sh
- bash .travis-global-namespace-check.sh
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ links:
mkdir -p include/oqs
$(LN) ../../src/kex/kex.h include/oqs
$(LN) ../../src/kex_rlwe_bcns15/kex_rlwe_bcns15.h include/oqs
$(LN) ../../src/kex_rlwe_newhope/kex_rlwe_newhope.h include/oqs
$(LN) ../../src/rand/rand.h include/oqs
$(LN) ../../src/rand_urandom_chacha20/rand_urandom_chacha20.h include/oqs

Expand All @@ -48,13 +49,22 @@ KEX_RLWE_BCNS15_HEADERS := $(addprefix src/kex_rlwe_bcns15/, kex_rlwe_bcns15.h l

$(KEX_RLWE_BCNS15_OBJS): $(KEX_RLWE_BCNS15_HEADERS)

# KEX_NEWHOPE

KEX_RLWE_NEWHOPE_OBJS := $(addprefix objs/kex_rlwe_newhope/, kex_rlwe_newhope.o)

KEX_RLWE_NEWHOPE_HEADERS := $(addprefix src/kex_rlwe_newhope/, kex_rlwe_newhope.h fips202.c newhope.c params.h poly.c precomp.c)

$(KEX_RLWE_NEWHOPE_OBJS): $(KEX_RLWE_NEWHOPE_HEADERS)


# KEX

objs/kex/kex.o: src/kex/kex.h

# LIB

lib: $(RAND_URANDOM_CHACHA_OBJS) $(KEX_RLWE_BCNS15_OBJS) objs/rand/rand.o objs/kex/kex.o
lib: $(RAND_URANDOM_CHACHA_OBJS) $(KEX_RLWE_BCNS15_OBJS) $(KEX_RLWE_NEWHOPE_OBJS) objs/rand/rand.o objs/kex/kex.o
rm -f liboqs.a
$(AR) liboqs.a $^
$(RANLIB) liboqs.a
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OQS will also include integrations into application-level protocols to provide e

- **open-quantum-safe/openssl** is an integration of liboqs into OpenSSL 1.0.2. The goal of this integration is to provide easy prototyping of quantum-resistant cryptography. The integration should not be considered "production quality". See more about this integration in its GitHub repository [open-quantum-safe/openssl/](https://github.com/open-quantum-safe/openssl/).

More information on OQS can be found on our website: [http://openquantumsafe.org/](http://openquantumsafe.org/).
More information on OQS can be found on our website: [https://openquantumsafe.org/](https://openquantumsafe.org/).

Contents
--------
Expand All @@ -25,6 +25,7 @@ liboqs currently contains:

- `rand_urandom_chacha20`: pseudorandom number generator seeded from /dev/urandom and expanded using the ChaCha20 stream cipher
- `kex_rlwe_bcns15`: key exchange from the ring learning with errors problem (Bos, Costello, Naehrig, Stebila, *IEEE Symposium on Security & Privacy 2015*, [https://eprint.iacr.org/2014/599](https://eprint.iacr.org/2014/599))
- `kex_rlwe_newhope`: "NewHope": key exchange from the ring learning with errors problem (Alkim, Ducas, Pöppelmann, Schwabe, *USENIX Security 2016*, [https://eprint.iacr.org/2015/1092](https://eprint.iacr.org/2015/1092)) (using the reference C implementation of NewHope from [https://github.com/tpoeppelmann/newhope](https://github.com/tpoeppelmann/newhope))

Building and Running
--------------------
Expand Down Expand Up @@ -87,13 +88,14 @@ Since our initial launch, we have made the following updates:
- Integration of liboqs into OpenSSL to enable testing of post-quantum algorithms in TLS connections ([open-quantum-safe/openssl/](https://github.com/open-quantum-safe/openssl/))
- Licensing liboqs under the MIT license (see below)
- Building on Windows
- Use of travis continuous integration system for testing
- `kex_rlwe_newhope` wrapper around "NewHope" ring-LWE key exchange ([https://eprint.iacr.org/2015/1092](https://eprint.iacr.org/2015/1092))

We plan to be making the following updates over the next month:

- `kex_lwe_frodo` implementation ([https://eprint.iacr.org/2016/659](https://eprint.iacr.org/2016/659))
- `kex_rlwe_bcns15` generalization to multiple security levels
- `kex_ntru_ees743p1` wrapper around NTRU open source public key encryption ([https://github.com/NTRUOpenSourceProject/ntru-crypto](https://github.com/NTRUOpenSourceProject/ntru-crypto))
- `kex_rlwe_newhope` wrapper around "NewHope" ring-LWE key exchange ([https://eprint.iacr.org/2015/1092](https://eprint.iacr.org/2015/1092))
- Benchmarking scripts for key exchange algorithms
- Detailed Doxygen documentation for existing API and public functions
- Modular build system
Expand All @@ -115,6 +117,7 @@ liboqs is licensed under the MIT License; see [https://github.com/open-quantum-s

- `src/kex_rlwe_bcns15`: public domain ([http://unlicense.org](http://unlicense.org))
- `src/rand_urandom_chacha20/external`: public domain
- `src/kex_rlwe_newhope`: public domain

Team
----
Expand Down
4 changes: 4 additions & 0 deletions src/kex/kex.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

#include <oqs/kex.h>
#include <oqs/kex_rlwe_bcns15.h>
#include <oqs/kex_rlwe_newhope.h>

OQS_KEX *OQS_KEX_new(OQS_RAND *rand, enum OQS_KEX_alg_name alg_name, UNUSED const uint8_t *seed, UNUSED const UNUSED size_t seed_len, UNUSED const char *named_parameters) {
switch (alg_name) {
case OQS_KEX_alg_default:
return OQS_KEX_rlwe_bcns15_new(rand);
case OQS_KEX_alg_rlwe_bcns15:
return OQS_KEX_rlwe_bcns15_new(rand);
case OQS_KEX_alg_rlwe_newhope:
return OQS_KEX_rlwe_newhope_new(rand);
default:
assert(0);
}
Expand Down
19 changes: 10 additions & 9 deletions src/kex/kex.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
enum OQS_KEX_alg_name {
OQS_KEX_alg_default,
OQS_KEX_alg_rlwe_bcns15,
OQS_KEX_alg_rlwe_newhope,
};

typedef struct OQS_KEX OQS_KEX;
Expand Down Expand Up @@ -75,20 +76,20 @@ typedef struct OQS_KEX {
*
* @param k Key exchange structure
* @param alice_priv Alice's private key
* @param alice_msg Alice's public key
* @param alice_msg_len Alice's public key length
* @param alice_msg Alice's message (public key + optional additional data)
* @param alice_msg_len Alice's message length
* @return 1 on success, or 0 on failure
*/
int (*alice_0)(OQS_KEX *k, void **alive_priv, uint8_t **alice_msg, size_t *alice_msg_len);

/**
* Pointer to a function for public, private and shared key generation by Bob.
* Pointer to a function for shared key generation by Bob.
*
* @param k Key exchange structure
* @param alice_msg Alice's public key
* @param alice_msg_len Alice's public key length
* @param bob_msg Bob's public key
* @param bob_msg_len Bob's public key length
* @param alice_msg Alice's message (public key + optional additional data)
* @param alice_msg_len Alice's message length
* @param bob_msg Bob's message (public key / encryption of shared key + optional additional data)
* @param bob_msg_len Bob's message length
* @param key Shared key
* @param key_len Shared key length
* @return 1 on success, or 0 on failure
Expand All @@ -100,8 +101,8 @@ typedef struct OQS_KEX {
*
* @param k Key exchange structure
* @param alice_priv Alice's private key
* @param bob_msg Bob's public key
* @param bob_msg_len Bob's public key length
* @param bob_msg Bob's message (public key / encryption of shared key + optional additional data)
* @param bob_msg_len Bob's message length
* @param key Shared key
* @param key_len Shared key length
* @return 1 on success, or 0 on failure
Expand Down
6 changes: 3 additions & 3 deletions src/kex/test_kex.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct kex_testcase {
/* Add new testcases here */
struct kex_testcase kex_testcases[] = {
{ OQS_KEX_alg_rlwe_bcns15, NULL, 0, NULL },
{ OQS_KEX_alg_rlwe_newhope, NULL, 0, NULL },
};

#define KEX_TEST_ITERATIONS 500
Expand Down Expand Up @@ -157,9 +158,8 @@ static int kex_test_correctness_wrapper(OQS_RAND *rand, enum OQS_KEX_alg_name al
}
}
printf("All session keys matched.\n");
printf("Statistical distance from uniform: %12.10f\n",
OQS_RAND_test_statistical_distance_from_uniform(
occurrences));
printf("Statistical distance from uniform: %12.10f\n", OQS_RAND_test_statistical_distance_from_uniform(occurrences));
printf("\n\n");

ret = 1;
goto cleanup;
Expand Down
5 changes: 5 additions & 0 deletions src/kex_rlwe_bcns15/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
The files in this directory (except kex_rlwe_bcns15.*) were originally written
by Joppe W. Bos, Craig Costello, Michael Naehrig, and Douglas Stebila
(https://github.com/dstebila/rlwekex).


The following license applies to all files in the src/kex_rlwe_bcns15 directory.


Expand Down
9 changes: 9 additions & 0 deletions src/kex_rlwe_newhope/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The files in this directory (except kex_rlwe_newhope.*) were originally written
by Erdem Alkim, Léo Ducas, Thomas Pöppelmann, and Peter Schwabe
(https://github.com/tpoeppelmann/newhope).


The following license applies to all files in the src/kex_rlwe_newhope directory.


Public domain.

0 comments on commit 4728c3a

Please sign in to comment.