mirror of
https://github.com/emmansun/gmsm.git
synced 2025-05-16 14:06:19 +08:00
Updated is my code constant time? (markdown)
parent
8b6f982d3b
commit
1ed25116a3
@ -37,12 +37,12 @@ __INLINE void cpSM2KE_reduction_x2w(BNU_CHUNK_T *r, const BNU_CHUNK_T *a, const
|
||||
const int w = ((elemBits + 1) / 2 - 1);
|
||||
|
||||
/* compute copy BNU_CHUNK */
|
||||
const int num_copy_bc = (w + (BNU_CHUNK_BITS - 1)) / BNU_CHUNK_BITS; // 2
|
||||
const int num_copy_bc = (w + (BNU_CHUNK_BITS - 1)) / BNU_CHUNK_BITS; // 2, 假定BNU_CHUNK_BITS=64
|
||||
const int num_bit_shift = (w - (num_copy_bc - 1) * BNU_CHUNK_BITS); // 63
|
||||
const BNU_CHUNK_T vadd = (BNU_CHUNK_T)(1ULL << num_bit_shift); // 1<<63 = 0x8000000000000000
|
||||
const BNU_CHUNK_T mask = (BNU_CHUNK_T)(vadd - 1); // 0x7fffffffffffffff
|
||||
|
||||
ZEXPAND_COPY_BNU(r, elemSize, a, num_copy_bc); // copy 2 64 bits of a to r
|
||||
ZEXPAND_COPY_BNU(r, elemSize, a, num_copy_bc); // copy 2 64 bits from a to r
|
||||
r[num_copy_bc - 1] = (r[num_copy_bc - 1] & mask) + vadd;
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user