| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/rsaz_exp.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | void rsaz_1024_norm2red_avx2(void *red, const void *norm); | - | ||||||||||||
| 2 | void rsaz_1024_mul_avx2(void *ret, const void *a, const void *b, | - | ||||||||||||
| 3 | const void *n, unsigned long k); | - | ||||||||||||
| 4 | void rsaz_1024_sqr_avx2(void *ret, const void *a, const void *n, unsigned long k, | - | ||||||||||||
| 5 | int cnt); | - | ||||||||||||
| 6 | void rsaz_1024_scatter5_avx2(void *tbl, const void *val, int i); | - | ||||||||||||
| 7 | void rsaz_1024_gather5_avx2(void *val, const void *tbl, int i); | - | ||||||||||||
| 8 | void rsaz_1024_red2norm_avx2(void *norm, const void *red); | - | ||||||||||||
| 9 | __attribute__((aligned(64))) static const unsigned long one[40] = { | - | ||||||||||||
| 10 | 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||
| 11 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
| 12 | }; | - | ||||||||||||
| 13 | - | |||||||||||||
| 14 | __attribute__((aligned(64))) static const unsigned long two80[40] = { | - | ||||||||||||
| 15 | 0, 0, 1 << 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||
| 16 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - | ||||||||||||
| 17 | }; | - | ||||||||||||
| 18 | - | |||||||||||||
| 19 | void RSAZ_1024_mod_exp_avx2(unsigned long result_norm[16], | - | ||||||||||||
| 20 | const unsigned long base_norm[16], | - | ||||||||||||
| 21 | const unsigned long exponent[16], | - | ||||||||||||
| 22 | const unsigned long m_norm[16], const unsigned long RR[16], | - | ||||||||||||
| 23 | unsigned long k0) | - | ||||||||||||
| 24 | { | - | ||||||||||||
| 25 | unsigned char storage[320 * 3 + 32 * 9 * 16 + 64]; | - | ||||||||||||
| 26 | unsigned char *p_str = storage + (64 - ((size_t)storage % 64)); | - | ||||||||||||
| 27 | unsigned char *a_inv, *m, *result; | - | ||||||||||||
| 28 | unsigned char *table_s = p_str + 320 * 3; | - | ||||||||||||
| 29 | unsigned char *R2 = table_s; | - | ||||||||||||
| 30 | int index; | - | ||||||||||||
| 31 | int wvalue; | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | if ((((
| 0 | ||||||||||||
| 34 | result = p_str; | - | ||||||||||||
| 35 | a_inv = p_str + 320; | - | ||||||||||||
| 36 | m = p_str + 320 * 2; | - | ||||||||||||
| 37 | } never executed: else {end of block | 0 | ||||||||||||
| 38 | m = p_str; | - | ||||||||||||
| 39 | result = p_str + 320; | - | ||||||||||||
| 40 | a_inv = p_str + 320 * 2; | - | ||||||||||||
| 41 | } never executed: end of block | 0 | ||||||||||||
| 42 | - | |||||||||||||
| 43 | rsaz_1024_norm2red_avx2(m, m_norm); | - | ||||||||||||
| 44 | rsaz_1024_norm2red_avx2(a_inv, base_norm); | - | ||||||||||||
| 45 | rsaz_1024_norm2red_avx2(R2, RR); | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | rsaz_1024_mul_avx2(R2, R2, R2, m, k0); | - | ||||||||||||
| 48 | rsaz_1024_mul_avx2(R2, R2, two80, m, k0); | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | - | |||||||||||||
| 51 | rsaz_1024_mul_avx2(result, R2, one, m, k0); | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | rsaz_1024_mul_avx2(a_inv, a_inv, R2, m, k0); | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | rsaz_1024_scatter5_avx2(table_s, result, 0); | - | ||||||||||||
| 56 | rsaz_1024_scatter5_avx2(table_s, a_inv, 1); | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | - | |||||||||||||
| 59 | rsaz_1024_sqr_avx2(result, a_inv, m, k0, 1); | - | ||||||||||||
| 60 | rsaz_1024_scatter5_avx2(table_s, result, 2); | - | ||||||||||||
| 61 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 62 | rsaz_1024_scatter5_avx2(table_s, result, 4); | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 65 | rsaz_1024_scatter5_avx2(table_s, result, 8); | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 68 | rsaz_1024_scatter5_avx2(table_s, result, 16); | - | ||||||||||||
| 69 | - | |||||||||||||
| 70 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 71 | rsaz_1024_scatter5_avx2(table_s, result, 17); | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | - | |||||||||||||
| 74 | rsaz_1024_gather5_avx2(result, table_s, 2); | - | ||||||||||||
| 75 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 76 | rsaz_1024_scatter5_avx2(table_s, result, 3); | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 79 | rsaz_1024_scatter5_avx2(table_s, result, 6); | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 82 | rsaz_1024_scatter5_avx2(table_s, result, 12); | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 85 | rsaz_1024_scatter5_avx2(table_s, result, 24); | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 88 | rsaz_1024_scatter5_avx2(table_s, result, 25); | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | - | |||||||||||||
| 91 | rsaz_1024_gather5_avx2(result, table_s, 4); | - | ||||||||||||
| 92 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 93 | rsaz_1024_scatter5_avx2(table_s, result, 5); | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 96 | rsaz_1024_scatter5_avx2(table_s, result, 10); | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 99 | rsaz_1024_scatter5_avx2(table_s, result, 20); | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 102 | rsaz_1024_scatter5_avx2(table_s, result, 21); | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | - | |||||||||||||
| 105 | rsaz_1024_gather5_avx2(result, table_s, 6); | - | ||||||||||||
| 106 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 107 | rsaz_1024_scatter5_avx2(table_s, result, 7); | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 110 | rsaz_1024_scatter5_avx2(table_s, result, 14); | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 113 | rsaz_1024_scatter5_avx2(table_s, result, 28); | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 116 | rsaz_1024_scatter5_avx2(table_s, result, 29); | - | ||||||||||||
| 117 | - | |||||||||||||
| 118 | - | |||||||||||||
| 119 | rsaz_1024_gather5_avx2(result, table_s, 8); | - | ||||||||||||
| 120 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 121 | rsaz_1024_scatter5_avx2(table_s, result, 9); | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 124 | rsaz_1024_scatter5_avx2(table_s, result, 18); | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 127 | rsaz_1024_scatter5_avx2(table_s, result, 19); | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 | - | |||||||||||||
| 130 | rsaz_1024_gather5_avx2(result, table_s, 10); | - | ||||||||||||
| 131 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 132 | rsaz_1024_scatter5_avx2(table_s, result, 11); | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 135 | rsaz_1024_scatter5_avx2(table_s, result, 22); | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 138 | rsaz_1024_scatter5_avx2(table_s, result, 23); | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | - | |||||||||||||
| 141 | rsaz_1024_gather5_avx2(result, table_s, 12); | - | ||||||||||||
| 142 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 143 | rsaz_1024_scatter5_avx2(table_s, result, 13); | - | ||||||||||||
| 144 | - | |||||||||||||
| 145 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 146 | rsaz_1024_scatter5_avx2(table_s, result, 26); | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 149 | rsaz_1024_scatter5_avx2(table_s, result, 27); | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | - | |||||||||||||
| 152 | rsaz_1024_gather5_avx2(result, table_s, 14); | - | ||||||||||||
| 153 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 154 | rsaz_1024_scatter5_avx2(table_s, result, 15); | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | rsaz_1024_sqr_avx2(result, result, m, k0, 1); | - | ||||||||||||
| 157 | rsaz_1024_scatter5_avx2(table_s, result, 30); | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 160 | rsaz_1024_scatter5_avx2(table_s, result, 31); | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | - | |||||||||||||
| 163 | - | |||||||||||||
| 164 | p_str = (unsigned char *)exponent; | - | ||||||||||||
| 165 | wvalue = p_str[127] >> 3; | - | ||||||||||||
| 166 | rsaz_1024_gather5_avx2(result, table_s, wvalue); | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | index = 1014; | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | while (index > -1
| 0 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | rsaz_1024_sqr_avx2(result, result, m, k0, 5); | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | wvalue = (p_str[(index / 8) + 1] << 8) | p_str[index / 8]; | - | ||||||||||||
| 175 | wvalue = (wvalue >> (index % 8)) & 31; | - | ||||||||||||
| 176 | index -= 5; | - | ||||||||||||
| 177 | - | |||||||||||||
| 178 | rsaz_1024_gather5_avx2(a_inv, table_s, wvalue); | - | ||||||||||||
| 179 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||
| 181 | - | |||||||||||||
| 182 | - | |||||||||||||
| 183 | rsaz_1024_sqr_avx2(result, result, m, k0, 4); | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | wvalue = p_str[0] & 15; | - | ||||||||||||
| 186 | - | |||||||||||||
| 187 | rsaz_1024_gather5_avx2(a_inv, table_s, wvalue); | - | ||||||||||||
| 188 | rsaz_1024_mul_avx2(result, result, a_inv, m, k0); | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | - | |||||||||||||
| 191 | rsaz_1024_mul_avx2(result, result, one, m, k0); | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | rsaz_1024_red2norm_avx2(result_norm, result); | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | OPENSSL_cleanse(storage, sizeof(storage)); | - | ||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||
| 197 | - | |||||||||||||
| 198 | - | |||||||||||||
| 199 | - | |||||||||||||
| 200 | - | |||||||||||||
| 201 | void rsaz_512_mul(void *ret, const void *a, const void *b, const void *n, | - | ||||||||||||
| 202 | unsigned long k); | - | ||||||||||||
| 203 | void rsaz_512_mul_scatter4(void *ret, const void *a, const void *n, | - | ||||||||||||
| 204 | unsigned long k, const void *tbl, unsigned int power); | - | ||||||||||||
| 205 | void rsaz_512_mul_gather4(void *ret, const void *a, const void *tbl, | - | ||||||||||||
| 206 | const void *n, unsigned long k, unsigned int power); | - | ||||||||||||
| 207 | void rsaz_512_mul_by_one(void *ret, const void *a, const void *n, unsigned long k); | - | ||||||||||||
| 208 | void rsaz_512_sqr(void *ret, const void *a, const void *n, unsigned long k, | - | ||||||||||||
| 209 | int cnt); | - | ||||||||||||
| 210 | void rsaz_512_scatter4(void *tbl, const unsigned long *val, int power); | - | ||||||||||||
| 211 | void rsaz_512_gather4(unsigned long *val, const void *tbl, int power); | - | ||||||||||||
| 212 | - | |||||||||||||
| 213 | void RSAZ_512_mod_exp(unsigned long result[8], | - | ||||||||||||
| 214 | const unsigned long base[8], const unsigned long exponent[8], | - | ||||||||||||
| 215 | const unsigned long m[8], unsigned long k0, const unsigned long RR[8]) | - | ||||||||||||
| 216 | { | - | ||||||||||||
| 217 | unsigned char storage[16 * 8 * 8 + 64 * 2 + 64]; | - | ||||||||||||
| 218 | unsigned char *table = storage + (64 - ((size_t)storage % 64)); | - | ||||||||||||
| 219 | unsigned long *a_inv = (unsigned long *)(table + 16 * 8 * 8); | - | ||||||||||||
| 220 | unsigned long *temp = (unsigned long *)(table + 16 * 8 * 8 + 8 * 8); | - | ||||||||||||
| 221 | unsigned char *p_str = (unsigned char *)exponent; | - | ||||||||||||
| 222 | int index; | - | ||||||||||||
| 223 | unsigned int wvalue; | - | ||||||||||||
| 224 | - | |||||||||||||
| 225 | - | |||||||||||||
| 226 | temp[0] = 0 - m[0]; | - | ||||||||||||
| 227 | temp[1] = ~m[1]; | - | ||||||||||||
| 228 | temp[2] = ~m[2]; | - | ||||||||||||
| 229 | temp[3] = ~m[3]; | - | ||||||||||||
| 230 | temp[4] = ~m[4]; | - | ||||||||||||
| 231 | temp[5] = ~m[5]; | - | ||||||||||||
| 232 | temp[6] = ~m[6]; | - | ||||||||||||
| 233 | temp[7] = ~m[7]; | - | ||||||||||||
| 234 | rsaz_512_scatter4(table, temp, 0); | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | - | |||||||||||||
| 237 | rsaz_512_mul(a_inv, base, RR, m, k0); | - | ||||||||||||
| 238 | rsaz_512_scatter4(table, a_inv, 1); | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | - | |||||||||||||
| 241 | rsaz_512_sqr(temp, a_inv, m, k0, 1); | - | ||||||||||||
| 242 | rsaz_512_scatter4(table, temp, 2); | - | ||||||||||||
| 243 | - | |||||||||||||
| 244 | for (index = 3; index < 16
| 616-8008 | ||||||||||||
| 245 | rsaz_512_mul_scatter4(temp, a_inv, m, k0, table, index); executed 8008 times by 1 test: rsaz_512_mul_scatter4(temp, a_inv, m, k0, table, index);Executed by:
| 8008 | ||||||||||||
| 246 | - | |||||||||||||
| 247 | - | |||||||||||||
| 248 | wvalue = p_str[63]; | - | ||||||||||||
| 249 | - | |||||||||||||
| 250 | rsaz_512_gather4(temp, table, wvalue >> 4); | - | ||||||||||||
| 251 | rsaz_512_sqr(temp, temp, m, k0, 4); | - | ||||||||||||
| 252 | rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue & 0xf); | - | ||||||||||||
| 253 | - | |||||||||||||
| 254 | for (index = 62; index >= 0
| 616-38808 | ||||||||||||
| 255 | wvalue = p_str[index]; | - | ||||||||||||
| 256 | - | |||||||||||||
| 257 | rsaz_512_sqr(temp, temp, m, k0, 4); | - | ||||||||||||
| 258 | rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue >> 4); | - | ||||||||||||
| 259 | - | |||||||||||||
| 260 | rsaz_512_sqr(temp, temp, m, k0, 4); | - | ||||||||||||
| 261 | rsaz_512_mul_gather4(temp, temp, table, m, k0, wvalue & 0x0f); | - | ||||||||||||
| 262 | } executed 38808 times by 1 test: end of blockExecuted by:
| 38808 | ||||||||||||
| 263 | - | |||||||||||||
| 264 | - | |||||||||||||
| 265 | rsaz_512_mul_by_one(result, temp, m, k0); | - | ||||||||||||
| 266 | - | |||||||||||||
| 267 | OPENSSL_cleanse(storage, sizeof(storage)); | - | ||||||||||||
| 268 | } executed 616 times by 1 test: end of blockExecuted by:
| 616 | ||||||||||||
| Switch to Source code | Preprocessed file |