** A single step of the Keccak mixing function for a 1600-bit state */
| 1473 | ** A single step of the Keccak mixing function for a 1600-bit state |
| 1474 | */ |
| 1475 | static void KeccakF1600Step(SHA3Context *p){ |
| 1476 | int i; |
| 1477 | u64 b0, b1, b2, b3, b4; |
| 1478 | u64 c0, c1, c2, c3, c4; |
| 1479 | u64 d0, d1, d2, d3, d4; |
| 1480 | static const u64 RC[] = { |
| 1481 | 0x0000000000000001ULL, 0x0000000000008082ULL, |
| 1482 | 0x800000000000808aULL, 0x8000000080008000ULL, |
| 1483 | 0x000000000000808bULL, 0x0000000080000001ULL, |
| 1484 | 0x8000000080008081ULL, 0x8000000000008009ULL, |
| 1485 | 0x000000000000008aULL, 0x0000000000000088ULL, |
| 1486 | 0x0000000080008009ULL, 0x000000008000000aULL, |
| 1487 | 0x000000008000808bULL, 0x800000000000008bULL, |
| 1488 | 0x8000000000008089ULL, 0x8000000000008003ULL, |
| 1489 | 0x8000000000008002ULL, 0x8000000000000080ULL, |
| 1490 | 0x000000000000800aULL, 0x800000008000000aULL, |
| 1491 | 0x8000000080008081ULL, 0x8000000000008080ULL, |
| 1492 | 0x0000000080000001ULL, 0x8000000080008008ULL |
| 1493 | }; |
| 1494 | # define a00 (p->u.s[0]) |
| 1495 | # define a01 (p->u.s[1]) |
| 1496 | # define a02 (p->u.s[2]) |
| 1497 | # define a03 (p->u.s[3]) |
| 1498 | # define a04 (p->u.s[4]) |
| 1499 | # define a10 (p->u.s[5]) |
| 1500 | # define a11 (p->u.s[6]) |
| 1501 | # define a12 (p->u.s[7]) |
| 1502 | # define a13 (p->u.s[8]) |
| 1503 | # define a14 (p->u.s[9]) |
| 1504 | # define a20 (p->u.s[10]) |
| 1505 | # define a21 (p->u.s[11]) |
| 1506 | # define a22 (p->u.s[12]) |
| 1507 | # define a23 (p->u.s[13]) |
| 1508 | # define a24 (p->u.s[14]) |
| 1509 | # define a30 (p->u.s[15]) |
| 1510 | # define a31 (p->u.s[16]) |
| 1511 | # define a32 (p->u.s[17]) |
| 1512 | # define a33 (p->u.s[18]) |
| 1513 | # define a34 (p->u.s[19]) |
| 1514 | # define a40 (p->u.s[20]) |
| 1515 | # define a41 (p->u.s[21]) |
| 1516 | # define a42 (p->u.s[22]) |
| 1517 | # define a43 (p->u.s[23]) |
| 1518 | # define a44 (p->u.s[24]) |
| 1519 | # define ROL64(a,x) ((a<<x)|(a>>(64-x))) |
| 1520 | |
| 1521 | for(i=0; i<24; i+=4){ |
| 1522 | c0 = a00^a10^a20^a30^a40; |
| 1523 | c1 = a01^a11^a21^a31^a41; |
| 1524 | c2 = a02^a12^a22^a32^a42; |
| 1525 | c3 = a03^a13^a23^a33^a43; |
| 1526 | c4 = a04^a14^a24^a34^a44; |
| 1527 | d0 = c4^ROL64(c1, 1); |
| 1528 | d1 = c0^ROL64(c2, 1); |
| 1529 | d2 = c1^ROL64(c3, 1); |
| 1530 | d3 = c2^ROL64(c4, 1); |
| 1531 | d4 = c3^ROL64(c0, 1); |
| 1532 |