diff options
author | Jack Lloyd <[email protected]> | 2015-07-05 21:15:08 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-07-05 21:15:08 -0400 |
commit | 46510029cf940a7c505231f1914468622317dd81 (patch) | |
tree | fcf133f982627f7ac13bd3a2670b14d24898a77d | |
parent | c56d3442e605d508dc372b2d38aeac84f273a43c (diff) |
The gf2m type is an unsigned 16-bit, so under C promotion rules a
shift promotes to signed int rather than an unsigned value. However
here we wish to use a large shift, which can cause a signed overflow.
Add static_cast to force to the desired (unsigned) type.
-rw-r--r-- | src/lib/pubkey/mce/code_based_key_gen.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp index 7adf85112..a3749abef 100644 --- a/src/lib/pubkey/mce/code_based_key_gen.cpp +++ b/src/lib/pubkey/mce/code_based_key_gen.cpp @@ -156,7 +156,7 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e { k = (l * ext_deg) / 32; j = (l * ext_deg) % 32; - sk[k] ^= F[i].get_coef( l) << j; + sk[k] ^= static_cast<u32bit>(F[i].get_coef(l)) << j; if (j + ext_deg > 32) { sk[k + 1] ^= F[i].get_coef( l) >> (32 - j); |