8 #include <botan/internal/mp_core.h>
9 #include <botan/mem_ops.h>
18 void bigint_shl1(word x[],
size_t x_size,
size_t word_shift,
size_t bit_shift)
22 for(
size_t j = 1; j != x_size + 1; ++j)
23 x[(x_size - j) + word_shift] = x[x_size - j];
30 for(
size_t j = word_shift; j != x_size + word_shift + 1; ++j)
33 x[j] = (temp << bit_shift) | carry;
42 void bigint_shr1(word x[],
size_t x_size,
size_t word_shift,
size_t bit_shift)
44 if(x_size < word_shift)
52 copy_mem(x, x + word_shift, x_size - word_shift);
53 clear_mem(x + x_size - word_shift, word_shift);
60 size_t top = x_size - word_shift;
65 x[top-1] = (w >> bit_shift) | carry;
69 x[top-2] = (w >> bit_shift) | carry;
73 x[top-3] = (w >> bit_shift) | carry;
77 x[top-4] = (w >> bit_shift) | carry;
86 x[top-1] = (w >> bit_shift) | carry;
98 size_t word_shift,
size_t bit_shift)
100 for(
size_t j = 0; j != x_size; ++j)
101 y[j + word_shift] = x[j];
105 for(
size_t j = word_shift; j != x_size + word_shift + 1; ++j)
108 y[j] = (w << bit_shift) | carry;
118 size_t word_shift,
size_t bit_shift)
120 if(x_size < word_shift)
return;
122 for(
size_t j = 0; j != x_size - word_shift; ++j)
123 y[j] = x[j + word_shift];
127 for(
size_t j = x_size - word_shift; j > 0; --j)
130 y[j-1] = (w >> bit_shift) | carry;
void bigint_shr1(word x[], size_t x_size, size_t word_shift, size_t bit_shift)
void bigint_shr2(word y[], const word x[], size_t x_size, size_t word_shift, size_t bit_shift)
void clear_mem(T *ptr, size_t n)
void copy_mem(T *out, const T *in, size_t n)
void bigint_shl2(word y[], const word x[], size_t x_size, size_t word_shift, size_t bit_shift)
void bigint_shl1(word x[], size_t x_size, size_t word_shift, size_t bit_shift)
const size_t MP_WORD_BITS