|
|
@@ -1,75 +1,18 @@ |
|
|
|
/** |
|
|
|
* |
|
|
|
* <api.h> |
|
|
|
* |
|
|
|
* @version 2.0 (March 2019) |
|
|
|
* |
|
|
|
* Reference ISO-C11 Implementation of the LEDAcrypt KEM-LT cipher using GCC built-ins. |
|
|
|
* |
|
|
|
* In alphabetical order: |
|
|
|
* |
|
|
|
* @author Marco Baldi <m.baldi@univpm.it> |
|
|
|
* @author Alessandro Barenghi <alessandro.barenghi@polimi.it> |
|
|
|
* @author Franco Chiaraluce <f.chiaraluce@univpm.it> |
|
|
|
* @author Gerardo Pelosi <gerardo.pelosi@polimi.it> |
|
|
|
* @author Paolo Santini <p.santini@pm.univpm.it> |
|
|
|
* |
|
|
|
* This code is hereby placed in the public domain. |
|
|
|
* |
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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. |
|
|
|
* |
|
|
|
**/ |
|
|
|
#ifndef PQCLEAN_LEDAKEMLT12_CLEAN_API_H |
|
|
|
#define PQCLEAN_LEDAKEMLT12_CLEAN_API_H |
|
|
|
|
|
|
|
#pragma once |
|
|
|
#define PQCLEAN_LEDAKEMLT12_CLEAN_CRYPTO_SECRETKEYBYTES 25 |
|
|
|
#define PQCLEAN_LEDAKEMLT12_CLEAN_CRYPTO_PUBLICKEYBYTES 6520 |
|
|
|
#define PQCLEAN_LEDAKEMLT12_CLEAN_CRYPTO_CIPHERTEXTBYTES 6520 |
|
|
|
#define PQCLEAN_LEDAKEMLT12_CLEAN_CRYPTO_BYTES 32 |
|
|
|
|
|
|
|
#include "qc_ldpc_parameters.h" |
|
|
|
#include "gf2x_limbs.h" |
|
|
|
#include "gf2x_arith_mod_xPplusOne.h" |
|
|
|
#define PQCLEAN_LEDAKEMLT12_CLEAN_CRYPTO_ALGNAME "LEDAKEMLT12" |
|
|
|
|
|
|
|
#define CRYPTO_ALGNAME "LEDA" |
|
|
|
int PQCLEAN_LEDAKEMLT12_CLEAN_crypto_kem_keypair(unsigned char *pk, unsigned char *sk); |
|
|
|
|
|
|
|
/* required bytes of input randomness */ |
|
|
|
#define CRYPTO_RANDOMBYTES TRNG_BYTE_LENGTH |
|
|
|
int PQCLEAN_LEDAKEMLT12_CLEAN_crypto_kem_enc(unsigned char *ct, unsigned char *ss, const unsigned char *pk); |
|
|
|
|
|
|
|
/* size in bytes of the secret key */ |
|
|
|
#define CRYPTO_SECRETKEYBYTES TRNG_BYTE_LENGTH+1 |
|
|
|
int PQCLEAN_LEDAKEMLT12_CLEAN_crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned char *sk); |
|
|
|
|
|
|
|
/* size in bytes of the public key */ |
|
|
|
#define CRYPTO_PUBLICKEYBYTES ((N0-1)*NUM_DIGITS_GF2X_ELEMENT*DIGIT_SIZE_B) |
|
|
|
|
|
|
|
/* size in bytes of the shared secret */ |
|
|
|
#define CRYPTO_BYTES HASH_BYTE_LENGTH |
|
|
|
|
|
|
|
/*size in bytes of the ciphertext*/ |
|
|
|
#define CRYPTO_CIPHERTEXTBYTES (NUM_DIGITS_GF2X_ELEMENT*DIGIT_SIZE_B) |
|
|
|
|
|
|
|
/* Your functions must return 0 to indicate success, -1 to indicate an error |
|
|
|
* condition */ |
|
|
|
|
|
|
|
/* Generates a keypair - pk is the public key and sk is the secret key. */ |
|
|
|
int crypto_kem_keypair( unsigned char *pk, |
|
|
|
unsigned char *sk ); |
|
|
|
|
|
|
|
/* Encrypt - pk is the public key, ct is a key encapsulation message |
|
|
|
(ciphertext), ss is the shared secret.*/ |
|
|
|
int crypto_kem_enc( unsigned char *ct, |
|
|
|
unsigned char *ss, |
|
|
|
const unsigned char *pk ); |
|
|
|
|
|
|
|
|
|
|
|
/* Decrypt - ct is a key encapsulation message (ciphertext), sk is the private |
|
|
|
key, ss is the shared secret */ |
|
|
|
|
|
|
|
int crypto_kem_dec( unsigned char *ss, |
|
|
|
const unsigned char *ct, |
|
|
|
const unsigned char *sk ); |
|
|
|
#endif |