mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 23:48:58 +00:00
remove pre-processor conditionals
This commit is contained in:
parent
510a7baee8
commit
15a9e77b4c
@ -1,8 +1 @@
|
||||
`Software implementation of Rainbow for NIST R2 submission' by Ming-Shing Chen
|
||||
|
||||
To the extent possible under law, the person who associated CC0 with
|
||||
`Software implementation of Rainbow for NIST R2 submission' has waived all copyright and related or neighboring rights
|
||||
to `Software implementation of Rainbow for NIST R2 submission'.
|
||||
|
||||
You should have received a copy of the CC0 legalcode along with this
|
||||
work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
TODO
|
||||
|
@ -202,13 +202,7 @@ void PQCLEAN_SABER_CLEAN_indcpa_kem_enc(const unsigned char *message_received, u
|
||||
}
|
||||
|
||||
|
||||
#if Saber_type == 1
|
||||
PQCLEAN_SABER_CLEAN_pack_3bit(msk_c, vprime);
|
||||
#elif Saber_type == 2
|
||||
PQCLEAN_SABER_CLEAN_pack_4bit(msk_c, vprime);
|
||||
#elif Saber_type == 3
|
||||
PQCLEAN_SABER_CLEAN_pack_6bit(msk_c, vprime);
|
||||
#endif
|
||||
|
||||
|
||||
for (j = 0; j < SABER_SCALEBYTES_KEM; j++) {
|
||||
@ -258,13 +252,7 @@ void PQCLEAN_SABER_CLEAN_indcpa_kem_dec(const unsigned char *sk, const unsigned
|
||||
scale_ar[i] = ciphertext[SABER_POLYVECCOMPRESSEDBYTES + i];
|
||||
}
|
||||
|
||||
#if Saber_type == 1
|
||||
PQCLEAN_SABER_CLEAN_un_pack3bit(scale_ar, op);
|
||||
#elif Saber_type == 2
|
||||
PQCLEAN_SABER_CLEAN_un_pack4bit(scale_ar, op);
|
||||
#elif Saber_type == 3
|
||||
PQCLEAN_SABER_CLEAN_un_pack6bit(scale_ar, op);
|
||||
#endif
|
||||
|
||||
|
||||
//addition of h1
|
||||
|
@ -1,23 +1,12 @@
|
||||
#include "api.h"
|
||||
|
||||
#ifndef PARAMS_H
|
||||
#define PARAMS_H
|
||||
|
||||
#if Saber_type == 1
|
||||
#define SABER_K 2
|
||||
#define SABER_MU 10
|
||||
#define SABER_ET 3
|
||||
#include "api.h"
|
||||
|
||||
#elif Saber_type == 2
|
||||
#define SABER_K 3
|
||||
#define SABER_MU 8
|
||||
#define SABER_ET 4
|
||||
|
||||
#elif Saber_type == 3
|
||||
#define SABER_K 4
|
||||
#define SABER_MU 6
|
||||
#define SABER_ET 6
|
||||
#endif
|
||||
|
||||
#define SABER_EQ 13
|
||||
#define SABER_EP 10
|
||||
|
@ -7,8 +7,6 @@
|
||||
#define PQCLEAN_SABER_CLEAN_CRYPTO_BYTES 32
|
||||
#define PQCLEAN_SABER_CLEAN_CRYPTO_CIPHERTEXTBYTES 1088
|
||||
|
||||
#define Saber_type 2
|
||||
|
||||
int PQCLEAN_SABER_CLEAN_crypto_kem_keypair(unsigned char *pk, unsigned char *sk);
|
||||
int PQCLEAN_SABER_CLEAN_crypto_kem_enc(unsigned char *ct, unsigned char *ss, const unsigned char *pk);
|
||||
int PQCLEAN_SABER_CLEAN_crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned char *sk);
|
||||
|
@ -24,33 +24,6 @@ static uint64_t load_littleendian(const unsigned char *x, int bytes) {
|
||||
void PQCLEAN_SABER_CLEAN_cbd(uint16_t *r, const unsigned char *buf) {
|
||||
uint16_t Qmod_minus1 = SABER_Q - 1;
|
||||
|
||||
#if Saber_type == 3
|
||||
uint32_t t, d, a[4], b[4];
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < SABER_N / 4; i++) {
|
||||
t = load_littleendian(buf + 3 * i, 3);
|
||||
d = 0;
|
||||
for (j = 0; j < 3; j++) {
|
||||
d += (t >> j) & 0x249249;
|
||||
}
|
||||
|
||||
a[0] = d & 0x7;
|
||||
b[0] = (d >> 3) & 0x7;
|
||||
a[1] = (d >> 6) & 0x7;
|
||||
b[1] = (d >> 9) & 0x7;
|
||||
a[2] = (d >> 12) & 0x7;
|
||||
b[2] = (d >> 15) & 0x7;
|
||||
a[3] = (d >> 18) & 0x7;
|
||||
b[3] = (d >> 21);
|
||||
|
||||
r[4 * i + 0] = (uint16_t)(a[0] - b[0]) & Qmod_minus1;
|
||||
r[4 * i + 1] = (uint16_t)(a[1] - b[1]) & Qmod_minus1;
|
||||
r[4 * i + 2] = (uint16_t)(a[2] - b[2]) & Qmod_minus1;
|
||||
r[4 * i + 3] = (uint16_t)(a[3] - b[3]) & Qmod_minus1;
|
||||
|
||||
}
|
||||
#elif Saber_type == 2
|
||||
uint32_t t, d, a[4], b[4];
|
||||
int i, j;
|
||||
|
||||
@ -75,32 +48,4 @@ void PQCLEAN_SABER_CLEAN_cbd(uint16_t *r, const unsigned char *buf) {
|
||||
r[4 * i + 2] = (uint16_t)(a[2] - b[2]) & Qmod_minus1;
|
||||
r[4 * i + 3] = (uint16_t)(a[3] - b[3]) & Qmod_minus1;
|
||||
}
|
||||
#elif Saber_type == 1
|
||||
uint64_t t, d, a[4], b[4];
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < SABER_N / 4; i++) {
|
||||
t = load_littleendian(buf + 5 * i, 5);
|
||||
d = 0;
|
||||
for (j = 0; j < 5; j++) {
|
||||
d += (t >> j) & 0x0842108421UL;
|
||||
}
|
||||
|
||||
a[0] = d & 0x1f;
|
||||
b[0] = (d >> 5) & 0x1f;
|
||||
a[1] = (d >> 10) & 0x1f;
|
||||
b[1] = (d >> 15) & 0x1f;
|
||||
a[2] = (d >> 20) & 0x1f;
|
||||
b[2] = (d >> 25) & 0x1f;
|
||||
a[3] = (d >> 30) & 0x1f;
|
||||
b[3] = (d >> 35);
|
||||
|
||||
r[4 * i + 0] = (uint16_t)(a[0] - b[0]) & Qmod_minus1;
|
||||
r[4 * i + 1] = (uint16_t)(a[1] - b[1]) & Qmod_minus1;
|
||||
r[4 * i + 2] = (uint16_t)(a[2] - b[2]) & Qmod_minus1;
|
||||
r[4 * i + 3] = (uint16_t)(a[3] - b[3]) & Qmod_minus1;
|
||||
}
|
||||
#else
|
||||
#error "Unsupported SABER parameter."
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user