Lines Matching refs:c

181 #define add_cout(carry, c, a, b) add((carry), (c), (a), (b))  argument
183 #define add_cout_cin(carryout, c, a, b, carryin) \ argument
187 (c) = (uint32_t)_t; \
191 #define sub_borrowout(borrow, c, a, b) \ argument
195 (c) = (a) - (b); \
199 #define sub_borrowin_borrowout(borrowout, c, a, b, borrowin) \ argument
204 sub_borrowout(_borrow2, (c), _t, (borrowin)); \
208 #define sub_borrowout_1(borrow, c, a) \ argument
212 c = a - b; \
216 #define sub_borrowin_borrowout_1(borrowout, c, a, borrowin) \ argument
221 sub_borrowout(_borrow2, c, _t, borrowin); \
269 #define square_casper(c, a) multiply_casper(c, a, a) argument
270 #define sub_casper(c, a, b) CASPER_montsub(c, a, b, &CASPER_MEM[(N_wordlen + 4U)]) argument
271 #define add_casper(c, a, b) CASPER_montadd(c, a, b, &CASPER_MEM[(N_wordlen + 4U)]) argument
272 #define mul2_casper(c, a) add_casper(c, a, a) argument
273 #define half(c, a, b) CASPER_half(c, a, b) argument
402 static void invert_mod_p384(uint32_t *c, uint32_t *a);
405 static void invert_mod_p256(uint32_t *c, uint32_t *a);
408 static void invert_mod_p521(uint32_t *c, uint32_t *a);
419 static void CASPER_half(uint32_t *c, uint32_t *a, uint32_t *b);
431 static void casper_select(uint32_t *c, uint32_t *a, uint32_t *b, int m, int n);
434 static uint32_t add_n_1(uint32_t *c, uint32_t *a, uint32_t b, int n);
438 static uint32_t add_n(uint32_t *c, uint32_t *a, uint32_t *b, int n);
441 static uint32_t sub_n_1(uint32_t *c, uint32_t *a, uint32_t b, int n);
445 static uint32_t sub_n(uint32_t *c, uint32_t *a, uint32_t *b, int n);
472 static void shiftrightSysram(uint32_t *z, uint32_t *x, uint32_t c);
473 static void shiftright(uint32_t *z, uint32_t *x, uint32_t c);
474 static void shiftleft(uint32_t *z, uint32_t *x, uint32_t c);
567 static void casper_select(uint32_t *c, uint32_t *a, uint32_t *b, int m, int n) in casper_select() argument
574 SET_WORD(&c[i], (GET_WORD(&a[i]) & m2) | (GET_WORD(&b[i]) & m1)); in casper_select()
1131 uint32_t c = 0; in CASPER_ECC_equal() local
1138 c = (a[0] ^ b[0]); in CASPER_ECC_equal()
1141 c |= (a[_i] ^ b[_i]); in CASPER_ECC_equal()
1145 *res = (int32_t)c; in CASPER_ECC_equal()
1151 uint32_t c = 0; in CASPER_ECC_equal_to_zero() local
1157 c = a[0]; in CASPER_ECC_equal_to_zero()
1160 c |= a[_i]; in CASPER_ECC_equal_to_zero()
1164 *res = (int32_t)c; in CASPER_ECC_equal_to_zero()
1770 static void CASPER_half(uint32_t *c, uint32_t *a, uint32_t *b) in CASPER_half() argument
1775 CASPER_MEMCPY(c, a, N_wordlen * sizeof(uint32_t)); in CASPER_half()
1776 SET_WORD(&c[N_wordlen], 0); in CASPER_half()
1777 SET_WORD(&c[N_wordlen + 1U], 0U); in CASPER_half()
1781 …erOpcodeResaddr(N_wordlen / 2U, (uint32_t)kCASPER_OpAdd64, CA_MK_OFF(((uint64_t *)(uintptr_t)c)))); in CASPER_half()
1784 shiftright(c, c, 1U); in CASPER_half()
1785 SET_WORD(&c[N_wordlen - 1U], GET_WORD(&c[N_wordlen - 1U]) | (GET_WORD(&c[N_wordlen]) << 31)); in CASPER_half()
1786 SET_WORD(&c[N_wordlen], 0U); in CASPER_half()
1787 … casper_select(c, b, c, (int32_t)(uint32_t)(GET_WORD(&a[0]) & 1U), (int16_t)(uint16_t)(N_wordlen)); in CASPER_half()
1796 static void shiftrightSysram(uint32_t *z, uint32_t *x, uint32_t c) in shiftrightSysram() argument
1798 z[0] = (x[1] << (32U - (c))) | (x[0] >> (c)); in shiftrightSysram()
1799 z[1] = (x[2] << (32U - (c))) | (x[1] >> (c)); in shiftrightSysram()
1800 z[2] = (x[3] << (32U - (c))) | (x[2] >> (c)); in shiftrightSysram()
1801 z[3] = (x[4] << (32U - (c))) | (x[3] >> (c)); in shiftrightSysram()
1802 z[4] = (x[5] << (32U - (c))) | (x[4] >> (c)); in shiftrightSysram()
1803 z[5] = (x[6] << (32U - (c))) | (x[5] >> (c)); in shiftrightSysram()
1804 z[6] = (x[7] << (32U - (c))) | (x[6] >> (c)); in shiftrightSysram()
1808 z[7] = (x[8] << (32U - (c))) | (x[7] >> (c)); in shiftrightSysram()
1809 z[8] = (x[9] << (32U - (c))) | (x[8] >> (c)); in shiftrightSysram()
1810 z[9] = (x[10] << (32U - (c))) | (x[9] >> (c)); in shiftrightSysram()
1811 z[10] = (x[11] << (32U - (c))) | (x[10] >> (c)); in shiftrightSysram()
1812 z[11] = (x[12] << (32U - (c))) | (x[11] >> (c)); in shiftrightSysram()
1813 z[12] = (x[13] << (32U - (c))) | (x[12] >> (c)); in shiftrightSysram()
1814 z[13] = (x[14] << (32U - (c))) | (x[13] >> (c)); in shiftrightSysram()
1815 z[14] = (x[15] << (32U - (c))) | (x[14] >> (c)); in shiftrightSysram()
1816 z[15] = (x[16] << (32U - (c))) | (x[15] >> (c)); in shiftrightSysram()
1817 z[16] = (x[17] << (32U - (c))) | (x[16] >> (c)); in shiftrightSysram()
1818 z[17] = (x[17] >> (c)); in shiftrightSysram()
1823 z[7] = (x[8] << (32U - (c))) | (x[7] >> (c)); in shiftrightSysram()
1824 z[8] = (x[9] << (32U - (c))) | (x[8] >> (c)); in shiftrightSysram()
1825 z[9] = (x[10] << (32U - (c))) | (x[9] >> (c)); in shiftrightSysram()
1826 z[10] = (x[11] << (32U - (c))) | (x[10] >> (c)); in shiftrightSysram()
1827 z[11] = (x[11] >> (c)); in shiftrightSysram()
1831 z[7] = (x[7] >> (c)); in shiftrightSysram()
1835 static void shiftright(uint32_t *z, uint32_t *x, uint32_t c) in shiftright() argument
1837 SET_WORD(&z[0], (GET_WORD(&x[1]) << (32U - (c))) | (GET_WORD(&x[0]) >> (c))); in shiftright()
1838 SET_WORD(&z[1], (GET_WORD(&x[2]) << (32U - (c))) | (GET_WORD(&x[1]) >> (c))); in shiftright()
1839 SET_WORD(&z[2], (GET_WORD(&x[3]) << (32U - (c))) | (GET_WORD(&x[2]) >> (c))); in shiftright()
1840 SET_WORD(&z[3], (GET_WORD(&x[4]) << (32U - (c))) | (GET_WORD(&x[3]) >> (c))); in shiftright()
1841 SET_WORD(&z[4], (GET_WORD(&x[5]) << (32U - (c))) | (GET_WORD(&x[4]) >> (c))); in shiftright()
1842 SET_WORD(&z[5], (GET_WORD(&x[6]) << (32U - (c))) | (GET_WORD(&x[5]) >> (c))); in shiftright()
1843 SET_WORD(&z[6], (GET_WORD(&x[7]) << (32U - (c))) | (GET_WORD(&x[6]) >> (c))); in shiftright()
1847 SET_WORD(&z[7], (GET_WORD(&x[8]) << (32U - (c))) | (GET_WORD(&x[7]) >> (c))); in shiftright()
1848 SET_WORD(&z[8], (GET_WORD(&x[9]) << (32U - (c))) | (GET_WORD(&x[8]) >> (c))); in shiftright()
1849 SET_WORD(&z[9], (GET_WORD(&x[10]) << (32U - (c))) | (GET_WORD(&x[9]) >> (c))); in shiftright()
1850 SET_WORD(&z[10], (GET_WORD(&x[11]) << (32U - (c))) | (GET_WORD(&x[10]) >> (c))); in shiftright()
1851 SET_WORD(&z[11], (GET_WORD(&x[12]) << (32U - (c))) | (GET_WORD(&x[11]) >> (c))); in shiftright()
1852 SET_WORD(&z[12], (GET_WORD(&x[13]) << (32U - (c))) | (GET_WORD(&x[12]) >> (c))); in shiftright()
1853 SET_WORD(&z[13], (GET_WORD(&x[14]) << (32U - (c))) | (GET_WORD(&x[13]) >> (c))); in shiftright()
1854 SET_WORD(&z[14], (GET_WORD(&x[15]) << (32U - (c))) | (GET_WORD(&x[14]) >> (c))); in shiftright()
1855 SET_WORD(&z[15], (GET_WORD(&x[16]) << (32U - (c))) | (GET_WORD(&x[15]) >> (c))); in shiftright()
1856 SET_WORD(&z[16], (GET_WORD(&x[17]) << (32U - (c))) | (GET_WORD(&x[16]) >> (c))); in shiftright()
1857 SET_WORD(&z[17], (GET_WORD(&x[17]) >> (c))); in shiftright()
1861 SET_WORD(&z[7], (GET_WORD(&x[8]) << (32U - (c))) | (GET_WORD(&x[7]) >> (c))); in shiftright()
1862 SET_WORD(&z[8], (GET_WORD(&x[9]) << (32U - (c))) | (GET_WORD(&x[8]) >> (c))); in shiftright()
1863 SET_WORD(&z[9], (GET_WORD(&x[10]) << (32U - (c))) | (GET_WORD(&x[9]) >> (c))); in shiftright()
1864 SET_WORD(&z[10], (GET_WORD(&x[11]) << (32U - (c))) | (GET_WORD(&x[10]) >> (c))); in shiftright()
1865 SET_WORD(&z[11], (GET_WORD(&x[11]) >> (c))); in shiftright()
1869 SET_WORD((&z[7]), (GET_WORD(&x[7]) >> (c))); in shiftright()
1873 static void shiftleft(uint32_t *z, uint32_t *x, uint32_t c) in shiftleft() argument
1877 SET_WORD(&z[17], (GET_WORD(&x[17]) << (c)) | GET_WORD(&z[16]) >> (32U - (c))); in shiftleft()
1878 SET_WORD(&z[16], (GET_WORD(&x[16]) << (c)) | GET_WORD(&z[15]) >> (32U - (c))); in shiftleft()
1879 SET_WORD(&z[15], (GET_WORD(&x[15]) << (c)) | GET_WORD(&z[14]) >> (32U - (c))); in shiftleft()
1880 SET_WORD(&z[14], (GET_WORD(&x[14]) << (c)) | GET_WORD(&z[13]) >> (32U - (c))); in shiftleft()
1881 SET_WORD(&z[13], (GET_WORD(&x[13]) << (c)) | GET_WORD(&z[12]) >> (32U - (c))); in shiftleft()
1882 SET_WORD(&z[12], (GET_WORD(&x[12]) << (c)) | GET_WORD(&z[11]) >> (32U - (c))); in shiftleft()
1883 SET_WORD(&z[11], (GET_WORD(&x[11]) << (c)) | GET_WORD(&z[10]) >> (32U - (c))); in shiftleft()
1884 SET_WORD(&z[10], (GET_WORD(&x[10]) << (c)) | GET_WORD(&z[9]) >> (32U - (c))); in shiftleft()
1885 SET_WORD(&z[9], (GET_WORD(&x[9]) << (c)) | GET_WORD(&z[8]) >> (32U - (c))); in shiftleft()
1886 SET_WORD(&z[8], (GET_WORD(&x[8]) << (c)) | GET_WORD(&z[7]) >> (32U - (c))); in shiftleft()
1890 SET_WORD(&z[11], (GET_WORD(&x[11]) << (c)) | GET_WORD(&z[10]) >> (32U - (c))); in shiftleft()
1891 SET_WORD(&z[10], (GET_WORD(&x[10]) << (c)) | GET_WORD(&z[9]) >> (32U - (c))); in shiftleft()
1892 SET_WORD(&z[9], (GET_WORD(&x[9]) << (c)) | GET_WORD(&z[8]) >> (32U - (c))); in shiftleft()
1893 SET_WORD(&z[8], (GET_WORD(&x[8]) << (c)) | GET_WORD(&z[7]) >> (32U - (c))); in shiftleft()
1895 SET_WORD(&z[7], (GET_WORD(&x[7]) << (c)) | GET_WORD(&z[6]) >> (32U - (c))); in shiftleft()
1896 SET_WORD(&z[6], (GET_WORD(&x[6]) << (c)) | GET_WORD(&z[5]) >> (32U - (c))); in shiftleft()
1897 SET_WORD(&z[5], (GET_WORD(&x[5]) << (c)) | GET_WORD(&z[4]) >> (32U - (c))); in shiftleft()
1898 SET_WORD(&z[4], (GET_WORD(&x[4]) << (c)) | GET_WORD(&z[3]) >> (32U - (c))); in shiftleft()
1899 SET_WORD(&z[3], (GET_WORD(&x[3]) << (c)) | GET_WORD(&z[2]) >> (32U - (c))); in shiftleft()
1900 SET_WORD(&z[2], (GET_WORD(&x[2]) << (c)) | GET_WORD(&z[1]) >> (32U - (c))); in shiftleft()
1901 SET_WORD(&z[1], (GET_WORD(&x[1]) << (c)) | GET_WORD(&z[0]) >> (32U - (c))); in shiftleft()
1902 SET_WORD(&z[0], (GET_WORD(&x[0]) << (c))); in shiftleft()
2187 static void recode(int8_t *c, uint32_t *k, int n, int w) in recode() argument
2195 c[i] = (int8_t)(uint8_t)((K[0] & ((uint32_t)(uint32_t)(1UL << (uint32_t)w) - 1UL)) - in recode()
2198 (void)add_n_1(K, K, (uint32_t)c[i] >> 31, (int16_t)(uint16_t)N_wordlen); in recode()
2200 c[t] = (int8_t)K[0]; in recode()
2203 static uint32_t sub_n(uint32_t *c, uint32_t *a, uint32_t *b, int n) in sub_n() argument
2207 sub_borrowout(borrow, GET_WORD(&c[0]), a[0], GET_WORD(&b[0])); in sub_n()
2210 sub_borrowin_borrowout(borrow, GET_WORD(&c[i]), a[i], GET_WORD(&b[i]), borrow); in sub_n()
2217 static uint32_t sub_n_1(uint32_t *c, uint32_t *a, uint32_t b, int n) {
2220 sub_borrowout(borrow, c[0], a[0], b);
2222 sub_borrowin_borrowout_1(borrow, c[i], a[i], borrow);
2228 static uint32_t add_n(uint32_t *c, uint32_t *a, uint32_t *b, int n) {
2231 add_cout(carry, c[0], a[0], b[0]);
2233 add_cout_cin(carry, c[i], a[i], b[i], carry);
2240 static uint32_t add_n_1(uint32_t *c, uint32_t *a, uint32_t b, int n) in add_n_1() argument
2244 add_cout(carry, c[0], a[0], b); in add_n_1()
2247 add_cout_cin(carry, c[i], a[i], 0U, carry); in add_n_1()
2645 uint32_t index = 0, c = 0; in double_scalar_multiplication() local
2699 …r_get_word(&p1[N_wordlen - 1U]) | casper_get_word(&p2[N_wordlen - 1U])) >> 31) == 0U && c < bitlen) in double_scalar_multiplication()
2703 c++; in double_scalar_multiplication()
2725 c += shiftl; in double_scalar_multiplication()
2742 c < bitlen) in double_scalar_multiplication()
2747 c++; in double_scalar_multiplication()
2750 if (c >= (bitlen - 1U)) in double_scalar_multiplication()
2782 c += shiftl; in double_scalar_multiplication()
2786 if (c == (bitlen - 1U)) in double_scalar_multiplication()
2799 c++; in double_scalar_multiplication()
2802 while (c < bitlen) in double_scalar_multiplication()
2805 c++; in double_scalar_multiplication()
2809 static void invert_mod_p256(uint32_t *c, uint32_t *a) in invert_mod_p256() argument
2932 multiply_casper(c, tmp, a); in invert_mod_p256()
2966 static void invert_mod_p384(uint32_t *c, uint32_t *a) in invert_mod_p384() argument
3158 multiply_casper(c, t6, d); in invert_mod_p384()
3185 static void invert_mod_p521(uint32_t *c, uint32_t *a) in invert_mod_p521() argument
3293 multiply_casper(c, e3, a); in invert_mod_p521()