Skip to content

Commit

Permalink
Kyber: pull from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jschanck committed Oct 15, 2021
1 parent d659d0d commit 08ef5e0
Show file tree
Hide file tree
Showing 30 changed files with 371 additions and 197 deletions.
2 changes: 1 addition & 1 deletion kyber/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6106678942f2bc2ce6bdfe93f6fc5548adfde24f
faf5c3fe33e0b61c7c8a7888dd862bf5def17ad2
36 changes: 18 additions & 18 deletions kyber/checkout.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
PYTHON=/usr/bin/python3
#!/bin/sh

BASE=`dirname $0`
BASE=`cd ${BASE} && pwd`
BASE=$(dirname "${0}")
BASE=$(cd "${BASE}" && pwd)

VERSION=$(cat ${BASE}/VERSION)
VERSION=$(cat "${BASE}"/VERSION)
V1=upstream
V2=upstream-patched

ARCHIVE=${VERSION}.zip
ARCHIVE="${VERSION}".zip
PATCHES="${BASE}"/patches

PATCHES=${BASE}/patches
SCRIPTS=${BASE}/scripts

cd ${BASE}
cd "${BASE}" || exit

if [ -e "${V1}" ]
then
read -p "${V1} directory already exists. Delete it? " yn
printf "%s directory already exists. Delete it (y/n)? " "${V1}"
read -r yn
if [ "${yn:-n}" != "y" ]
then
exit -1
Expand All @@ -26,27 +25,28 @@ fi

if [ -e "${V2}" ]
then
read -p "${V2} directory already exists. Delete it? " yn
printf "%s directory already exists. Delete it (y/n)? " "${V2}"
read -r yn
if [ "${yn:-n}" != "y" ]
then
exit -1
fi
rm -rf ${V2}
fi

if [ ! -f ${BASE}/${ARCHIVE} ]
if [ ! -f "${BASE}/${ARCHIVE}" ]
then
wget -P ${BASE} https://github.com/pq-crystals/kyber/archive/${VERSION}.zip
wget -P "${BASE}" "https://github.com/pq-crystals/kyber/archive/${VERSION}.zip"
fi
unzip -qq -d ${BASE} ${BASE}/${ARCHIVE}
mv kyber-${VERSION} ${V1}
unzip -qq -d "${BASE}" "${BASE}/${ARCHIVE}"
mv kyber-"${VERSION}" ${V1}
mkdir -p ${V2}

cp -rp ${V1}/* ${V2}

( cd ${V2}
for X in ${PATCHES}/*
( cd ${V2} || exit
for X in "${PATCHES}"/*
do
patch -p1 < ${X}
patch -p1 < "${X}"
done
)
18 changes: 18 additions & 0 deletions kyber/meta/kyber1024-90s_avx2_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 3168
#define CRYPTO_PUBLICKEYBYTES 1568
#define CRYPTO_CIPHERTEXTBYTES 1568
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber1024-90s"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber1024-90s_clean_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 3168
#define CRYPTO_PUBLICKEYBYTES 1568
#define CRYPTO_CIPHERTEXTBYTES 1568
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber1024-90s"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber1024_avx2_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 3168
#define CRYPTO_PUBLICKEYBYTES 1568
#define CRYPTO_CIPHERTEXTBYTES 1568
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber1024"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber1024_clean_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 3168
#define CRYPTO_PUBLICKEYBYTES 1568
#define CRYPTO_CIPHERTEXTBYTES 1568
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber1024"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber512-90s_avx2_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 1632
#define CRYPTO_PUBLICKEYBYTES 800
#define CRYPTO_CIPHERTEXTBYTES 768
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber512-90s"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber512-90s_clean_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 1632
#define CRYPTO_PUBLICKEYBYTES 800
#define CRYPTO_CIPHERTEXTBYTES 768
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber512-90s"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber512_avx2_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 1632
#define CRYPTO_PUBLICKEYBYTES 800
#define CRYPTO_CIPHERTEXTBYTES 768
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber512"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber512_clean_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 1632
#define CRYPTO_PUBLICKEYBYTES 800
#define CRYPTO_CIPHERTEXTBYTES 768
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber512"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber768-90s_avx2_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 2400
#define CRYPTO_PUBLICKEYBYTES 1184
#define CRYPTO_CIPHERTEXTBYTES 1088
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber768-90s"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber768-90s_clean_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 2400
#define CRYPTO_PUBLICKEYBYTES 1184
#define CRYPTO_CIPHERTEXTBYTES 1088
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber768-90s"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber768_avx2_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 2400
#define CRYPTO_PUBLICKEYBYTES 1184
#define CRYPTO_CIPHERTEXTBYTES 1088
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber768"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
18 changes: 18 additions & 0 deletions kyber/meta/kyber768_clean_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef API_H
#define API_H

#include <stdint.h>

#define CRYPTO_SECRETKEYBYTES 2400
#define CRYPTO_PUBLICKEYBYTES 1184
#define CRYPTO_CIPHERTEXTBYTES 1088
#define CRYPTO_BYTES 32
#define CRYPTO_ALGNAME "Kyber768"

int crypto_kem_keypair(uint8_t *pk, uint8_t *sk);

int crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);

int crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);

#endif
Loading

0 comments on commit 08ef5e0

Please sign in to comment.