Lines Matching refs:keyLength
30 void multiprecision_init(DWORD *c, uint32_t keyLength)
32 for (uint32_t i = 0; i < keyLength; i++)
36 void multiprecision_copy(DWORD *c, DWORD *a, uint32_t keyLength)
38 for (uint32_t i = 0; i < keyLength; i++)
42 int multiprecision_compare(DWORD *a, DWORD *b, uint32_t keyLength)
44 for (int i = keyLength - 1; i >= 0; i--)
54 int multiprecision_iszero(DWORD *a, uint32_t keyLength)
56 for (uint32_t i = 0; i < keyLength; i++)
73 UINT32 multiprecision_most_signdwords(DWORD *a, uint32_t keyLength)
76 for (i = keyLength - 1; i >= 0; i--)
82 UINT32 multiprecision_most_signbits(DWORD *a, uint32_t keyLength)
86 aMostSignDWORDs = multiprecision_most_signdwords(a, keyLength);
94 DWORD multiprecision_add(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
100 for (uint32_t i = 0; i < keyLength; i++)
113 DWORD multiprecision_sub(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
119 for (uint32_t i=0; i < keyLength; i++)
131 void multiprecision_lshift_mod(DWORD * c, DWORD * a, uint32_t keyLength)
136 if (keyLength == KEY_LENGTH_DWORDS_P192)
140 else if (keyLength == KEY_LENGTH_DWORDS_P256)
147 carrier = multiprecision_lshift(c, a, keyLength);
150 multiprecision_sub(c, c, modp, keyLength);
152 else if (multiprecision_compare(c, modp, keyLength)>=0)
154 multiprecision_sub(c, c, modp, keyLength);
159 void multiprecision_rshift(DWORD * c, DWORD * a, uint32_t keyLength)
168 for (int i = keyLength-1; i >= 0; i--)
177 void multiprecision_mersenns_mult_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
181 multiprecision_mult(cc, a, b, keyLength);
182 if (keyLength == 6)
186 else if (keyLength == 8)
193 void multiprecision_mersenns_squa_mod(DWORD *c, DWORD *a, uint32_t keyLength)
195 multiprecision_mersenns_mult_mod(c, a, a, keyLength);
199 void multiprecision_add_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
204 if (keyLength == KEY_LENGTH_DWORDS_P192)
208 else if (keyLength == KEY_LENGTH_DWORDS_P256)
215 carrier = multiprecision_add(c, a, b, keyLength);
218 multiprecision_sub(c, c, modp, keyLength);
220 else if (multiprecision_compare(c, modp, keyLength) >= 0)
222 multiprecision_sub(c, c, modp, keyLength);
227 void multiprecision_sub_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
232 if (keyLength == KEY_LENGTH_DWORDS_P192)
236 else if(keyLength == KEY_LENGTH_DWORDS_P256)
243 borrow = multiprecision_sub(c, a, b, keyLength);
245 multiprecision_add(c, c, modp, keyLength);
249 DWORD multiprecision_lshift(DWORD * c, DWORD * a, uint32_t keyLength)
258 for (uint32_t i = 0; i < keyLength; i++)
269 void multiprecision_mult(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
276 multiprecision_init(c, keyLength);
279 for (uint32_t i = 0; i < keyLength; i++)
282 for (uint32_t j = 0; j < keyLength; j++)
295 c[i+keyLength] = U;
636 void multiprecision_inv_mod(DWORD *aminus, DWORD *u, uint32_t keyLength)
643 if(keyLength == KEY_LENGTH_DWORDS_P256)
652 multiprecision_copy(v, modp, keyLength);
653 multiprecision_init(A, keyLength);
654 multiprecision_init(C, keyLength);
657 while (!multiprecision_iszero(u, keyLength))
661 multiprecision_rshift(u, u, keyLength);
663 multiprecision_rshift(A, A, keyLength);
666 A[keyLength]=multiprecision_add(A, A, modp, keyLength); // A =A+p
667 multiprecision_rshift(A, A, keyLength);
668 A[keyLength-1] |= (A[keyLength]<<31);
674 multiprecision_rshift(v, v, keyLength);
677 multiprecision_rshift(C, C, keyLength);
681 C[keyLength] = multiprecision_add(C, C, modp, keyLength); // C =C+p
682 multiprecision_rshift(C, C, keyLength);
683 C[keyLength-1] |= (C[keyLength] << 31);
687 if (multiprecision_compare(u, v, keyLength) >= 0)
689 multiprecision_sub(u, u, v, keyLength);
690 multiprecision_sub_mod(A, A, C, keyLength);
694 multiprecision_sub(v, v, u, keyLength);
695 multiprecision_sub_mod(C, C, A, keyLength);
699 if (multiprecision_compare(C, modp, keyLength) >= 0)
700 multiprecision_sub(aminus, C, modp, keyLength);
702 multiprecision_copy(aminus, C, keyLength);