| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#include <stdint.h> |
| 16 |
typedef unsigned char fiat_poly1305_uint1; |
| 17 |
typedef signed char fiat_poly1305_int1; |
| 18 |
#if defined(__GNUC__) || defined(__clang__) |
| 19 |
# define FIAT_POLY1305_FIAT_INLINE __inline__ |
| 20 |
#else |
| 21 |
# define FIAT_POLY1305_FIAT_INLINE |
| 22 |
#endif |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
typedef uint32_t fiat_poly1305_loose_field_element[5]; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
typedef uint32_t fiat_poly1305_tight_field_element[5]; |
| 31 |
|
| 32 |
#if (-1 & 3) != 3 |
| 33 |
#error "This code only works on a two's complement system" |
| 34 |
#endif |
| 35 |
|
| 36 |
#if !defined(FIAT_POLY1305_NO_ASM) && (defined(__GNUC__) || defined(__clang__)) |
| 37 |
static __inline__ uint32_t fiat_poly1305_value_barrier_u32(uint32_t a) { |
| 38 |
__asm__("" : "+r"(a) : ); |
| 39 |
return a; |
| 40 |
} |
| 41 |
#else |
| 42 |
# define fiat_poly1305_value_barrier_u32(x) (x) |
| 43 |
#endif |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
6⌋ |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_addcarryx_u26(uint32_t* out1, fiat_poly1305_uint1* out2, fiat_poly1305_uint1 arg1, uint32_t arg2, uint32_t arg3) { |
| 62 |
uint32_t x1; |
| 63 |
uint32_t x2; |
| 64 |
fiat_poly1305_uint1 x3; |
| 65 |
x1 = ((arg1 + arg2) + arg3); |
| 66 |
x2 = (x1 & UINT32_C(0x3ffffff)); |
| 67 |
x3 = (fiat_poly1305_uint1)(x1 >> 26); |
| 68 |
*out1 = x2; |
| 69 |
*out2 = x3; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
6⌋ |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_subborrowx_u26(uint32_t* out1, fiat_poly1305_uint1* out2, fiat_poly1305_uint1 arg1, uint32_t arg2, uint32_t arg3) { |
| 88 |
int32_t x1; |
| 89 |
fiat_poly1305_int1 x2; |
| 90 |
uint32_t x3; |
| 91 |
x1 = ((int32_t)(arg2 - arg1) - (int32_t)arg3); |
| 92 |
x2 = (fiat_poly1305_int1)(x1 >> 26); |
| 93 |
x3 = (x1 & UINT32_C(0x3ffffff)); |
| 94 |
*out1 = x3; |
| 95 |
*out2 = (fiat_poly1305_uint1)(0x0 - x2); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_cmovznz_u32(uint32_t* out1, fiat_poly1305_uint1 arg1, uint32_t arg2, uint32_t arg3) { |
| 112 |
fiat_poly1305_uint1 x1; |
| 113 |
uint32_t x2; |
| 114 |
uint32_t x3; |
| 115 |
x1 = (!(!arg1)); |
| 116 |
x2 = ((fiat_poly1305_int1)(0x0 - x1) & UINT32_C(0xffffffff)); |
| 117 |
x3 = ((fiat_poly1305_value_barrier_u32(x2) & arg3) | (fiat_poly1305_value_barrier_u32((~x2)) & arg2)); |
| 118 |
*out1 = x3; |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_carry_mul(fiat_poly1305_tight_field_element out1, const fiat_poly1305_loose_field_element arg1, const fiat_poly1305_loose_field_element arg2) { |
| 129 |
uint64_t x1; |
| 130 |
uint64_t x2; |
| 131 |
uint64_t x3; |
| 132 |
uint64_t x4; |
| 133 |
uint64_t x5; |
| 134 |
uint64_t x6; |
| 135 |
uint64_t x7; |
| 136 |
uint64_t x8; |
| 137 |
uint64_t x9; |
| 138 |
uint64_t x10; |
| 139 |
uint64_t x11; |
| 140 |
uint64_t x12; |
| 141 |
uint64_t x13; |
| 142 |
uint64_t x14; |
| 143 |
uint64_t x15; |
| 144 |
uint64_t x16; |
| 145 |
uint64_t x17; |
| 146 |
uint64_t x18; |
| 147 |
uint64_t x19; |
| 148 |
uint64_t x20; |
| 149 |
uint64_t x21; |
| 150 |
uint64_t x22; |
| 151 |
uint64_t x23; |
| 152 |
uint64_t x24; |
| 153 |
uint64_t x25; |
| 154 |
uint64_t x26; |
| 155 |
uint64_t x27; |
| 156 |
uint32_t x28; |
| 157 |
uint64_t x29; |
| 158 |
uint64_t x30; |
| 159 |
uint64_t x31; |
| 160 |
uint64_t x32; |
| 161 |
uint64_t x33; |
| 162 |
uint64_t x34; |
| 163 |
uint32_t x35; |
| 164 |
uint64_t x36; |
| 165 |
uint64_t x37; |
| 166 |
uint32_t x38; |
| 167 |
uint64_t x39; |
| 168 |
uint64_t x40; |
| 169 |
uint32_t x41; |
| 170 |
uint64_t x42; |
| 171 |
uint32_t x43; |
| 172 |
uint32_t x44; |
| 173 |
uint64_t x45; |
| 174 |
uint64_t x46; |
| 175 |
uint32_t x47; |
| 176 |
uint32_t x48; |
| 177 |
uint32_t x49; |
| 178 |
fiat_poly1305_uint1 x50; |
| 179 |
uint32_t x51; |
| 180 |
uint32_t x52; |
| 181 |
x1 = ((uint64_t)(arg1[4]) * ((arg2[4]) * 0x5)); |
| 182 |
x2 = ((uint64_t)(arg1[4]) * ((arg2[3]) * 0x5)); |
| 183 |
x3 = ((uint64_t)(arg1[4]) * ((arg2[2]) * 0x5)); |
| 184 |
x4 = ((uint64_t)(arg1[4]) * ((arg2[1]) * 0x5)); |
| 185 |
x5 = ((uint64_t)(arg1[3]) * ((arg2[4]) * 0x5)); |
| 186 |
x6 = ((uint64_t)(arg1[3]) * ((arg2[3]) * 0x5)); |
| 187 |
x7 = ((uint64_t)(arg1[3]) * ((arg2[2]) * 0x5)); |
| 188 |
x8 = ((uint64_t)(arg1[2]) * ((arg2[4]) * 0x5)); |
| 189 |
x9 = ((uint64_t)(arg1[2]) * ((arg2[3]) * 0x5)); |
| 190 |
x10 = ((uint64_t)(arg1[1]) * ((arg2[4]) * 0x5)); |
| 191 |
x11 = ((uint64_t)(arg1[4]) * (arg2[0])); |
| 192 |
x12 = ((uint64_t)(arg1[3]) * (arg2[1])); |
| 193 |
x13 = ((uint64_t)(arg1[3]) * (arg2[0])); |
| 194 |
x14 = ((uint64_t)(arg1[2]) * (arg2[2])); |
| 195 |
x15 = ((uint64_t)(arg1[2]) * (arg2[1])); |
| 196 |
x16 = ((uint64_t)(arg1[2]) * (arg2[0])); |
| 197 |
x17 = ((uint64_t)(arg1[1]) * (arg2[3])); |
| 198 |
x18 = ((uint64_t)(arg1[1]) * (arg2[2])); |
| 199 |
x19 = ((uint64_t)(arg1[1]) * (arg2[1])); |
| 200 |
x20 = ((uint64_t)(arg1[1]) * (arg2[0])); |
| 201 |
x21 = ((uint64_t)(arg1[0]) * (arg2[4])); |
| 202 |
x22 = ((uint64_t)(arg1[0]) * (arg2[3])); |
| 203 |
x23 = ((uint64_t)(arg1[0]) * (arg2[2])); |
| 204 |
x24 = ((uint64_t)(arg1[0]) * (arg2[1])); |
| 205 |
x25 = ((uint64_t)(arg1[0]) * (arg2[0])); |
| 206 |
x26 = (x25 + (x10 + (x9 + (x7 + x4)))); |
| 207 |
x27 = (x26 >> 26); |
| 208 |
x28 = (uint32_t)(x26 & UINT32_C(0x3ffffff)); |
| 209 |
x29 = (x21 + (x17 + (x14 + (x12 + x11)))); |
| 210 |
x30 = (x22 + (x18 + (x15 + (x13 + x1)))); |
| 211 |
x31 = (x23 + (x19 + (x16 + (x5 + x2)))); |
| 212 |
x32 = (x24 + (x20 + (x8 + (x6 + x3)))); |
| 213 |
x33 = (x27 + x32); |
| 214 |
x34 = (x33 >> 26); |
| 215 |
x35 = (uint32_t)(x33 & UINT32_C(0x3ffffff)); |
| 216 |
x36 = (x34 + x31); |
| 217 |
x37 = (x36 >> 26); |
| 218 |
x38 = (uint32_t)(x36 & UINT32_C(0x3ffffff)); |
| 219 |
x39 = (x37 + x30); |
| 220 |
x40 = (x39 >> 26); |
| 221 |
x41 = (uint32_t)(x39 & UINT32_C(0x3ffffff)); |
| 222 |
x42 = (x40 + x29); |
| 223 |
x43 = (uint32_t)(x42 >> 26); |
| 224 |
x44 = (uint32_t)(x42 & UINT32_C(0x3ffffff)); |
| 225 |
x45 = ((uint64_t)x43 * 0x5); |
| 226 |
x46 = (x28 + x45); |
| 227 |
x47 = (uint32_t)(x46 >> 26); |
| 228 |
x48 = (uint32_t)(x46 & UINT32_C(0x3ffffff)); |
| 229 |
x49 = (x47 + x35); |
| 230 |
x50 = (fiat_poly1305_uint1)(x49 >> 26); |
| 231 |
x51 = (x49 & UINT32_C(0x3ffffff)); |
| 232 |
x52 = (x50 + x38); |
| 233 |
out1[0] = x48; |
| 234 |
out1[1] = x51; |
| 235 |
out1[2] = x52; |
| 236 |
out1[3] = x41; |
| 237 |
out1[4] = x44; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_carry_square(fiat_poly1305_tight_field_element out1, const fiat_poly1305_loose_field_element arg1) { |
| 248 |
uint32_t x1; |
| 249 |
uint32_t x2; |
| 250 |
uint32_t x3; |
| 251 |
uint32_t x4; |
| 252 |
uint32_t x5; |
| 253 |
uint32_t x6; |
| 254 |
uint32_t x7; |
| 255 |
uint32_t x8; |
| 256 |
uint64_t x9; |
| 257 |
uint64_t x10; |
| 258 |
uint64_t x11; |
| 259 |
uint64_t x12; |
| 260 |
uint64_t x13; |
| 261 |
uint64_t x14; |
| 262 |
uint64_t x15; |
| 263 |
uint64_t x16; |
| 264 |
uint64_t x17; |
| 265 |
uint64_t x18; |
| 266 |
uint64_t x19; |
| 267 |
uint64_t x20; |
| 268 |
uint64_t x21; |
| 269 |
uint64_t x22; |
| 270 |
uint64_t x23; |
| 271 |
uint64_t x24; |
| 272 |
uint64_t x25; |
| 273 |
uint32_t x26; |
| 274 |
uint64_t x27; |
| 275 |
uint64_t x28; |
| 276 |
uint64_t x29; |
| 277 |
uint64_t x30; |
| 278 |
uint64_t x31; |
| 279 |
uint64_t x32; |
| 280 |
uint32_t x33; |
| 281 |
uint64_t x34; |
| 282 |
uint64_t x35; |
| 283 |
uint32_t x36; |
| 284 |
uint64_t x37; |
| 285 |
uint64_t x38; |
| 286 |
uint32_t x39; |
| 287 |
uint64_t x40; |
| 288 |
uint32_t x41; |
| 289 |
uint32_t x42; |
| 290 |
uint64_t x43; |
| 291 |
uint64_t x44; |
| 292 |
uint32_t x45; |
| 293 |
uint32_t x46; |
| 294 |
uint32_t x47; |
| 295 |
fiat_poly1305_uint1 x48; |
| 296 |
uint32_t x49; |
| 297 |
uint32_t x50; |
| 298 |
x1 = ((arg1[4]) * 0x5); |
| 299 |
x2 = (x1 * 0x2); |
| 300 |
x3 = ((arg1[4]) * 0x2); |
| 301 |
x4 = ((arg1[3]) * 0x5); |
| 302 |
x5 = (x4 * 0x2); |
| 303 |
x6 = ((arg1[3]) * 0x2); |
| 304 |
x7 = ((arg1[2]) * 0x2); |
| 305 |
x8 = ((arg1[1]) * 0x2); |
| 306 |
x9 = ((uint64_t)(arg1[4]) * x1); |
| 307 |
x10 = ((uint64_t)(arg1[3]) * x2); |
| 308 |
x11 = ((uint64_t)(arg1[3]) * x4); |
| 309 |
x12 = ((uint64_t)(arg1[2]) * x2); |
| 310 |
x13 = ((uint64_t)(arg1[2]) * x5); |
| 311 |
x14 = ((uint64_t)(arg1[2]) * (arg1[2])); |
| 312 |
x15 = ((uint64_t)(arg1[1]) * x2); |
| 313 |
x16 = ((uint64_t)(arg1[1]) * x6); |
| 314 |
x17 = ((uint64_t)(arg1[1]) * x7); |
| 315 |
x18 = ((uint64_t)(arg1[1]) * (arg1[1])); |
| 316 |
x19 = ((uint64_t)(arg1[0]) * x3); |
| 317 |
x20 = ((uint64_t)(arg1[0]) * x6); |
| 318 |
x21 = ((uint64_t)(arg1[0]) * x7); |
| 319 |
x22 = ((uint64_t)(arg1[0]) * x8); |
| 320 |
x23 = ((uint64_t)(arg1[0]) * (arg1[0])); |
| 321 |
x24 = (x23 + (x15 + x13)); |
| 322 |
x25 = (x24 >> 26); |
| 323 |
x26 = (uint32_t)(x24 & UINT32_C(0x3ffffff)); |
| 324 |
x27 = (x19 + (x16 + x14)); |
| 325 |
x28 = (x20 + (x17 + x9)); |
| 326 |
x29 = (x21 + (x18 + x10)); |
| 327 |
x30 = (x22 + (x12 + x11)); |
| 328 |
x31 = (x25 + x30); |
| 329 |
x32 = (x31 >> 26); |
| 330 |
x33 = (uint32_t)(x31 & UINT32_C(0x3ffffff)); |
| 331 |
x34 = (x32 + x29); |
| 332 |
x35 = (x34 >> 26); |
| 333 |
x36 = (uint32_t)(x34 & UINT32_C(0x3ffffff)); |
| 334 |
x37 = (x35 + x28); |
| 335 |
x38 = (x37 >> 26); |
| 336 |
x39 = (uint32_t)(x37 & UINT32_C(0x3ffffff)); |
| 337 |
x40 = (x38 + x27); |
| 338 |
x41 = (uint32_t)(x40 >> 26); |
| 339 |
x42 = (uint32_t)(x40 & UINT32_C(0x3ffffff)); |
| 340 |
x43 = ((uint64_t)x41 * 0x5); |
| 341 |
x44 = (x26 + x43); |
| 342 |
x45 = (uint32_t)(x44 >> 26); |
| 343 |
x46 = (uint32_t)(x44 & UINT32_C(0x3ffffff)); |
| 344 |
x47 = (x45 + x33); |
| 345 |
x48 = (fiat_poly1305_uint1)(x47 >> 26); |
| 346 |
x49 = (x47 & UINT32_C(0x3ffffff)); |
| 347 |
x50 = (x48 + x36); |
| 348 |
out1[0] = x46; |
| 349 |
out1[1] = x49; |
| 350 |
out1[2] = x50; |
| 351 |
out1[3] = x39; |
| 352 |
out1[4] = x42; |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_carry(fiat_poly1305_tight_field_element out1, const fiat_poly1305_loose_field_element arg1) { |
| 363 |
uint32_t x1; |
| 364 |
uint32_t x2; |
| 365 |
uint32_t x3; |
| 366 |
uint32_t x4; |
| 367 |
uint32_t x5; |
| 368 |
uint32_t x6; |
| 369 |
uint32_t x7; |
| 370 |
uint32_t x8; |
| 371 |
uint32_t x9; |
| 372 |
uint32_t x10; |
| 373 |
uint32_t x11; |
| 374 |
uint32_t x12; |
| 375 |
x1 = (arg1[0]); |
| 376 |
x2 = ((x1 >> 26) + (arg1[1])); |
| 377 |
x3 = ((x2 >> 26) + (arg1[2])); |
| 378 |
x4 = ((x3 >> 26) + (arg1[3])); |
| 379 |
x5 = ((x4 >> 26) + (arg1[4])); |
| 380 |
x6 = ((x1 & UINT32_C(0x3ffffff)) + ((x5 >> 26) * 0x5)); |
| 381 |
x7 = ((fiat_poly1305_uint1)(x6 >> 26) + (x2 & UINT32_C(0x3ffffff))); |
| 382 |
x8 = (x6 & UINT32_C(0x3ffffff)); |
| 383 |
x9 = (x7 & UINT32_C(0x3ffffff)); |
| 384 |
x10 = ((fiat_poly1305_uint1)(x7 >> 26) + (x3 & UINT32_C(0x3ffffff))); |
| 385 |
x11 = (x4 & UINT32_C(0x3ffffff)); |
| 386 |
x12 = (x5 & UINT32_C(0x3ffffff)); |
| 387 |
out1[0] = x8; |
| 388 |
out1[1] = x9; |
| 389 |
out1[2] = x10; |
| 390 |
out1[3] = x11; |
| 391 |
out1[4] = x12; |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_add(fiat_poly1305_loose_field_element out1, const fiat_poly1305_tight_field_element arg1, const fiat_poly1305_tight_field_element arg2) { |
| 402 |
uint32_t x1; |
| 403 |
uint32_t x2; |
| 404 |
uint32_t x3; |
| 405 |
uint32_t x4; |
| 406 |
uint32_t x5; |
| 407 |
x1 = ((arg1[0]) + (arg2[0])); |
| 408 |
x2 = ((arg1[1]) + (arg2[1])); |
| 409 |
x3 = ((arg1[2]) + (arg2[2])); |
| 410 |
x4 = ((arg1[3]) + (arg2[3])); |
| 411 |
x5 = ((arg1[4]) + (arg2[4])); |
| 412 |
out1[0] = x1; |
| 413 |
out1[1] = x2; |
| 414 |
out1[2] = x3; |
| 415 |
out1[3] = x4; |
| 416 |
out1[4] = x5; |
| 417 |
} |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_sub(fiat_poly1305_loose_field_element out1, const fiat_poly1305_tight_field_element arg1, const fiat_poly1305_tight_field_element arg2) { |
| 427 |
uint32_t x1; |
| 428 |
uint32_t x2; |
| 429 |
uint32_t x3; |
| 430 |
uint32_t x4; |
| 431 |
uint32_t x5; |
| 432 |
x1 = ((UINT32_C(0x7fffff6) + (arg1[0])) - (arg2[0])); |
| 433 |
x2 = ((UINT32_C(0x7fffffe) + (arg1[1])) - (arg2[1])); |
| 434 |
x3 = ((UINT32_C(0x7fffffe) + (arg1[2])) - (arg2[2])); |
| 435 |
x4 = ((UINT32_C(0x7fffffe) + (arg1[3])) - (arg2[3])); |
| 436 |
x5 = ((UINT32_C(0x7fffffe) + (arg1[4])) - (arg2[4])); |
| 437 |
out1[0] = x1; |
| 438 |
out1[1] = x2; |
| 439 |
out1[2] = x3; |
| 440 |
out1[3] = x4; |
| 441 |
out1[4] = x5; |
| 442 |
} |
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_opp(fiat_poly1305_loose_field_element out1, const fiat_poly1305_tight_field_element arg1) { |
| 452 |
uint32_t x1; |
| 453 |
uint32_t x2; |
| 454 |
uint32_t x3; |
| 455 |
uint32_t x4; |
| 456 |
uint32_t x5; |
| 457 |
x1 = (UINT32_C(0x7fffff6) - (arg1[0])); |
| 458 |
x2 = (UINT32_C(0x7fffffe) - (arg1[1])); |
| 459 |
x3 = (UINT32_C(0x7fffffe) - (arg1[2])); |
| 460 |
x4 = (UINT32_C(0x7fffffe) - (arg1[3])); |
| 461 |
x5 = (UINT32_C(0x7fffffe) - (arg1[4])); |
| 462 |
out1[0] = x1; |
| 463 |
out1[1] = x2; |
| 464 |
out1[2] = x3; |
| 465 |
out1[3] = x4; |
| 466 |
out1[4] = x5; |
| 467 |
} |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_selectznz(uint32_t out1[5], fiat_poly1305_uint1 arg1, const uint32_t arg2[5], const uint32_t arg3[5]) { |
| 483 |
uint32_t x1; |
| 484 |
uint32_t x2; |
| 485 |
uint32_t x3; |
| 486 |
uint32_t x4; |
| 487 |
uint32_t x5; |
| 488 |
fiat_poly1305_cmovznz_u32(&x1, arg1, (arg2[0]), (arg3[0])); |
| 489 |
fiat_poly1305_cmovznz_u32(&x2, arg1, (arg2[1]), (arg3[1])); |
| 490 |
fiat_poly1305_cmovznz_u32(&x3, arg1, (arg2[2]), (arg3[2])); |
| 491 |
fiat_poly1305_cmovznz_u32(&x4, arg1, (arg2[3]), (arg3[3])); |
| 492 |
fiat_poly1305_cmovznz_u32(&x5, arg1, (arg2[4]), (arg3[4])); |
| 493 |
out1[0] = x1; |
| 494 |
out1[1] = x2; |
| 495 |
out1[2] = x3; |
| 496 |
out1[3] = x4; |
| 497 |
out1[4] = x5; |
| 498 |
} |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
..16] |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_to_bytes(uint8_t out1[17], const fiat_poly1305_tight_field_element arg1) { |
| 510 |
uint32_t x1; |
| 511 |
fiat_poly1305_uint1 x2; |
| 512 |
uint32_t x3; |
| 513 |
fiat_poly1305_uint1 x4; |
| 514 |
uint32_t x5; |
| 515 |
fiat_poly1305_uint1 x6; |
| 516 |
uint32_t x7; |
| 517 |
fiat_poly1305_uint1 x8; |
| 518 |
uint32_t x9; |
| 519 |
fiat_poly1305_uint1 x10; |
| 520 |
uint32_t x11; |
| 521 |
uint32_t x12; |
| 522 |
fiat_poly1305_uint1 x13; |
| 523 |
uint32_t x14; |
| 524 |
fiat_poly1305_uint1 x15; |
| 525 |
uint32_t x16; |
| 526 |
fiat_poly1305_uint1 x17; |
| 527 |
uint32_t x18; |
| 528 |
fiat_poly1305_uint1 x19; |
| 529 |
uint32_t x20; |
| 530 |
fiat_poly1305_uint1 x21; |
| 531 |
uint32_t x22; |
| 532 |
uint32_t x23; |
| 533 |
uint32_t x24; |
| 534 |
uint8_t x25; |
| 535 |
uint32_t x26; |
| 536 |
uint8_t x27; |
| 537 |
uint32_t x28; |
| 538 |
uint8_t x29; |
| 539 |
uint8_t x30; |
| 540 |
uint32_t x31; |
| 541 |
uint8_t x32; |
| 542 |
uint32_t x33; |
| 543 |
uint8_t x34; |
| 544 |
uint32_t x35; |
| 545 |
uint8_t x36; |
| 546 |
uint8_t x37; |
| 547 |
uint32_t x38; |
| 548 |
uint8_t x39; |
| 549 |
uint32_t x40; |
| 550 |
uint8_t x41; |
| 551 |
uint32_t x42; |
| 552 |
uint8_t x43; |
| 553 |
uint8_t x44; |
| 554 |
uint32_t x45; |
| 555 |
uint8_t x46; |
| 556 |
uint32_t x47; |
| 557 |
uint8_t x48; |
| 558 |
uint32_t x49; |
| 559 |
uint8_t x50; |
| 560 |
uint8_t x51; |
| 561 |
uint8_t x52; |
| 562 |
uint32_t x53; |
| 563 |
uint8_t x54; |
| 564 |
uint32_t x55; |
| 565 |
uint8_t x56; |
| 566 |
uint8_t x57; |
| 567 |
fiat_poly1305_subborrowx_u26(&x1, &x2, 0x0, (arg1[0]), UINT32_C(0x3fffffb)); |
| 568 |
fiat_poly1305_subborrowx_u26(&x3, &x4, x2, (arg1[1]), UINT32_C(0x3ffffff)); |
| 569 |
fiat_poly1305_subborrowx_u26(&x5, &x6, x4, (arg1[2]), UINT32_C(0x3ffffff)); |
| 570 |
fiat_poly1305_subborrowx_u26(&x7, &x8, x6, (arg1[3]), UINT32_C(0x3ffffff)); |
| 571 |
fiat_poly1305_subborrowx_u26(&x9, &x10, x8, (arg1[4]), UINT32_C(0x3ffffff)); |
| 572 |
fiat_poly1305_cmovznz_u32(&x11, x10, 0x0, UINT32_C(0xffffffff)); |
| 573 |
fiat_poly1305_addcarryx_u26(&x12, &x13, 0x0, x1, (x11 & UINT32_C(0x3fffffb))); |
| 574 |
fiat_poly1305_addcarryx_u26(&x14, &x15, x13, x3, (x11 & UINT32_C(0x3ffffff))); |
| 575 |
fiat_poly1305_addcarryx_u26(&x16, &x17, x15, x5, (x11 & UINT32_C(0x3ffffff))); |
| 576 |
fiat_poly1305_addcarryx_u26(&x18, &x19, x17, x7, (x11 & UINT32_C(0x3ffffff))); |
| 577 |
fiat_poly1305_addcarryx_u26(&x20, &x21, x19, x9, (x11 & UINT32_C(0x3ffffff))); |
| 578 |
x22 = (x18 << 6); |
| 579 |
x23 = (x16 << 4); |
| 580 |
x24 = (x14 << 2); |
| 581 |
x25 = (uint8_t)(x12 & UINT8_C(0xff)); |
| 582 |
x26 = (x12 >> 8); |
| 583 |
x27 = (uint8_t)(x26 & UINT8_C(0xff)); |
| 584 |
x28 = (x26 >> 8); |
| 585 |
x29 = (uint8_t)(x28 & UINT8_C(0xff)); |
| 586 |
x30 = (uint8_t)(x28 >> 8); |
| 587 |
x31 = (x24 + (uint32_t)x30); |
| 588 |
x32 = (uint8_t)(x31 & UINT8_C(0xff)); |
| 589 |
x33 = (x31 >> 8); |
| 590 |
x34 = (uint8_t)(x33 & UINT8_C(0xff)); |
| 591 |
x35 = (x33 >> 8); |
| 592 |
x36 = (uint8_t)(x35 & UINT8_C(0xff)); |
| 593 |
x37 = (uint8_t)(x35 >> 8); |
| 594 |
x38 = (x23 + (uint32_t)x37); |
| 595 |
x39 = (uint8_t)(x38 & UINT8_C(0xff)); |
| 596 |
x40 = (x38 >> 8); |
| 597 |
x41 = (uint8_t)(x40 & UINT8_C(0xff)); |
| 598 |
x42 = (x40 >> 8); |
| 599 |
x43 = (uint8_t)(x42 & UINT8_C(0xff)); |
| 600 |
x44 = (uint8_t)(x42 >> 8); |
| 601 |
x45 = (x22 + (uint32_t)x44); |
| 602 |
x46 = (uint8_t)(x45 & UINT8_C(0xff)); |
| 603 |
x47 = (x45 >> 8); |
| 604 |
x48 = (uint8_t)(x47 & UINT8_C(0xff)); |
| 605 |
x49 = (x47 >> 8); |
| 606 |
x50 = (uint8_t)(x49 & UINT8_C(0xff)); |
| 607 |
x51 = (uint8_t)(x49 >> 8); |
| 608 |
x52 = (uint8_t)(x20 & UINT8_C(0xff)); |
| 609 |
x53 = (x20 >> 8); |
| 610 |
x54 = (uint8_t)(x53 & UINT8_C(0xff)); |
| 611 |
x55 = (x53 >> 8); |
| 612 |
x56 = (uint8_t)(x55 & UINT8_C(0xff)); |
| 613 |
x57 = (uint8_t)(x55 >> 8); |
| 614 |
out1[0] = x25; |
| 615 |
out1[1] = x27; |
| 616 |
out1[2] = x29; |
| 617 |
out1[3] = x32; |
| 618 |
out1[4] = x34; |
| 619 |
out1[5] = x36; |
| 620 |
out1[6] = x39; |
| 621 |
out1[7] = x41; |
| 622 |
out1[8] = x43; |
| 623 |
out1[9] = x46; |
| 624 |
out1[10] = x48; |
| 625 |
out1[11] = x50; |
| 626 |
out1[12] = x51; |
| 627 |
out1[13] = x52; |
| 628 |
out1[14] = x54; |
| 629 |
out1[15] = x56; |
| 630 |
out1[16] = x57; |
| 631 |
} |
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_from_bytes(fiat_poly1305_tight_field_element out1, const uint8_t arg1[17]) { |
| 643 |
uint32_t x1; |
| 644 |
uint32_t x2; |
| 645 |
uint32_t x3; |
| 646 |
uint8_t x4; |
| 647 |
uint32_t x5; |
| 648 |
uint32_t x6; |
| 649 |
uint32_t x7; |
| 650 |
uint32_t x8; |
| 651 |
uint32_t x9; |
| 652 |
uint32_t x10; |
| 653 |
uint32_t x11; |
| 654 |
uint32_t x12; |
| 655 |
uint32_t x13; |
| 656 |
uint32_t x14; |
| 657 |
uint32_t x15; |
| 658 |
uint32_t x16; |
| 659 |
uint8_t x17; |
| 660 |
uint32_t x18; |
| 661 |
uint32_t x19; |
| 662 |
uint32_t x20; |
| 663 |
uint32_t x21; |
| 664 |
uint8_t x22; |
| 665 |
uint32_t x23; |
| 666 |
uint32_t x24; |
| 667 |
uint32_t x25; |
| 668 |
uint32_t x26; |
| 669 |
uint8_t x27; |
| 670 |
uint32_t x28; |
| 671 |
uint32_t x29; |
| 672 |
uint32_t x30; |
| 673 |
uint32_t x31; |
| 674 |
uint8_t x32; |
| 675 |
uint32_t x33; |
| 676 |
uint32_t x34; |
| 677 |
uint32_t x35; |
| 678 |
uint32_t x36; |
| 679 |
uint32_t x37; |
| 680 |
uint32_t x38; |
| 681 |
x1 = ((uint32_t)(arg1[16]) << 24); |
| 682 |
x2 = ((uint32_t)(arg1[15]) << 16); |
| 683 |
x3 = ((uint32_t)(arg1[14]) << 8); |
| 684 |
x4 = (arg1[13]); |
| 685 |
x5 = ((uint32_t)(arg1[12]) << 18); |
| 686 |
x6 = ((uint32_t)(arg1[11]) << 10); |
| 687 |
x7 = ((uint32_t)(arg1[10]) << 2); |
| 688 |
x8 = ((uint32_t)(arg1[9]) << 20); |
| 689 |
x9 = ((uint32_t)(arg1[8]) << 12); |
| 690 |
x10 = ((uint32_t)(arg1[7]) << 4); |
| 691 |
x11 = ((uint32_t)(arg1[6]) << 22); |
| 692 |
x12 = ((uint32_t)(arg1[5]) << 14); |
| 693 |
x13 = ((uint32_t)(arg1[4]) << 6); |
| 694 |
x14 = ((uint32_t)(arg1[3]) << 24); |
| 695 |
x15 = ((uint32_t)(arg1[2]) << 16); |
| 696 |
x16 = ((uint32_t)(arg1[1]) << 8); |
| 697 |
x17 = (arg1[0]); |
| 698 |
x18 = (x16 + (uint32_t)x17); |
| 699 |
x19 = (x15 + x18); |
| 700 |
x20 = (x14 + x19); |
| 701 |
x21 = (x20 & UINT32_C(0x3ffffff)); |
| 702 |
x22 = (uint8_t)(x20 >> 26); |
| 703 |
x23 = (x13 + (uint32_t)x22); |
| 704 |
x24 = (x12 + x23); |
| 705 |
x25 = (x11 + x24); |
| 706 |
x26 = (x25 & UINT32_C(0x3ffffff)); |
| 707 |
x27 = (uint8_t)(x25 >> 26); |
| 708 |
x28 = (x10 + (uint32_t)x27); |
| 709 |
x29 = (x9 + x28); |
| 710 |
x30 = (x8 + x29); |
| 711 |
x31 = (x30 & UINT32_C(0x3ffffff)); |
| 712 |
x32 = (uint8_t)(x30 >> 26); |
| 713 |
x33 = (x7 + (uint32_t)x32); |
| 714 |
x34 = (x6 + x33); |
| 715 |
x35 = (x5 + x34); |
| 716 |
x36 = (x3 + (uint32_t)x4); |
| 717 |
x37 = (x2 + x36); |
| 718 |
x38 = (x1 + x37); |
| 719 |
out1[0] = x21; |
| 720 |
out1[1] = x26; |
| 721 |
out1[2] = x31; |
| 722 |
out1[3] = x35; |
| 723 |
out1[4] = x38; |
| 724 |
} |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
static FIAT_POLY1305_FIAT_INLINE void fiat_poly1305_relax(fiat_poly1305_loose_field_element out1, const fiat_poly1305_tight_field_element arg1) { |
| 734 |
uint32_t x1; |
| 735 |
uint32_t x2; |
| 736 |
uint32_t x3; |
| 737 |
uint32_t x4; |
| 738 |
uint32_t x5; |
| 739 |
x1 = (arg1[0]); |
| 740 |
x2 = (arg1[1]); |
| 741 |
x3 = (arg1[2]); |
| 742 |
x4 = (arg1[3]); |
| 743 |
x5 = (arg1[4]); |
| 744 |
out1[0] = x1; |
| 745 |
out1[1] = x2; |
| 746 |
out1[2] = x3; |
| 747 |
out1[3] = x4; |
| 748 |
out1[4] = x5; |
| 749 |
} |