Path: blob/linux/scryptjane/scrypt-jane-mix_chacha.h
1201 views
#if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_CHACHA_INCLUDED)12#undef SCRYPT_MIX3#define SCRYPT_MIX "ChaCha20/8 Ref"45#undef SCRYPT_CHACHA_INCLUDED6#define SCRYPT_CHACHA_INCLUDED7#define SCRYPT_CHACHA_BASIC89static void10chacha_core_basic(uint32_t state[16]) {11size_t rounds = 8;12uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t;1314x0 = state[0];15x1 = state[1];16x2 = state[2];17x3 = state[3];18x4 = state[4];19x5 = state[5];20x6 = state[6];21x7 = state[7];22x8 = state[8];23x9 = state[9];24x10 = state[10];25x11 = state[11];26x12 = state[12];27x13 = state[13];28x14 = state[14];29x15 = state[15];3031#define quarter(a,b,c,d) \32a += b; t = d^a; d = ROTL32(t,16); \33c += d; t = b^c; b = ROTL32(t,12); \34a += b; t = d^a; d = ROTL32(t, 8); \35c += d; t = b^c; b = ROTL32(t, 7);3637for (; rounds; rounds -= 2) {38quarter( x0, x4, x8,x12)39quarter( x1, x5, x9,x13)40quarter( x2, x6,x10,x14)41quarter( x3, x7,x11,x15)42quarter( x0, x5,x10,x15)43quarter( x1, x6,x11,x12)44quarter( x2, x7, x8,x13)45quarter( x3, x4, x9,x14)46}4748state[0] += x0;49state[1] += x1;50state[2] += x2;51state[3] += x3;52state[4] += x4;53state[5] += x5;54state[6] += x6;55state[7] += x7;56state[8] += x8;57state[9] += x9;58state[10] += x10;59state[11] += x11;60state[12] += x12;61state[13] += x13;62state[14] += x14;63state[15] += x15;6465#undef quarter66}6768#endif6970