use size_t for index in aes xof buffer and not for index of digits

This commit is contained in:
Leon 2019-06-11 16:20:31 +02:00
parent e5da5da9a6
commit 98e643e5c7
12 changed files with 35 additions and 35 deletions

View File

@ -20,7 +20,7 @@ static inline void gf2x_add_asymm(const size_t nr, DIGIT Res[],
} }
/* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */ /* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */
void PQCLEAN_LEDAKEMLT12_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsigned int amount) { void PQCLEAN_LEDAKEMLT12_CLEAN_right_bit_shift_n(int length, DIGIT in[], unsigned int amount) {
assert(amount < DIGIT_SIZE_b); assert(amount < DIGIT_SIZE_b);
if ( amount == 0 ) { if ( amount == 0 ) {
return; return;
@ -36,12 +36,12 @@ void PQCLEAN_LEDAKEMLT12_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsi
} }
/* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */ /* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */
void PQCLEAN_LEDAKEMLT12_CLEAN_left_bit_shift_n(size_t length, DIGIT in[], unsigned int amount) { void PQCLEAN_LEDAKEMLT12_CLEAN_left_bit_shift_n(int length, DIGIT in[], unsigned int amount) {
assert(amount < DIGIT_SIZE_b); assert(amount < DIGIT_SIZE_b);
if ( amount == 0 ) { if ( amount == 0 ) {
return; return;
} }
size_t j; int j;
DIGIT mask; DIGIT mask;
mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1); mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1);
for (j = 0 ; j < length - 1 ; j++) { for (j = 0 ; j < length - 1 ; j++) {

View File

@ -50,14 +50,14 @@ typedef uint64_t DIGIT;
#define GF2X_MUL PQCLEAN_LEDAKEMLT12_CLEAN_gf2x_mul_comb #define GF2X_MUL PQCLEAN_LEDAKEMLT12_CLEAN_gf2x_mul_comb
static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], size_t nr) { static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], int nr) {
for (size_t i = 0; i < nr; i++) { for (int i = 0; i < nr; i++) {
Res[i] = A[i] ^ B[i]; Res[i] = A[i] ^ B[i];
} }
} }
void PQCLEAN_LEDAKEMLT12_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsigned int amount); void PQCLEAN_LEDAKEMLT12_CLEAN_right_bit_shift_n(int length, DIGIT in[], unsigned int amount);
void PQCLEAN_LEDAKEMLT12_CLEAN_left_bit_shift_n(size_t length, DIGIT in[], unsigned int amount); void PQCLEAN_LEDAKEMLT12_CLEAN_left_bit_shift_n(int length, DIGIT in[], unsigned int amount);
void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]); void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]);
#endif #endif

View File

@ -15,7 +15,7 @@
static int seedexpander_init(AES_XOF_struct *ctx, static int seedexpander_init(AES_XOF_struct *ctx,
unsigned char *seed, unsigned char *seed,
unsigned char *diversifier, unsigned char *diversifier,
uint64_t maxlen) { size_t maxlen) {
if ( maxlen >= 0x100000000 ) { if ( maxlen >= 0x100000000 ) {
return RNG_BAD_MAXLEN; return RNG_BAD_MAXLEN;
} }

View File

@ -11,8 +11,8 @@
typedef struct { typedef struct {
unsigned char buffer[16]; unsigned char buffer[16];
unsigned int buffer_pos; size_t buffer_pos;
uint64_t length_remaining; size_t length_remaining;
unsigned char key[32]; unsigned char key[32];
unsigned char ctr[16]; unsigned char ctr[16];
} AES_XOF_struct; } AES_XOF_struct;

View File

@ -5,12 +5,12 @@
/* allows the second operand to be shorter than the first */ /* allows the second operand to be shorter than the first */
/* the result should be as large as the first operand*/ /* the result should be as large as the first operand*/
static inline void gf2x_add_asymm(const size_t nr, DIGIT Res[], static inline void gf2x_add_asymm(const int nr, DIGIT Res[],
const size_t na, const DIGIT A[], const int na, const DIGIT A[],
const size_t nb, const DIGIT B[]) { const int nb, const DIGIT B[]) {
assert(nr >= na && na >= nb); assert(nr >= na && na >= nb);
size_t i; int i;
size_t delta = na - nb; int delta = na - nb;
for (i = 0; i < delta; i++) { for (i = 0; i < delta; i++) {
Res[i] = A[i]; Res[i] = A[i];
} }
@ -20,7 +20,7 @@ static inline void gf2x_add_asymm(const size_t nr, DIGIT Res[],
} }
/* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */ /* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */
void PQCLEAN_LEDAKEMLT32_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsigned int amount) { void PQCLEAN_LEDAKEMLT32_CLEAN_right_bit_shift_n(int length, DIGIT in[], unsigned int amount) {
assert(amount < DIGIT_SIZE_b); assert(amount < DIGIT_SIZE_b);
if ( amount == 0 ) { if ( amount == 0 ) {
return; return;
@ -36,12 +36,12 @@ void PQCLEAN_LEDAKEMLT32_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsi
} }
/* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */ /* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */
void PQCLEAN_LEDAKEMLT32_CLEAN_left_bit_shift_n(size_t length, DIGIT in[], unsigned int amount) { void PQCLEAN_LEDAKEMLT32_CLEAN_left_bit_shift_n(int length, DIGIT in[], unsigned int amount) {
assert(amount < DIGIT_SIZE_b); assert(amount < DIGIT_SIZE_b);
if ( amount == 0 ) { if ( amount == 0 ) {
return; return;
} }
size_t j; int j;
DIGIT mask; DIGIT mask;
mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1); mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1);
for (j = 0 ; j < length - 1 ; j++) { for (j = 0 ; j < length - 1 ; j++) {

View File

@ -50,14 +50,14 @@ typedef uint64_t DIGIT;
#define GF2X_MUL PQCLEAN_LEDAKEMLT32_CLEAN_gf2x_mul_comb #define GF2X_MUL PQCLEAN_LEDAKEMLT32_CLEAN_gf2x_mul_comb
static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], size_t nr) { static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], int nr) {
for (size_t i = 0; i < nr; i++) { for (int i = 0; i < nr; i++) {
Res[i] = A[i] ^ B[i]; Res[i] = A[i] ^ B[i];
} }
} }
void PQCLEAN_LEDAKEMLT32_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsigned int amount); void PQCLEAN_LEDAKEMLT32_CLEAN_right_bit_shift_n(int length, DIGIT in[], unsigned int amount);
void PQCLEAN_LEDAKEMLT32_CLEAN_left_bit_shift_n(size_t length, DIGIT in[], unsigned int amount); void PQCLEAN_LEDAKEMLT32_CLEAN_left_bit_shift_n(int length, DIGIT in[], unsigned int amount);
void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]); void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]);
#endif #endif

