Browse Source

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

master
Leon 5 years ago
parent
commit
98e643e5c7
12 changed files with 35 additions and 35 deletions
  1. +3
    -3
      crypto_kem/ledakemlt12/clean/gf2x_arith.c
  2. +4
    -4
      crypto_kem/ledakemlt12/clean/gf2x_arith.h
  3. +1
    -1
      crypto_kem/ledakemlt12/clean/rng.c
  4. +2
    -2
      crypto_kem/ledakemlt12/clean/rng.h
  5. +8
    -8
      crypto_kem/ledakemlt32/clean/gf2x_arith.c
  6. +4
    -4
      crypto_kem/ledakemlt32/clean/gf2x_arith.h
  7. +1
    -1
      crypto_kem/ledakemlt32/clean/rng.c
  8. +2
    -2
      crypto_kem/ledakemlt32/clean/rng.h
  9. +3
    -3
      crypto_kem/ledakemlt52/clean/gf2x_arith.c
  10. +4
    -4
      crypto_kem/ledakemlt52/clean/gf2x_arith.h
  11. +1
    -1
      crypto_kem/ledakemlt52/clean/rng.c
  12. +2
    -2
      crypto_kem/ledakemlt52/clean/rng.h

+ 3
- 3
crypto_kem/ledakemlt12/clean/gf2x_arith.c 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 */
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);
if ( amount == 0 ) {
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 */
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);
if ( amount == 0 ) {
return;
}
size_t j;
int j;
DIGIT mask;
mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1);
for (j = 0 ; j < length - 1 ; j++) {


+ 4
- 4
crypto_kem/ledakemlt12/clean/gf2x_arith.h View File

@@ -50,14 +50,14 @@ typedef uint64_t DIGIT;

#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) {
for (size_t i = 0; i < nr; i++) {
static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], int nr) {
for (int i = 0; i < nr; 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_left_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(int length, DIGIT in[], unsigned int amount);
void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]);

#endif

+ 1
- 1
crypto_kem/ledakemlt12/clean/rng.c View File

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


+ 2
- 2
crypto_kem/ledakemlt12/clean/rng.h View File

@@ -11,8 +11,8 @@

typedef struct {
unsigned char buffer[16];
unsigned int buffer_pos;
uint64_t length_remaining;
size_t buffer_pos;
size_t length_remaining;
unsigned char key[32];
unsigned char ctr[16];
} AES_XOF_struct;


+ 8
- 8
crypto_kem/ledakemlt32/clean/gf2x_arith.c View File

@@ -5,12 +5,12 @@

/* allows the second operand to be shorter than the first */
/* the result should be as large as the first operand*/
static inline void gf2x_add_asymm(const size_t nr, DIGIT Res[],
const size_t na, const DIGIT A[],
const size_t nb, const DIGIT B[]) {
static inline void gf2x_add_asymm(const int nr, DIGIT Res[],
const int na, const DIGIT A[],
const int nb, const DIGIT B[]) {
assert(nr >= na && na >= nb);
size_t i;
size_t delta = na - nb;
int i;
int delta = na - nb;
for (i = 0; i < delta; 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 */
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);
if ( amount == 0 ) {
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 */
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);
if ( amount == 0 ) {
return;
}
size_t j;
int j;
DIGIT mask;
mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1);
for (j = 0 ; j < length - 1 ; j++) {


+ 4
- 4
crypto_kem/ledakemlt32/clean/gf2x_arith.h View File

@@ -50,14 +50,14 @@ typedef uint64_t DIGIT;

#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) {
for (size_t i = 0; i < nr; i++) {
static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], int nr) {
for (int i = 0; i < nr; 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_left_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(int length, DIGIT in[], unsigned int amount);
void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]);

#endif

+ 1
- 1
crypto_kem/ledakemlt32/clean/rng.c View File

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


+ 2
- 2
crypto_kem/ledakemlt32/clean/rng.h View File

@@ -11,8 +11,8 @@

typedef struct {
unsigned char buffer[16];
unsigned int buffer_pos;
uint64_t length_remaining;
size_t buffer_pos;
size_t length_remaining;
unsigned char key[32];
unsigned char ctr[16];
} AES_XOF_struct;


+ 3
- 3
crypto_kem/ledakemlt52/clean/gf2x_arith.c 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 */
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);
if ( amount == 0 ) {
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 */
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);
if ( amount == 0 ) {
return;
}
size_t j;
int j;
DIGIT mask;
mask = ~(((DIGIT)0x01 << (DIGIT_SIZE_b - amount)) - 1);
for (j = 0 ; j < length - 1 ; j++) {


+ 4
- 4
crypto_kem/ledakemlt52/clean/gf2x_arith.h View File

@@ -50,14 +50,14 @@ typedef uint64_t DIGIT;

#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) {
for (size_t i = 0; i < nr; i++) {
static inline void gf2x_add(DIGIT Res[], const DIGIT A[], const DIGIT B[], int nr) {
for (int i = 0; i < nr; 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_left_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(int length, DIGIT in[], unsigned int amount);
void GF2X_MUL(int nr, DIGIT Res[], int na, const DIGIT A[], int nb, const DIGIT B[]);

#endif

+ 1
- 1
crypto_kem/ledakemlt52/clean/rng.c View File

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


+ 2
- 2
crypto_kem/ledakemlt52/clean/rng.h View File

@@ -11,8 +11,8 @@

typedef struct {
unsigned char buffer[16];
unsigned int buffer_pos;
uint64_t length_remaining;
size_t buffer_pos;
size_t length_remaining;
unsigned char key[32];
unsigned char ctr[16];
} AES_XOF_struct;


Loading…
Cancel
Save