Skip to content

Commit

Permalink
compiler warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmucb committed Apr 28, 2024
1 parent 2528e96 commit ebfcedd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions v2/kyber/kyber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ bool byte_encode_from_vector(int d, int n, vector<int>& v, byte* out) {
int k = 0; // bit position in output byte
int m = 0; // current output byte number
int out_len = (num_bits + NBITSINBYTE - 1) / NBITSINBYTE;
memset(out, 0, out_len);
memset(out, 0, (size_t)out_len);
for (int i = 0; i < num_bits; i++) {
t = (int)bit_from_int_vector(d, i, v);
r |= t << k;
Expand Down Expand Up @@ -1698,14 +1698,15 @@ bool kyber_kem_decaps(int g, kyber_parameters& p, int kem_dk_len, byte* kem_dk,

// ------------------------------------------------------------------------------------

#ifdef LONG_DEBUG
bool special_test_1(kyber_parameters& p, coefficient_vector& mu,
coefficient_vector& nu,
int len_m, byte* m, int len_c2, byte*c2) {

printf("\n\ntest, decompressed mu\n");
coefficient_vector t_compressed_mu(p.q_, p.n_);
byte checked_m[32];
memset(checked_m, 0, 32);
memset(checked_m, 0, (size_t)32);

for (int j = 0; j < p.n_; j++) {
t_compressed_mu.c_[j] = compress(p.q_, mu.c_[j], 1);
Expand Down Expand Up @@ -1785,6 +1786,7 @@ if (!coefficient_equal(r1, r2)) {
}
return true;
}
#endif

// ------------------------------------------------------------------------------------

4 changes: 4 additions & 0 deletions v2/kyber/test_kyber.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ bool test_kyber_support() {
sample_ntt_out.c_[i] = 0;
}
int n_b = crypto_get_random_bytes(sample_ntt_b_len, sample_ntt_b);
if (n_b != sample_ntt_b_len) {
printf("Could not get enough random bits\n");
return false;
}
if (!sample_ntt(p.q_, p.n_, sample_ntt_b_len,
sample_ntt_b, sample_ntt_out.c_)) {
printf("Could not sample_ntt\n");
Expand Down

0 comments on commit ebfcedd

Please sign in to comment.