View File

@ -15,7 +15,7 @@
static int seedexpander_init(AES_XOF_struct *ctx, static int seedexpander_init(AES_XOF_struct *ctx,
unsigned char *seed, unsigned char *seed,
unsigned char *diversifier, unsigned char *diversifier,
uint64_t maxlen) { size_t maxlen) {
if ( maxlen >= 0x100000000 ) { if ( maxlen >= 0x100000000 ) {
return RNG_BAD_MAXLEN; return RNG_BAD_MAXLEN;
} }

View File

@ -11,8 +11,8 @@
typedef struct { typedef struct {
unsigned char buffer[16]; unsigned char buffer[16];
unsigned int buffer_pos; size_t buffer_pos;
uint64_t length_remaining; size_t length_remaining;
unsigned char key[32]; unsigned char key[32];
unsigned char ctr[16]; unsigned char ctr[16];
} AES_XOF_struct; } AES_XOF_struct;

View File

@ -20,7 +20,7 @@ static inline void gf2x_add_asymm(const size_t nr, DIGIT Res[],
} }
/* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */ /* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */
void PQCLEAN_LEDAKEMLT52_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsigned int amount) { void PQCLEAN_LEDAKEMLT52_CLEAN_right_bit_shift_n(int length, DIGIT in[], unsigned int amount) {
assert(amount < DIGIT_SIZE_b); assert(amount < DIGIT_SIZE_b);
if ( amount == 0 ) { if ( amount == 0 ) {
return; return;
@ -36,12 +36,12 @@ void PQCLEAN_LEDAKEMLT52_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsi
} }
/* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */ /* PRE: MAX ALLOWED ROTATION AMOUNT : DIGIT_SIZE_b */
void PQCLEAN_LEDAKEMLT52_CLEAN_left_bit_shift_n(size_t length, DIGIT in[], unsigned int amount) { void PQCLEAN_LEDAKEMLT52_CLEAN_left_bit_shift_n(int length, DIGIT in[], unsigned int amount) {
assert(amount < DIGIT_SIZE_b); assert(amount < DIGIT_SIZE_b);
if ( amount == 0 ) { if ( amount == 0 ) {
return; return;
} }
size_t j; int j;
DIGIT mask; DIGIT mask;
mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1); mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1);
for (j = 0 ; j < length - 1 ; j++) { for (j = 0 ; j < length - 1 ; j++) {

View File

@ -50,14 +50,14 @@ typedef uint64_t DIGIT;
#define GF2X_MUL PQCLEAN_LEDAKEMLT52_CLEAN_gf2x_mul_comb #define GF2X_MUL PQCLEAN_LEDAKEMLT52_CLEAN_gf2x_mul_comb
static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], size_t nr) { static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], int nr) {
for (size_t i = 0; i < nr; i++) { for (int i = 0; i < nr; i++) {
Res[i] = A[i] ^ B[i]; Res[i] = A[i] ^ B[i];
} }
} }
void PQCLEAN_LEDAKEMLT52_CLEAN_right_bit_shift_n(size_t length, DIGIT in[], unsigned int amount); void PQCLEAN_LEDAKEMLT52_CLEAN_right_bit_shift_n(int length, DIGIT in[], unsigned int amount);
void PQCLEAN_LEDAKEMLT52_CLEAN_left_bit_shift_n(size_t length, DIGIT in[], unsigned int amount); void PQCLEAN_LEDAKEMLT52_CLEAN_left_bit_shift_n(int length, DIGIT in[], unsigned int amount);
void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]); void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]);
#endif #endif

View File

@ -15,7 +15,7 @@
static int seedexpander_init(AES_XOF_struct *ctx, static int seedexpander_init(AES_XOF_struct *ctx,
unsigned char *seed, unsigned char *seed,
unsigned char *diversifier, unsigned char *diversifier,
uint64_t maxlen) { size_t maxlen) {
if ( maxlen >= 0x100000000 ) { if ( maxlen >= 0x100000000 ) {
return RNG_BAD_MAXLEN; return RNG_BAD_MAXLEN;
} }

View File

@ -11,8 +11,8 @@
typedef struct { typedef struct {
unsigned char buffer[16]; unsigned char buffer[16];
unsigned int buffer_pos; size_t buffer_pos;
uint64_t length_remaining; size_t length_remaining;
unsigned char key[32]; unsigned char key[32];
unsigned char ctr[16]; unsigned char ctr[16];
} AES_XOF_struct; } AES_XOF_struct;