You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2688 lines
72 KiB

  1. package skein
  2. import (
  3. "encoding/binary"
  4. "unsafe"
  5. )
  6. type CtxtHeader struct {
  7. hashBitLen uint
  8. bCnt uint
  9. T [2]uint64
  10. }
  11. type Skein1024 struct {
  12. h CtxtHeader
  13. X [SKEIN1024_STATE_WORDS]uint64
  14. b [SKEIN1024_BLOCK_BYTES]byte
  15. }
  16. func (s *Skein1024) Init(size uint) {
  17. s.h.hashBitLen = size
  18. switch size {
  19. case 1024:
  20. copy(s.X[:], SKEIN1024_IV_1024)
  21. //TODO: prebuilds for other sizes.
  22. default:
  23. //Build the IV values
  24. }
  25. s.h.T[0] = 0
  26. s.h.T[1] = (1 << 62) | (48 << 56)
  27. s.h.bCnt=0
  28. }
  29. func (s *Skein1024) Update(msg []byte) {
  30. n := uint(0)
  31. if uint(len(msg)) + s.h.bCnt > SKEIN1024_BLOCK_BYTES {
  32. if s.h.bCnt > 0 {
  33. n = SKEIN1024_BLOCK_BYTES - s.h.bCnt
  34. if n > 0 {
  35. copy(s.b[s.h.bCnt:],msg)
  36. msg = msg[n:]
  37. s.h.bCnt += n
  38. }
  39. if s.h.bCnt != SKEIN1024_BLOCK_BYTES {
  40. panic("ASSERTION FAILURE")
  41. }
  42. s.ProcessBlock(s.b[:],make([]uint64, SKEIN1024_STATE_WORDS+4), 1, SKEIN1024_BLOCK_BYTES)
  43. s.h.bCnt = 0
  44. }
  45. if uint(len(msg)) > SKEIN1024_BLOCK_BYTES {
  46. n = uint(len(msg) - 1) / SKEIN1024_BLOCK_BYTES
  47. s.ProcessBlock(msg,make([]uint64, SKEIN1024_STATE_WORDS+4),n,SKEIN1024_BLOCK_BYTES)
  48. msg = msg[n * SKEIN1024_BLOCK_BYTES:]
  49. }
  50. //ASSERT: ss.h.bCnt == 0
  51. }
  52. if len(msg) > 0 {
  53. copy(s.b[s.h.bCnt:], msg)
  54. s.h.bCnt += uint(len(msg))
  55. }
  56. }
  57. func (s *Skein1024) Final(outp []byte) {
  58. var n, byteCnt uint
  59. X := make([]uint64, SKEIN1024_STATE_WORDS)
  60. s.h.T[1] |= (1 << 63)
  61. if s.h.bCnt < SKEIN1024_BLOCK_BYTES {
  62. for j := s.h.bCnt; j < SKEIN1024_BLOCK_BYTES; j++ {
  63. s.b[j] = 0
  64. }
  65. }
  66. kw := make([]uint64, SKEIN1024_STATE_WORDS+4)
  67. s.ProcessBlock(s.b[:],kw,1,s.h.bCnt)
  68. byteCnt = (s.h.hashBitLen + 7) >> 3
  69. for i, _ := range s.b {s.b[i] = 0}
  70. copy(X, s.X[:])
  71. for i := uint(0); i*SKEIN1024_BLOCK_BYTES < byteCnt; i++ {
  72. binary.LittleEndian.PutUint64(s.b[:], uint64(i))
  73. s.h.T[0] = 0
  74. s.h.T[1] = (uint64(1) << 62 | uint64(63) << 56 | uint64(1) << 63)
  75. s.h.bCnt=0
  76. //ZERO OUT KW ARRAY
  77. s.ProcessBlock(s.b[:],kw,1,8)
  78. n = byteCnt - i*SKEIN1024_BLOCK_BYTES /* number of output bytes left to go */
  79. if n >= SKEIN1024_BLOCK_BYTES {
  80. n = SKEIN1024_BLOCK_BYTES
  81. }
  82. //copy(outp[i*SKEIN1024_BLOCK_BYTES:],s.X)
  83. CopyInt64ToBytes(outp[i*SKEIN1024_BLOCK_BYTES:], s.X[:])
  84. //Maybe unecessary?
  85. //Skein_Show_Final(1024,&s.h,n,hashVal+i*SKEIN1024_BLOCK_BYTES)
  86. copy(s.X[:],X)
  87. }
  88. }
  89. func CopyInt64ToBytes(dest []byte, src []uint64) {
  90. up := (*[]uint64)(unsafe.Pointer(&dest))
  91. for i := 0; i < len(src); i++ {
  92. (*up)[i] = src[i]
  93. }
  94. }
  95. func CopyBytesToInt64(dest []uint64, src []byte) {
  96. up := (*[]uint64)(unsafe.Pointer(&src))
  97. for i := uint(0); i < uint(len(src) / 8); i++ {
  98. dest[i] = (*up)[i]
  99. }
  100. }
  101. func (s *Skein1024) ProcessBlock(blk []byte, kw []uint64, blkCnt, byteCntAdd uint) {
  102. const WCNT = SKEIN1024_STATE_WORDS
  103. //var kw [WCNT+4]uint6
  104. var X00,X01,X02,X03,X04,X05,X06,X07,X08,X09,X10,X11,X12,X13,X14,X15 uint64
  105. var w_ [WCNT]uint64
  106. w := w_[:]
  107. //w := make([]uint64, WCNT)
  108. //ASSERT blkCnt != 0
  109. ks := kw[3:]
  110. kw[0] = s.h.T[0]
  111. kw[1] = s.h.T[1]
  112. /*
  113. if blkCnt == 0 {
  114. fmt.Println("Is this ever called?")
  115. blkCnt++
  116. }*/
  117. for ;blkCnt > 0; blkCnt-- {
  118. kw[0] += uint64(byteCntAdd)
  119. ks[0] = s.X[0]
  120. ks[1] = s.X[1]
  121. ks[2] = s.X[2]
  122. ks[3] = s.X[3]
  123. ks[4] = s.X[4]
  124. ks[5] = s.X[5]
  125. ks[6] = s.X[6]
  126. ks[7] = s.X[7]
  127. ks[8] = s.X[8]
  128. ks[9] = s.X[9]
  129. ks[10] = s.X[10]
  130. ks[11] = s.X[11]
  131. ks[12] = s.X[12]
  132. ks[13] = s.X[13]
  133. ks[14] = s.X[14]
  134. ks[15] = s.X[15]
  135. ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ ((0xA9FC1A22) + (( uint64(0x1BD11BDA)) << 32))
  136. kw[2] = kw[0] ^ kw[1]
  137. //copy(w[:], blk[:8*WCNT])
  138. CopyBytesToInt64(w, blk)
  139. X00 = w[ 0] + ks[ 0] /* do the first full key injection */
  140. X01 = w[ 1] + ks[ 1]
  141. X02 = w[ 2] + ks[ 2]
  142. X03 = w[ 3] + ks[ 3]
  143. X04 = w[ 4] + ks[ 4]
  144. X05 = w[ 5] + ks[ 5]
  145. X06 = w[ 6] + ks[ 6]
  146. X07 = w[ 7] + ks[ 7]
  147. X08 = w[ 8] + ks[ 8]
  148. X09 = w[ 9] + ks[ 9]
  149. X10 = w[10] + ks[10]
  150. X11 = w[11] + ks[11]
  151. X12 = w[12] + ks[12]
  152. X13 = w[13] + ks[13] + kw[0]
  153. X14 = w[14] + ks[14] + kw[1]
  154. X15 = w[15] + ks[15]
  155. ks[0] = s.X[0]
  156. X00 += X01
  157. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  158. X01 ^= X00
  159. X02 += X03
  160. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  161. X03 ^= X02
  162. X04 += X05
  163. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  164. X05 ^= X04
  165. X06 += X07
  166. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  167. X07 ^= X06
  168. X08 += X09
  169. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  170. X09 ^= X08
  171. X10 += X11
  172. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  173. X11 ^= X10
  174. X12 += X13
  175. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  176. X13 ^= X12
  177. X14 += X15
  178. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  179. X15 ^= X14
  180. X00 += X09
  181. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  182. X09 ^= X00
  183. X02 += X13
  184. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  185. X13 ^= X02
  186. X06 += X11
  187. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  188. X11 ^= X06
  189. X04 += X15
  190. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  191. X15 ^= X04
  192. X10 += X07
  193. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  194. X07 ^= X10
  195. X12 += X03
  196. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  197. X03 ^= X12
  198. X14 += X05
  199. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  200. X05 ^= X14
  201. X08 += X01
  202. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  203. X01 ^= X08
  204. X00 += X07
  205. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  206. X07 ^= X00
  207. X02 += X05
  208. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  209. X05 ^= X02
  210. X04 += X03
  211. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  212. X03 ^= X04
  213. X06 += X01
  214. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  215. X01 ^= X06
  216. X12 += X15
  217. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  218. X15 ^= X12
  219. X14 += X13
  220. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  221. X13 ^= X14
  222. X08 += X11
  223. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  224. X11 ^= X08
  225. X10 += X09
  226. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  227. X09 ^= X10
  228. X00 += X15
  229. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  230. X15 ^= X00
  231. X02 += X11
  232. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  233. X11 ^= X02
  234. X06 += X13
  235. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  236. X13 ^= X06
  237. X04 += X09
  238. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  239. X09 ^= X04
  240. X14 += X01
  241. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  242. X01 ^= X14
  243. X08 += X05
  244. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  245. X05 ^= X08
  246. X10 += X03
  247. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  248. X03 ^= X10
  249. X12 += X07
  250. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  251. X07 ^= X12
  252. X00 += ks[((2*(0))+ 1) % 17]
  253. X01 += ks[((2*(0))+ 2) % 17]
  254. X02 += ks[((2*(0))+ 3) % 17]
  255. X03 += ks[((2*(0))+ 4) % 17]
  256. X04 += ks[((2*(0))+ 5) % 17]
  257. X05 += ks[((2*(0))+ 6) % 17]
  258. X06 += ks[((2*(0))+ 7) % 17]
  259. X07 += ks[((2*(0))+ 8) % 17]
  260. X08 += ks[((2*(0))+ 9) % 17]
  261. X09 += ks[((2*(0))+10) % 17]
  262. X10 += ks[((2*(0))+11) % 17]
  263. X11 += ks[((2*(0))+12) % 17]
  264. X12 += ks[((2*(0))+13) % 17]
  265. X13 += ks[((2*(0))+14) % 17] + kw[((2*(0))+1) % 3]
  266. X14 += ks[((2*(0))+15) % 17] + kw[((2*(0))+2) % 3]
  267. X15 += ks[((2*(0))+16) % 17] + (2*(0))+1
  268. X00 += X01
  269. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  270. X01 ^= X00
  271. X02 += X03
  272. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  273. X03 ^= X02
  274. X04 += X05
  275. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  276. X05 ^= X04
  277. X06 += X07
  278. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  279. X07 ^= X06
  280. X08 += X09
  281. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  282. X09 ^= X08
  283. X10 += X11
  284. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  285. X11 ^= X10
  286. X12 += X13
  287. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  288. X13 ^= X12
  289. X14 += X15
  290. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  291. X15 ^= X14
  292. X00 += X09
  293. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  294. X09 ^= X00
  295. X02 += X13
  296. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  297. X13 ^= X02
  298. X06 += X11
  299. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  300. X11 ^= X06
  301. X04 += X15
  302. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  303. X15 ^= X04
  304. X10 += X07
  305. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  306. X07 ^= X10
  307. X12 += X03
  308. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  309. X03 ^= X12
  310. X14 += X05
  311. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  312. X05 ^= X14
  313. X08 += X01
  314. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  315. X01 ^= X08
  316. X00 += X07
  317. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  318. X07 ^= X00
  319. X02 += X05
  320. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  321. X05 ^= X02
  322. X04 += X03
  323. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  324. X03 ^= X04
  325. X06 += X01
  326. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  327. X01 ^= X06
  328. X12 += X15
  329. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  330. X15 ^= X12
  331. X14 += X13
  332. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  333. X13 ^= X14
  334. X08 += X11
  335. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  336. X11 ^= X08
  337. X10 += X09
  338. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  339. X09 ^= X10
  340. X00 += X15
  341. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  342. X15 ^= X00
  343. X02 += X11
  344. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  345. X11 ^= X02
  346. X06 += X13
  347. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  348. X13 ^= X06
  349. X04 += X09
  350. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  351. X09 ^= X04
  352. X14 += X01
  353. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  354. X01 ^= X14
  355. X08 += X05
  356. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  357. X05 ^= X08
  358. X10 += X03
  359. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  360. X03 ^= X10
  361. X12 += X07
  362. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  363. X07 ^= X12
  364. X00 += ks[((2*(0)+1)+ 1) % 17]
  365. X01 += ks[((2*(0)+1)+ 2) % 17]
  366. X02 += ks[((2*(0)+1)+ 3) % 17]
  367. X03 += ks[((2*(0)+1)+ 4) % 17]
  368. X04 += ks[((2*(0)+1)+ 5) % 17]
  369. X05 += ks[((2*(0)+1)+ 6) % 17]
  370. X06 += ks[((2*(0)+1)+ 7) % 17]
  371. X07 += ks[((2*(0)+1)+ 8) % 17]
  372. X08 += ks[((2*(0)+1)+ 9) % 17]
  373. X09 += ks[((2*(0)+1)+10) % 17]
  374. X10 += ks[((2*(0)+1)+11) % 17]
  375. X11 += ks[((2*(0)+1)+12) % 17]
  376. X12 += ks[((2*(0)+1)+13) % 17]
  377. X13 += ks[((2*(0)+1)+14) % 17] + kw[((2*(0)+1)+1) % 3]
  378. X14 += ks[((2*(0)+1)+15) % 17] + kw[((2*(0)+1)+2) % 3]
  379. X15 += ks[((2*(0)+1)+16) % 17] + (2*(0)+1)+1
  380. X00 += X01
  381. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  382. X01 ^= X00
  383. X02 += X03
  384. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  385. X03 ^= X02
  386. X04 += X05
  387. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  388. X05 ^= X04
  389. X06 += X07
  390. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  391. X07 ^= X06
  392. X08 += X09
  393. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  394. X09 ^= X08
  395. X10 += X11
  396. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  397. X11 ^= X10
  398. X12 += X13
  399. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  400. X13 ^= X12
  401. X14 += X15
  402. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  403. X15 ^= X14
  404. X00 += X09
  405. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  406. X09 ^= X00
  407. X02 += X13
  408. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  409. X13 ^= X02
  410. X06 += X11
  411. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  412. X11 ^= X06
  413. X04 += X15
  414. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  415. X15 ^= X04
  416. X10 += X07
  417. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  418. X07 ^= X10
  419. X12 += X03
  420. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  421. X03 ^= X12
  422. X14 += X05
  423. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  424. X05 ^= X14
  425. X08 += X01
  426. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  427. X01 ^= X08
  428. X00 += X07
  429. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  430. X07 ^= X00
  431. X02 += X05
  432. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  433. X05 ^= X02
  434. X04 += X03
  435. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  436. X03 ^= X04
  437. X06 += X01
  438. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  439. X01 ^= X06
  440. X12 += X15
  441. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  442. X15 ^= X12
  443. X14 += X13
  444. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  445. X13 ^= X14
  446. X08 += X11
  447. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  448. X11 ^= X08
  449. X10 += X09
  450. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  451. X09 ^= X10
  452. X00 += X15
  453. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  454. X15 ^= X00
  455. X02 += X11
  456. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  457. X11 ^= X02
  458. X06 += X13
  459. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  460. X13 ^= X06
  461. X04 += X09
  462. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  463. X09 ^= X04
  464. X14 += X01
  465. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  466. X01 ^= X14
  467. X08 += X05
  468. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  469. X05 ^= X08
  470. X10 += X03
  471. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  472. X03 ^= X10
  473. X12 += X07
  474. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  475. X07 ^= X12
  476. X00 += ks[((2*(1))+ 1) % 17]
  477. X01 += ks[((2*(1))+ 2) % 17]
  478. X02 += ks[((2*(1))+ 3) % 17]
  479. X03 += ks[((2*(1))+ 4) % 17]
  480. X04 += ks[((2*(1))+ 5) % 17]
  481. X05 += ks[((2*(1))+ 6) % 17]
  482. X06 += ks[((2*(1))+ 7) % 17]
  483. X07 += ks[((2*(1))+ 8) % 17]
  484. X08 += ks[((2*(1))+ 9) % 17]
  485. X09 += ks[((2*(1))+10) % 17]
  486. X10 += ks[((2*(1))+11) % 17]
  487. X11 += ks[((2*(1))+12) % 17]
  488. X12 += ks[((2*(1))+13) % 17]
  489. X13 += ks[((2*(1))+14) % 17] + kw[((2*(1))+1) % 3]
  490. X14 += ks[((2*(1))+15) % 17] + kw[((2*(1))+2) % 3]
  491. X15 += ks[((2*(1))+16) % 17] + (2*(1))+1
  492. X00 += X01
  493. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  494. X01 ^= X00
  495. X02 += X03
  496. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  497. X03 ^= X02
  498. X04 += X05
  499. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  500. X05 ^= X04
  501. X06 += X07
  502. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  503. X07 ^= X06
  504. X08 += X09
  505. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  506. X09 ^= X08
  507. X10 += X11
  508. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  509. X11 ^= X10
  510. X12 += X13
  511. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  512. X13 ^= X12
  513. X14 += X15
  514. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  515. X15 ^= X14
  516. X00 += X09
  517. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  518. X09 ^= X00
  519. X02 += X13
  520. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  521. X13 ^= X02
  522. X06 += X11
  523. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  524. X11 ^= X06
  525. X04 += X15
  526. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  527. X15 ^= X04
  528. X10 += X07
  529. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  530. X07 ^= X10
  531. X12 += X03
  532. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  533. X03 ^= X12
  534. X14 += X05
  535. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  536. X05 ^= X14
  537. X08 += X01
  538. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  539. X01 ^= X08
  540. X00 += X07
  541. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  542. X07 ^= X00
  543. X02 += X05
  544. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  545. X05 ^= X02
  546. X04 += X03
  547. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  548. X03 ^= X04
  549. X06 += X01
  550. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  551. X01 ^= X06
  552. X12 += X15
  553. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  554. X15 ^= X12
  555. X14 += X13
  556. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  557. X13 ^= X14
  558. X08 += X11
  559. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  560. X11 ^= X08
  561. X10 += X09
  562. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  563. X09 ^= X10
  564. X00 += X15
  565. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  566. X15 ^= X00
  567. X02 += X11
  568. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  569. X11 ^= X02
  570. X06 += X13
  571. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  572. X13 ^= X06
  573. X04 += X09
  574. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  575. X09 ^= X04
  576. X14 += X01
  577. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  578. X01 ^= X14
  579. X08 += X05
  580. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  581. X05 ^= X08
  582. X10 += X03
  583. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  584. X03 ^= X10
  585. X12 += X07
  586. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  587. X07 ^= X12
  588. X00 += ks[((2*(1)+1)+ 1) % 17]
  589. X01 += ks[((2*(1)+1)+ 2) % 17]
  590. X02 += ks[((2*(1)+1)+ 3) % 17]
  591. X03 += ks[((2*(1)+1)+ 4) % 17]
  592. X04 += ks[((2*(1)+1)+ 5) % 17]
  593. X05 += ks[((2*(1)+1)+ 6) % 17]
  594. X06 += ks[((2*(1)+1)+ 7) % 17]
  595. X07 += ks[((2*(1)+1)+ 8) % 17]
  596. X08 += ks[((2*(1)+1)+ 9) % 17]
  597. X09 += ks[((2*(1)+1)+10) % 17]
  598. X10 += ks[((2*(1)+1)+11) % 17]
  599. X11 += ks[((2*(1)+1)+12) % 17]
  600. X12 += ks[((2*(1)+1)+13) % 17]
  601. X13 += ks[((2*(1)+1)+14) % 17] + kw[((2*(1)+1)+1) % 3]
  602. X14 += ks[((2*(1)+1)+15) % 17] + kw[((2*(1)+1)+2) % 3]
  603. X15 += ks[((2*(1)+1)+16) % 17] + (2*(1)+1)+1
  604. X00 += X01
  605. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  606. X01 ^= X00
  607. X02 += X03
  608. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  609. X03 ^= X02
  610. X04 += X05
  611. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  612. X05 ^= X04
  613. X06 += X07
  614. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  615. X07 ^= X06
  616. X08 += X09
  617. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  618. X09 ^= X08
  619. X10 += X11
  620. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  621. X11 ^= X10
  622. X12 += X13
  623. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  624. X13 ^= X12
  625. X14 += X15
  626. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  627. X15 ^= X14
  628. X00 += X09
  629. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  630. X09 ^= X00
  631. X02 += X13
  632. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  633. X13 ^= X02
  634. X06 += X11
  635. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  636. X11 ^= X06
  637. X04 += X15
  638. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  639. X15 ^= X04
  640. X10 += X07
  641. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  642. X07 ^= X10
  643. X12 += X03
  644. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  645. X03 ^= X12
  646. X14 += X05
  647. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  648. X05 ^= X14
  649. X08 += X01
  650. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  651. X01 ^= X08
  652. X00 += X07
  653. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  654. X07 ^= X00
  655. X02 += X05
  656. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  657. X05 ^= X02
  658. X04 += X03
  659. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  660. X03 ^= X04
  661. X06 += X01
  662. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  663. X01 ^= X06
  664. X12 += X15
  665. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  666. X15 ^= X12
  667. X14 += X13
  668. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  669. X13 ^= X14
  670. X08 += X11
  671. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  672. X11 ^= X08
  673. X10 += X09
  674. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  675. X09 ^= X10
  676. X00 += X15
  677. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  678. X15 ^= X00
  679. X02 += X11
  680. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  681. X11 ^= X02
  682. X06 += X13
  683. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  684. X13 ^= X06
  685. X04 += X09
  686. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  687. X09 ^= X04
  688. X14 += X01
  689. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  690. X01 ^= X14
  691. X08 += X05
  692. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  693. X05 ^= X08
  694. X10 += X03
  695. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  696. X03 ^= X10
  697. X12 += X07
  698. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  699. X07 ^= X12
  700. X00 += ks[((2*(2))+ 1) % 17]
  701. X01 += ks[((2*(2))+ 2) % 17]
  702. X02 += ks[((2*(2))+ 3) % 17]
  703. X03 += ks[((2*(2))+ 4) % 17]
  704. X04 += ks[((2*(2))+ 5) % 17]
  705. X05 += ks[((2*(2))+ 6) % 17]
  706. X06 += ks[((2*(2))+ 7) % 17]
  707. X07 += ks[((2*(2))+ 8) % 17]
  708. X08 += ks[((2*(2))+ 9) % 17]
  709. X09 += ks[((2*(2))+10) % 17]
  710. X10 += ks[((2*(2))+11) % 17]
  711. X11 += ks[((2*(2))+12) % 17]
  712. X12 += ks[((2*(2))+13) % 17]
  713. X13 += ks[((2*(2))+14) % 17] + kw[((2*(2))+1) % 3]
  714. X14 += ks[((2*(2))+15) % 17] + kw[((2*(2))+2) % 3]
  715. X15 += ks[((2*(2))+16) % 17] + (2*(2))+1
  716. X00 += X01
  717. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  718. X01 ^= X00
  719. X02 += X03
  720. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  721. X03 ^= X02
  722. X04 += X05
  723. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  724. X05 ^= X04
  725. X06 += X07
  726. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  727. X07 ^= X06
  728. X08 += X09
  729. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  730. X09 ^= X08
  731. X10 += X11
  732. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  733. X11 ^= X10
  734. X12 += X13
  735. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  736. X13 ^= X12
  737. X14 += X15
  738. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  739. X15 ^= X14
  740. X00 += X09
  741. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  742. X09 ^= X00
  743. X02 += X13
  744. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  745. X13 ^= X02
  746. X06 += X11
  747. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  748. X11 ^= X06
  749. X04 += X15
  750. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  751. X15 ^= X04
  752. X10 += X07
  753. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  754. X07 ^= X10
  755. X12 += X03
  756. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  757. X03 ^= X12
  758. X14 += X05
  759. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  760. X05 ^= X14
  761. X08 += X01
  762. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  763. X01 ^= X08
  764. X00 += X07
  765. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  766. X07 ^= X00
  767. X02 += X05
  768. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  769. X05 ^= X02
  770. X04 += X03
  771. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  772. X03 ^= X04
  773. X06 += X01
  774. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  775. X01 ^= X06
  776. X12 += X15
  777. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  778. X15 ^= X12
  779. X14 += X13
  780. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  781. X13 ^= X14
  782. X08 += X11
  783. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  784. X11 ^= X08
  785. X10 += X09
  786. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  787. X09 ^= X10
  788. X00 += X15
  789. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  790. X15 ^= X00
  791. X02 += X11
  792. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  793. X11 ^= X02
  794. X06 += X13
  795. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  796. X13 ^= X06
  797. X04 += X09
  798. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  799. X09 ^= X04
  800. X14 += X01
  801. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  802. X01 ^= X14
  803. X08 += X05
  804. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  805. X05 ^= X08
  806. X10 += X03
  807. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  808. X03 ^= X10
  809. X12 += X07
  810. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  811. X07 ^= X12
  812. X00 += ks[((2*(2)+1)+ 1) % 17]
  813. X01 += ks[((2*(2)+1)+ 2) % 17]
  814. X02 += ks[((2*(2)+1)+ 3) % 17]
  815. X03 += ks[((2*(2)+1)+ 4) % 17]
  816. X04 += ks[((2*(2)+1)+ 5) % 17]
  817. X05 += ks[((2*(2)+1)+ 6) % 17]
  818. X06 += ks[((2*(2)+1)+ 7) % 17]
  819. X07 += ks[((2*(2)+1)+ 8) % 17]
  820. X08 += ks[((2*(2)+1)+ 9) % 17]
  821. X09 += ks[((2*(2)+1)+10) % 17]
  822. X10 += ks[((2*(2)+1)+11) % 17]
  823. X11 += ks[((2*(2)+1)+12) % 17]
  824. X12 += ks[((2*(2)+1)+13) % 17]
  825. X13 += ks[((2*(2)+1)+14) % 17] + kw[((2*(2)+1)+1) % 3]
  826. X14 += ks[((2*(2)+1)+15) % 17] + kw[((2*(2)+1)+2) % 3]
  827. X15 += ks[((2*(2)+1)+16) % 17] + (2*(2)+1)+1
  828. X00 += X01
  829. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  830. X01 ^= X00
  831. X02 += X03
  832. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  833. X03 ^= X02
  834. X04 += X05
  835. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  836. X05 ^= X04
  837. X06 += X07
  838. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  839. X07 ^= X06
  840. X08 += X09
  841. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  842. X09 ^= X08
  843. X10 += X11
  844. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  845. X11 ^= X10
  846. X12 += X13
  847. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  848. X13 ^= X12
  849. X14 += X15
  850. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  851. X15 ^= X14
  852. X00 += X09
  853. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  854. X09 ^= X00
  855. X02 += X13
  856. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  857. X13 ^= X02
  858. X06 += X11
  859. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  860. X11 ^= X06
  861. X04 += X15
  862. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  863. X15 ^= X04
  864. X10 += X07
  865. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  866. X07 ^= X10
  867. X12 += X03
  868. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  869. X03 ^= X12
  870. X14 += X05
  871. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  872. X05 ^= X14
  873. X08 += X01
  874. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  875. X01 ^= X08
  876. X00 += X07
  877. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  878. X07 ^= X00
  879. X02 += X05
  880. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  881. X05 ^= X02
  882. X04 += X03
  883. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  884. X03 ^= X04
  885. X06 += X01
  886. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  887. X01 ^= X06
  888. X12 += X15
  889. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  890. X15 ^= X12
  891. X14 += X13
  892. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  893. X13 ^= X14
  894. X08 += X11
  895. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  896. X11 ^= X08
  897. X10 += X09
  898. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  899. X09 ^= X10
  900. X00 += X15
  901. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  902. X15 ^= X00
  903. X02 += X11
  904. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  905. X11 ^= X02
  906. X06 += X13
  907. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  908. X13 ^= X06
  909. X04 += X09
  910. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  911. X09 ^= X04
  912. X14 += X01
  913. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  914. X01 ^= X14
  915. X08 += X05
  916. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  917. X05 ^= X08
  918. X10 += X03
  919. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  920. X03 ^= X10
  921. X12 += X07
  922. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  923. X07 ^= X12
  924. X00 += ks[((2*(3))+ 1) % 17]
  925. X01 += ks[((2*(3))+ 2) % 17]
  926. X02 += ks[((2*(3))+ 3) % 17]
  927. X03 += ks[((2*(3))+ 4) % 17]
  928. X04 += ks[((2*(3))+ 5) % 17]
  929. X05 += ks[((2*(3))+ 6) % 17]
  930. X06 += ks[((2*(3))+ 7) % 17]
  931. X07 += ks[((2*(3))+ 8) % 17]
  932. X08 += ks[((2*(3))+ 9) % 17]
  933. X09 += ks[((2*(3))+10) % 17]
  934. X10 += ks[((2*(3))+11) % 17]
  935. X11 += ks[((2*(3))+12) % 17]
  936. X12 += ks[((2*(3))+13) % 17]
  937. X13 += ks[((2*(3))+14) % 17] + kw[((2*(3))+1) % 3]
  938. X14 += ks[((2*(3))+15) % 17] + kw[((2*(3))+2) % 3]
  939. X15 += ks[((2*(3))+16) % 17] + (2*(3))+1
  940. X00 += X01
  941. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  942. X01 ^= X00
  943. X02 += X03
  944. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  945. X03 ^= X02
  946. X04 += X05
  947. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  948. X05 ^= X04
  949. X06 += X07
  950. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  951. X07 ^= X06
  952. X08 += X09
  953. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  954. X09 ^= X08
  955. X10 += X11
  956. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  957. X11 ^= X10
  958. X12 += X13
  959. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  960. X13 ^= X12
  961. X14 += X15
  962. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  963. X15 ^= X14
  964. X00 += X09
  965. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  966. X09 ^= X00
  967. X02 += X13
  968. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  969. X13 ^= X02
  970. X06 += X11
  971. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  972. X11 ^= X06
  973. X04 += X15
  974. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  975. X15 ^= X04
  976. X10 += X07
  977. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  978. X07 ^= X10
  979. X12 += X03
  980. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  981. X03 ^= X12
  982. X14 += X05
  983. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  984. X05 ^= X14
  985. X08 += X01
  986. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  987. X01 ^= X08
  988. X00 += X07
  989. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  990. X07 ^= X00
  991. X02 += X05
  992. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  993. X05 ^= X02
  994. X04 += X03
  995. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  996. X03 ^= X04
  997. X06 += X01
  998. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  999. X01 ^= X06
  1000. X12 += X15
  1001. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  1002. X15 ^= X12
  1003. X14 += X13
  1004. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  1005. X13 ^= X14
  1006. X08 += X11
  1007. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  1008. X11 ^= X08
  1009. X10 += X09
  1010. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  1011. X09 ^= X10
  1012. X00 += X15
  1013. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  1014. X15 ^= X00
  1015. X02 += X11
  1016. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  1017. X11 ^= X02
  1018. X06 += X13
  1019. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  1020. X13 ^= X06
  1021. X04 += X09
  1022. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  1023. X09 ^= X04
  1024. X14 += X01
  1025. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  1026. X01 ^= X14
  1027. X08 += X05
  1028. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  1029. X05 ^= X08
  1030. X10 += X03
  1031. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  1032. X03 ^= X10
  1033. X12 += X07
  1034. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  1035. X07 ^= X12
  1036. X00 += ks[((2*(3)+1)+ 1) % 17]
  1037. X01 += ks[((2*(3)+1)+ 2) % 17]
  1038. X02 += ks[((2*(3)+1)+ 3) % 17]
  1039. X03 += ks[((2*(3)+1)+ 4) % 17]
  1040. X04 += ks[((2*(3)+1)+ 5) % 17]
  1041. X05 += ks[((2*(3)+1)+ 6) % 17]
  1042. X06 += ks[((2*(3)+1)+ 7) % 17]
  1043. X07 += ks[((2*(3)+1)+ 8) % 17]
  1044. X08 += ks[((2*(3)+1)+ 9) % 17]
  1045. X09 += ks[((2*(3)+1)+10) % 17]
  1046. X10 += ks[((2*(3)+1)+11) % 17]
  1047. X11 += ks[((2*(3)+1)+12) % 17]
  1048. X12 += ks[((2*(3)+1)+13) % 17]
  1049. X13 += ks[((2*(3)+1)+14) % 17] + kw[((2*(3)+1)+1) % 3]
  1050. X14 += ks[((2*(3)+1)+15) % 17] + kw[((2*(3)+1)+2) % 3]
  1051. X15 += ks[((2*(3)+1)+16) % 17] + (2*(3)+1)+1
  1052. X00 += X01
  1053. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  1054. X01 ^= X00
  1055. X02 += X03
  1056. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  1057. X03 ^= X02
  1058. X04 += X05
  1059. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  1060. X05 ^= X04
  1061. X06 += X07
  1062. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  1063. X07 ^= X06
  1064. X08 += X09
  1065. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  1066. X09 ^= X08
  1067. X10 += X11
  1068. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  1069. X11 ^= X10
  1070. X12 += X13
  1071. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  1072. X13 ^= X12
  1073. X14 += X15
  1074. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  1075. X15 ^= X14
  1076. X00 += X09
  1077. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  1078. X09 ^= X00
  1079. X02 += X13
  1080. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  1081. X13 ^= X02
  1082. X06 += X11
  1083. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  1084. X11 ^= X06
  1085. X04 += X15
  1086. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  1087. X15 ^= X04
  1088. X10 += X07
  1089. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  1090. X07 ^= X10
  1091. X12 += X03
  1092. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  1093. X03 ^= X12
  1094. X14 += X05
  1095. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  1096. X05 ^= X14
  1097. X08 += X01
  1098. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  1099. X01 ^= X08
  1100. X00 += X07
  1101. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  1102. X07 ^= X00
  1103. X02 += X05
  1104. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  1105. X05 ^= X02
  1106. X04 += X03
  1107. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  1108. X03 ^= X04
  1109. X06 += X01
  1110. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  1111. X01 ^= X06
  1112. X12 += X15
  1113. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  1114. X15 ^= X12
  1115. X14 += X13
  1116. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  1117. X13 ^= X14
  1118. X08 += X11
  1119. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  1120. X11 ^= X08
  1121. X10 += X09
  1122. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  1123. X09 ^= X10
  1124. X00 += X15
  1125. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  1126. X15 ^= X00
  1127. X02 += X11
  1128. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  1129. X11 ^= X02
  1130. X06 += X13
  1131. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  1132. X13 ^= X06
  1133. X04 += X09
  1134. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  1135. X09 ^= X04
  1136. X14 += X01
  1137. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  1138. X01 ^= X14
  1139. X08 += X05
  1140. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  1141. X05 ^= X08
  1142. X10 += X03
  1143. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  1144. X03 ^= X10
  1145. X12 += X07
  1146. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  1147. X07 ^= X12
  1148. X00 += ks[((2*(4))+ 1) % 17]
  1149. X01 += ks[((2*(4))+ 2) % 17]
  1150. X02 += ks[((2*(4))+ 3) % 17]
  1151. X03 += ks[((2*(4))+ 4) % 17]
  1152. X04 += ks[((2*(4))+ 5) % 17]
  1153. X05 += ks[((2*(4))+ 6) % 17]
  1154. X06 += ks[((2*(4))+ 7) % 17]
  1155. X07 += ks[((2*(4))+ 8) % 17]
  1156. X08 += ks[((2*(4))+ 9) % 17]
  1157. X09 += ks[((2*(4))+10) % 17]
  1158. X10 += ks[((2*(4))+11) % 17]
  1159. X11 += ks[((2*(4))+12) % 17]
  1160. X12 += ks[((2*(4))+13) % 17]
  1161. X13 += ks[((2*(4))+14) % 17] + kw[((2*(4))+1) % 3]
  1162. X14 += ks[((2*(4))+15) % 17] + kw[((2*(4))+2) % 3]
  1163. X15 += ks[((2*(4))+16) % 17] + (2*(4))+1
  1164. X00 += X01
  1165. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  1166. X01 ^= X00
  1167. X02 += X03
  1168. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  1169. X03 ^= X02
  1170. X04 += X05
  1171. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  1172. X05 ^= X04
  1173. X06 += X07
  1174. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  1175. X07 ^= X06
  1176. X08 += X09
  1177. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  1178. X09 ^= X08
  1179. X10 += X11
  1180. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  1181. X11 ^= X10
  1182. X12 += X13
  1183. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  1184. X13 ^= X12
  1185. X14 += X15
  1186. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  1187. X15 ^= X14
  1188. X00 += X09
  1189. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  1190. X09 ^= X00
  1191. X02 += X13
  1192. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  1193. X13 ^= X02
  1194. X06 += X11
  1195. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  1196. X11 ^= X06
  1197. X04 += X15
  1198. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  1199. X15 ^= X04
  1200. X10 += X07
  1201. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  1202. X07 ^= X10
  1203. X12 += X03
  1204. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  1205. X03 ^= X12
  1206. X14 += X05
  1207. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  1208. X05 ^= X14
  1209. X08 += X01
  1210. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  1211. X01 ^= X08
  1212. X00 += X07
  1213. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  1214. X07 ^= X00
  1215. X02 += X05
  1216. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  1217. X05 ^= X02
  1218. X04 += X03
  1219. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  1220. X03 ^= X04
  1221. X06 += X01
  1222. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  1223. X01 ^= X06
  1224. X12 += X15
  1225. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  1226. X15 ^= X12
  1227. X14 += X13
  1228. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  1229. X13 ^= X14
  1230. X08 += X11
  1231. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  1232. X11 ^= X08
  1233. X10 += X09
  1234. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  1235. X09 ^= X10
  1236. X00 += X15
  1237. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  1238. X15 ^= X00
  1239. X02 += X11
  1240. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  1241. X11 ^= X02
  1242. X06 += X13
  1243. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  1244. X13 ^= X06
  1245. X04 += X09
  1246. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  1247. X09 ^= X04
  1248. X14 += X01
  1249. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  1250. X01 ^= X14
  1251. X08 += X05
  1252. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  1253. X05 ^= X08
  1254. X10 += X03
  1255. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  1256. X03 ^= X10
  1257. X12 += X07
  1258. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  1259. X07 ^= X12
  1260. X00 += ks[((2*(4)+1)+ 1) % 17]
  1261. X01 += ks[((2*(4)+1)+ 2) % 17]
  1262. X02 += ks[((2*(4)+1)+ 3) % 17]
  1263. X03 += ks[((2*(4)+1)+ 4) % 17]
  1264. X04 += ks[((2*(4)+1)+ 5) % 17]
  1265. X05 += ks[((2*(4)+1)+ 6) % 17]
  1266. X06 += ks[((2*(4)+1)+ 7) % 17]
  1267. X07 += ks[((2*(4)+1)+ 8) % 17]
  1268. X08 += ks[((2*(4)+1)+ 9) % 17]
  1269. X09 += ks[((2*(4)+1)+10) % 17]
  1270. X10 += ks[((2*(4)+1)+11) % 17]
  1271. X11 += ks[((2*(4)+1)+12) % 17]
  1272. X12 += ks[((2*(4)+1)+13) % 17]
  1273. X13 += ks[((2*(4)+1)+14) % 17] + kw[((2*(4)+1)+1) % 3]
  1274. X14 += ks[((2*(4)+1)+15) % 17] + kw[((2*(4)+1)+2) % 3]
  1275. X15 += ks[((2*(4)+1)+16) % 17] + (2*(4)+1)+1
  1276. X00 += X01
  1277. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  1278. X01 ^= X00
  1279. X02 += X03
  1280. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  1281. X03 ^= X02
  1282. X04 += X05
  1283. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  1284. X05 ^= X04
  1285. X06 += X07
  1286. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  1287. X07 ^= X06
  1288. X08 += X09
  1289. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  1290. X09 ^= X08
  1291. X10 += X11
  1292. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  1293. X11 ^= X10
  1294. X12 += X13
  1295. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  1296. X13 ^= X12
  1297. X14 += X15
  1298. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  1299. X15 ^= X14
  1300. X00 += X09
  1301. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  1302. X09 ^= X00
  1303. X02 += X13
  1304. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  1305. X13 ^= X02
  1306. X06 += X11
  1307. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  1308. X11 ^= X06
  1309. X04 += X15
  1310. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  1311. X15 ^= X04
  1312. X10 += X07
  1313. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  1314. X07 ^= X10
  1315. X12 += X03
  1316. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  1317. X03 ^= X12
  1318. X14 += X05
  1319. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  1320. X05 ^= X14
  1321. X08 += X01
  1322. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  1323. X01 ^= X08
  1324. X00 += X07
  1325. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  1326. X07 ^= X00
  1327. X02 += X05
  1328. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  1329. X05 ^= X02
  1330. X04 += X03
  1331. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  1332. X03 ^= X04
  1333. X06 += X01
  1334. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  1335. X01 ^= X06
  1336. X12 += X15
  1337. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  1338. X15 ^= X12
  1339. X14 += X13
  1340. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  1341. X13 ^= X14
  1342. X08 += X11
  1343. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  1344. X11 ^= X08
  1345. X10 += X09
  1346. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  1347. X09 ^= X10
  1348. X00 += X15
  1349. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  1350. X15 ^= X00
  1351. X02 += X11
  1352. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  1353. X11 ^= X02
  1354. X06 += X13
  1355. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  1356. X13 ^= X06
  1357. X04 += X09
  1358. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  1359. X09 ^= X04
  1360. X14 += X01
  1361. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  1362. X01 ^= X14
  1363. X08 += X05
  1364. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  1365. X05 ^= X08
  1366. X10 += X03
  1367. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  1368. X03 ^= X10
  1369. X12 += X07
  1370. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  1371. X07 ^= X12
  1372. X00 += ks[((2*(5))+ 1) % 17]
  1373. X01 += ks[((2*(5))+ 2) % 17]
  1374. X02 += ks[((2*(5))+ 3) % 17]
  1375. X03 += ks[((2*(5))+ 4) % 17]
  1376. X04 += ks[((2*(5))+ 5) % 17]
  1377. X05 += ks[((2*(5))+ 6) % 17]
  1378. X06 += ks[((2*(5))+ 7) % 17]
  1379. X07 += ks[((2*(5))+ 8) % 17]
  1380. X08 += ks[((2*(5))+ 9) % 17]
  1381. X09 += ks[((2*(5))+10) % 17]
  1382. X10 += ks[((2*(5))+11) % 17]
  1383. X11 += ks[((2*(5))+12) % 17]
  1384. X12 += ks[((2*(5))+13) % 17]
  1385. X13 += ks[((2*(5))+14) % 17] + kw[((2*(5))+1) % 3]
  1386. X14 += ks[((2*(5))+15) % 17] + kw[((2*(5))+2) % 3]
  1387. X15 += ks[((2*(5))+16) % 17] + (2*(5))+1
  1388. X00 += X01
  1389. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  1390. X01 ^= X00
  1391. X02 += X03
  1392. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  1393. X03 ^= X02
  1394. X04 += X05
  1395. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  1396. X05 ^= X04
  1397. X06 += X07
  1398. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  1399. X07 ^= X06
  1400. X08 += X09
  1401. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  1402. X09 ^= X08
  1403. X10 += X11
  1404. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  1405. X11 ^= X10
  1406. X12 += X13
  1407. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  1408. X13 ^= X12
  1409. X14 += X15
  1410. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  1411. X15 ^= X14
  1412. X00 += X09
  1413. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  1414. X09 ^= X00
  1415. X02 += X13
  1416. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  1417. X13 ^= X02
  1418. X06 += X11
  1419. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  1420. X11 ^= X06
  1421. X04 += X15
  1422. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  1423. X15 ^= X04
  1424. X10 += X07
  1425. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  1426. X07 ^= X10
  1427. X12 += X03
  1428. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  1429. X03 ^= X12
  1430. X14 += X05
  1431. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  1432. X05 ^= X14
  1433. X08 += X01
  1434. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  1435. X01 ^= X08
  1436. X00 += X07
  1437. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  1438. X07 ^= X00
  1439. X02 += X05
  1440. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  1441. X05 ^= X02
  1442. X04 += X03
  1443. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  1444. X03 ^= X04
  1445. X06 += X01
  1446. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  1447. X01 ^= X06
  1448. X12 += X15
  1449. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  1450. X15 ^= X12
  1451. X14 += X13
  1452. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  1453. X13 ^= X14
  1454. X08 += X11
  1455. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  1456. X11 ^= X08
  1457. X10 += X09
  1458. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  1459. X09 ^= X10
  1460. X00 += X15
  1461. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  1462. X15 ^= X00
  1463. X02 += X11
  1464. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  1465. X11 ^= X02
  1466. X06 += X13
  1467. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  1468. X13 ^= X06
  1469. X04 += X09
  1470. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  1471. X09 ^= X04
  1472. X14 += X01
  1473. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  1474. X01 ^= X14
  1475. X08 += X05
  1476. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  1477. X05 ^= X08
  1478. X10 += X03
  1479. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  1480. X03 ^= X10
  1481. X12 += X07
  1482. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  1483. X07 ^= X12
  1484. X00 += ks[((2*(5)+1)+ 1) % 17]
  1485. X01 += ks[((2*(5)+1)+ 2) % 17]
  1486. X02 += ks[((2*(5)+1)+ 3) % 17]
  1487. X03 += ks[((2*(5)+1)+ 4) % 17]
  1488. X04 += ks[((2*(5)+1)+ 5) % 17]
  1489. X05 += ks[((2*(5)+1)+ 6) % 17]
  1490. X06 += ks[((2*(5)+1)+ 7) % 17]
  1491. X07 += ks[((2*(5)+1)+ 8) % 17]
  1492. X08 += ks[((2*(5)+1)+ 9) % 17]
  1493. X09 += ks[((2*(5)+1)+10) % 17]
  1494. X10 += ks[((2*(5)+1)+11) % 17]
  1495. X11 += ks[((2*(5)+1)+12) % 17]
  1496. X12 += ks[((2*(5)+1)+13) % 17]
  1497. X13 += ks[((2*(5)+1)+14) % 17] + kw[((2*(5)+1)+1) % 3]
  1498. X14 += ks[((2*(5)+1)+15) % 17] + kw[((2*(5)+1)+2) % 3]
  1499. X15 += ks[((2*(5)+1)+16) % 17] + (2*(5)+1)+1
  1500. X00 += X01
  1501. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  1502. X01 ^= X00
  1503. X02 += X03
  1504. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  1505. X03 ^= X02
  1506. X04 += X05
  1507. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  1508. X05 ^= X04
  1509. X06 += X07
  1510. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  1511. X07 ^= X06
  1512. X08 += X09
  1513. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  1514. X09 ^= X08
  1515. X10 += X11
  1516. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  1517. X11 ^= X10
  1518. X12 += X13
  1519. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  1520. X13 ^= X12
  1521. X14 += X15
  1522. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  1523. X15 ^= X14
  1524. X00 += X09
  1525. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  1526. X09 ^= X00
  1527. X02 += X13
  1528. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  1529. X13 ^= X02
  1530. X06 += X11
  1531. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  1532. X11 ^= X06
  1533. X04 += X15
  1534. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  1535. X15 ^= X04
  1536. X10 += X07
  1537. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  1538. X07 ^= X10
  1539. X12 += X03
  1540. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  1541. X03 ^= X12
  1542. X14 += X05
  1543. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  1544. X05 ^= X14
  1545. X08 += X01
  1546. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  1547. X01 ^= X08
  1548. X00 += X07
  1549. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  1550. X07 ^= X00
  1551. X02 += X05
  1552. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  1553. X05 ^= X02
  1554. X04 += X03
  1555. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  1556. X03 ^= X04
  1557. X06 += X01
  1558. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  1559. X01 ^= X06
  1560. X12 += X15
  1561. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  1562. X15 ^= X12
  1563. X14 += X13
  1564. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  1565. X13 ^= X14
  1566. X08 += X11
  1567. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  1568. X11 ^= X08
  1569. X10 += X09
  1570. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  1571. X09 ^= X10
  1572. X00 += X15
  1573. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  1574. X15 ^= X00
  1575. X02 += X11
  1576. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  1577. X11 ^= X02
  1578. X06 += X13
  1579. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  1580. X13 ^= X06
  1581. X04 += X09
  1582. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  1583. X09 ^= X04
  1584. X14 += X01
  1585. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  1586. X01 ^= X14
  1587. X08 += X05
  1588. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  1589. X05 ^= X08
  1590. X10 += X03
  1591. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  1592. X03 ^= X10
  1593. X12 += X07
  1594. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  1595. X07 ^= X12
  1596. X00 += ks[((2*(6))+ 1) % 17]
  1597. X01 += ks[((2*(6))+ 2) % 17]
  1598. X02 += ks[((2*(6))+ 3) % 17]
  1599. X03 += ks[((2*(6))+ 4) % 17]
  1600. X04 += ks[((2*(6))+ 5) % 17]
  1601. X05 += ks[((2*(6))+ 6) % 17]
  1602. X06 += ks[((2*(6))+ 7) % 17]
  1603. X07 += ks[((2*(6))+ 8) % 17]
  1604. X08 += ks[((2*(6))+ 9) % 17]
  1605. X09 += ks[((2*(6))+10) % 17]
  1606. X10 += ks[((2*(6))+11) % 17]
  1607. X11 += ks[((2*(6))+12) % 17]
  1608. X12 += ks[((2*(6))+13) % 17]
  1609. X13 += ks[((2*(6))+14) % 17] + kw[((2*(6))+1) % 3]
  1610. X14 += ks[((2*(6))+15) % 17] + kw[((2*(6))+2) % 3]
  1611. X15 += ks[((2*(6))+16) % 17] + (2*(6))+1
  1612. X00 += X01
  1613. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  1614. X01 ^= X00
  1615. X02 += X03
  1616. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  1617. X03 ^= X02
  1618. X04 += X05
  1619. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  1620. X05 ^= X04
  1621. X06 += X07
  1622. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  1623. X07 ^= X06
  1624. X08 += X09
  1625. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  1626. X09 ^= X08
  1627. X10 += X11
  1628. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  1629. X11 ^= X10
  1630. X12 += X13
  1631. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  1632. X13 ^= X12
  1633. X14 += X15
  1634. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  1635. X15 ^= X14
  1636. X00 += X09
  1637. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  1638. X09 ^= X00
  1639. X02 += X13
  1640. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  1641. X13 ^= X02
  1642. X06 += X11
  1643. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  1644. X11 ^= X06
  1645. X04 += X15
  1646. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  1647. X15 ^= X04
  1648. X10 += X07
  1649. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  1650. X07 ^= X10
  1651. X12 += X03
  1652. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  1653. X03 ^= X12
  1654. X14 += X05
  1655. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  1656. X05 ^= X14
  1657. X08 += X01
  1658. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  1659. X01 ^= X08
  1660. X00 += X07
  1661. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  1662. X07 ^= X00
  1663. X02 += X05
  1664. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  1665. X05 ^= X02
  1666. X04 += X03
  1667. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  1668. X03 ^= X04
  1669. X06 += X01
  1670. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  1671. X01 ^= X06
  1672. X12 += X15
  1673. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  1674. X15 ^= X12
  1675. X14 += X13
  1676. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  1677. X13 ^= X14
  1678. X08 += X11
  1679. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  1680. X11 ^= X08
  1681. X10 += X09
  1682. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  1683. X09 ^= X10
  1684. X00 += X15
  1685. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  1686. X15 ^= X00
  1687. X02 += X11
  1688. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  1689. X11 ^= X02
  1690. X06 += X13
  1691. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  1692. X13 ^= X06
  1693. X04 += X09
  1694. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  1695. X09 ^= X04
  1696. X14 += X01
  1697. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  1698. X01 ^= X14
  1699. X08 += X05
  1700. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  1701. X05 ^= X08
  1702. X10 += X03
  1703. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  1704. X03 ^= X10
  1705. X12 += X07
  1706. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  1707. X07 ^= X12
  1708. X00 += ks[((2*(6)+1)+ 1) % 17]
  1709. X01 += ks[((2*(6)+1)+ 2) % 17]
  1710. X02 += ks[((2*(6)+1)+ 3) % 17]
  1711. X03 += ks[((2*(6)+1)+ 4) % 17]
  1712. X04 += ks[((2*(6)+1)+ 5) % 17]
  1713. X05 += ks[((2*(6)+1)+ 6) % 17]
  1714. X06 += ks[((2*(6)+1)+ 7) % 17]
  1715. X07 += ks[((2*(6)+1)+ 8) % 17]
  1716. X08 += ks[((2*(6)+1)+ 9) % 17]
  1717. X09 += ks[((2*(6)+1)+10) % 17]
  1718. X10 += ks[((2*(6)+1)+11) % 17]
  1719. X11 += ks[((2*(6)+1)+12) % 17]
  1720. X12 += ks[((2*(6)+1)+13) % 17]
  1721. X13 += ks[((2*(6)+1)+14) % 17] + kw[((2*(6)+1)+1) % 3]
  1722. X14 += ks[((2*(6)+1)+15) % 17] + kw[((2*(6)+1)+2) % 3]
  1723. X15 += ks[((2*(6)+1)+16) % 17] + (2*(6)+1)+1
  1724. X00 += X01
  1725. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  1726. X01 ^= X00
  1727. X02 += X03
  1728. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  1729. X03 ^= X02
  1730. X04 += X05
  1731. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  1732. X05 ^= X04
  1733. X06 += X07
  1734. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  1735. X07 ^= X06
  1736. X08 += X09
  1737. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  1738. X09 ^= X08
  1739. X10 += X11
  1740. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  1741. X11 ^= X10
  1742. X12 += X13
  1743. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  1744. X13 ^= X12
  1745. X14 += X15
  1746. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  1747. X15 ^= X14
  1748. X00 += X09
  1749. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  1750. X09 ^= X00
  1751. X02 += X13
  1752. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  1753. X13 ^= X02
  1754. X06 += X11
  1755. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  1756. X11 ^= X06
  1757. X04 += X15
  1758. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  1759. X15 ^= X04
  1760. X10 += X07
  1761. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  1762. X07 ^= X10
  1763. X12 += X03
  1764. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  1765. X03 ^= X12
  1766. X14 += X05
  1767. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  1768. X05 ^= X14
  1769. X08 += X01
  1770. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  1771. X01 ^= X08
  1772. X00 += X07
  1773. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  1774. X07 ^= X00
  1775. X02 += X05
  1776. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  1777. X05 ^= X02
  1778. X04 += X03
  1779. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  1780. X03 ^= X04
  1781. X06 += X01
  1782. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  1783. X01 ^= X06
  1784. X12 += X15
  1785. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  1786. X15 ^= X12
  1787. X14 += X13
  1788. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  1789. X13 ^= X14
  1790. X08 += X11
  1791. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  1792. X11 ^= X08
  1793. X10 += X09
  1794. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  1795. X09 ^= X10
  1796. X00 += X15
  1797. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  1798. X15 ^= X00
  1799. X02 += X11
  1800. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  1801. X11 ^= X02
  1802. X06 += X13
  1803. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  1804. X13 ^= X06
  1805. X04 += X09
  1806. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  1807. X09 ^= X04
  1808. X14 += X01
  1809. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  1810. X01 ^= X14
  1811. X08 += X05
  1812. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  1813. X05 ^= X08
  1814. X10 += X03
  1815. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  1816. X03 ^= X10
  1817. X12 += X07
  1818. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  1819. X07 ^= X12
  1820. X00 += ks[((2*(7))+ 1) % 17]
  1821. X01 += ks[((2*(7))+ 2) % 17]
  1822. X02 += ks[((2*(7))+ 3) % 17]
  1823. X03 += ks[((2*(7))+ 4) % 17]
  1824. X04 += ks[((2*(7))+ 5) % 17]
  1825. X05 += ks[((2*(7))+ 6) % 17]
  1826. X06 += ks[((2*(7))+ 7) % 17]
  1827. X07 += ks[((2*(7))+ 8) % 17]
  1828. X08 += ks[((2*(7))+ 9) % 17]
  1829. X09 += ks[((2*(7))+10) % 17]
  1830. X10 += ks[((2*(7))+11) % 17]
  1831. X11 += ks[((2*(7))+12) % 17]
  1832. X12 += ks[((2*(7))+13) % 17]
  1833. X13 += ks[((2*(7))+14) % 17] + kw[((2*(7))+1) % 3]
  1834. X14 += ks[((2*(7))+15) % 17] + kw[((2*(7))+2) % 3]
  1835. X15 += ks[((2*(7))+16) % 17] + (2*(7))+1
  1836. X00 += X01
  1837. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  1838. X01 ^= X00
  1839. X02 += X03
  1840. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  1841. X03 ^= X02
  1842. X04 += X05
  1843. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  1844. X05 ^= X04
  1845. X06 += X07
  1846. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  1847. X07 ^= X06
  1848. X08 += X09
  1849. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  1850. X09 ^= X08
  1851. X10 += X11
  1852. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  1853. X11 ^= X10
  1854. X12 += X13
  1855. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  1856. X13 ^= X12
  1857. X14 += X15
  1858. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  1859. X15 ^= X14
  1860. X00 += X09
  1861. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  1862. X09 ^= X00
  1863. X02 += X13
  1864. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  1865. X13 ^= X02
  1866. X06 += X11
  1867. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  1868. X11 ^= X06
  1869. X04 += X15
  1870. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  1871. X15 ^= X04
  1872. X10 += X07
  1873. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  1874. X07 ^= X10
  1875. X12 += X03
  1876. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  1877. X03 ^= X12
  1878. X14 += X05
  1879. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  1880. X05 ^= X14
  1881. X08 += X01
  1882. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  1883. X01 ^= X08
  1884. X00 += X07
  1885. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  1886. X07 ^= X00
  1887. X02 += X05
  1888. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  1889. X05 ^= X02
  1890. X04 += X03
  1891. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  1892. X03 ^= X04
  1893. X06 += X01
  1894. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  1895. X01 ^= X06
  1896. X12 += X15
  1897. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  1898. X15 ^= X12
  1899. X14 += X13
  1900. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  1901. X13 ^= X14
  1902. X08 += X11
  1903. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  1904. X11 ^= X08
  1905. X10 += X09
  1906. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  1907. X09 ^= X10
  1908. X00 += X15
  1909. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  1910. X15 ^= X00
  1911. X02 += X11
  1912. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  1913. X11 ^= X02
  1914. X06 += X13
  1915. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  1916. X13 ^= X06
  1917. X04 += X09
  1918. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  1919. X09 ^= X04
  1920. X14 += X01
  1921. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  1922. X01 ^= X14
  1923. X08 += X05
  1924. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  1925. X05 ^= X08
  1926. X10 += X03
  1927. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  1928. X03 ^= X10
  1929. X12 += X07
  1930. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  1931. X07 ^= X12
  1932. X00 += ks[((2*(7)+1)+ 1) % 17]
  1933. X01 += ks[((2*(7)+1)+ 2) % 17]
  1934. X02 += ks[((2*(7)+1)+ 3) % 17]
  1935. X03 += ks[((2*(7)+1)+ 4) % 17]
  1936. X04 += ks[((2*(7)+1)+ 5) % 17]
  1937. X05 += ks[((2*(7)+1)+ 6) % 17]
  1938. X06 += ks[((2*(7)+1)+ 7) % 17]
  1939. X07 += ks[((2*(7)+1)+ 8) % 17]
  1940. X08 += ks[((2*(7)+1)+ 9) % 17]
  1941. X09 += ks[((2*(7)+1)+10) % 17]
  1942. X10 += ks[((2*(7)+1)+11) % 17]
  1943. X11 += ks[((2*(7)+1)+12) % 17]
  1944. X12 += ks[((2*(7)+1)+13) % 17]
  1945. X13 += ks[((2*(7)+1)+14) % 17] + kw[((2*(7)+1)+1) % 3]
  1946. X14 += ks[((2*(7)+1)+15) % 17] + kw[((2*(7)+1)+2) % 3]
  1947. X15 += ks[((2*(7)+1)+16) % 17] + (2*(7)+1)+1
  1948. X00 += X01
  1949. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  1950. X01 ^= X00
  1951. X02 += X03
  1952. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  1953. X03 ^= X02
  1954. X04 += X05
  1955. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  1956. X05 ^= X04
  1957. X06 += X07
  1958. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  1959. X07 ^= X06
  1960. X08 += X09
  1961. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  1962. X09 ^= X08
  1963. X10 += X11
  1964. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  1965. X11 ^= X10
  1966. X12 += X13
  1967. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  1968. X13 ^= X12
  1969. X14 += X15
  1970. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  1971. X15 ^= X14
  1972. X00 += X09
  1973. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  1974. X09 ^= X00
  1975. X02 += X13
  1976. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  1977. X13 ^= X02
  1978. X06 += X11
  1979. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  1980. X11 ^= X06
  1981. X04 += X15
  1982. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  1983. X15 ^= X04
  1984. X10 += X07
  1985. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  1986. X07 ^= X10
  1987. X12 += X03
  1988. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  1989. X03 ^= X12
  1990. X14 += X05
  1991. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  1992. X05 ^= X14
  1993. X08 += X01
  1994. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  1995. X01 ^= X08
  1996. X00 += X07
  1997. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  1998. X07 ^= X00
  1999. X02 += X05
  2000. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  2001. X05 ^= X02
  2002. X04 += X03
  2003. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  2004. X03 ^= X04
  2005. X06 += X01
  2006. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  2007. X01 ^= X06
  2008. X12 += X15
  2009. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  2010. X15 ^= X12
  2011. X14 += X13
  2012. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  2013. X13 ^= X14
  2014. X08 += X11
  2015. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  2016. X11 ^= X08
  2017. X10 += X09
  2018. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  2019. X09 ^= X10
  2020. X00 += X15
  2021. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  2022. X15 ^= X00
  2023. X02 += X11
  2024. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  2025. X11 ^= X02
  2026. X06 += X13
  2027. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  2028. X13 ^= X06
  2029. X04 += X09
  2030. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  2031. X09 ^= X04
  2032. X14 += X01
  2033. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  2034. X01 ^= X14
  2035. X08 += X05
  2036. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  2037. X05 ^= X08
  2038. X10 += X03
  2039. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  2040. X03 ^= X10
  2041. X12 += X07
  2042. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  2043. X07 ^= X12
  2044. X00 += ks[((2*(8))+ 1) % 17]
  2045. X01 += ks[((2*(8))+ 2) % 17]
  2046. X02 += ks[((2*(8))+ 3) % 17]
  2047. X03 += ks[((2*(8))+ 4) % 17]
  2048. X04 += ks[((2*(8))+ 5) % 17]
  2049. X05 += ks[((2*(8))+ 6) % 17]
  2050. X06 += ks[((2*(8))+ 7) % 17]
  2051. X07 += ks[((2*(8))+ 8) % 17]
  2052. X08 += ks[((2*(8))+ 9) % 17]
  2053. X09 += ks[((2*(8))+10) % 17]
  2054. X10 += ks[((2*(8))+11) % 17]
  2055. X11 += ks[((2*(8))+12) % 17]
  2056. X12 += ks[((2*(8))+13) % 17]
  2057. X13 += ks[((2*(8))+14) % 17] + kw[((2*(8))+1) % 3]
  2058. X14 += ks[((2*(8))+15) % 17] + kw[((2*(8))+2) % 3]
  2059. X15 += ks[((2*(8))+16) % 17] + (2*(8))+1
  2060. X00 += X01
  2061. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  2062. X01 ^= X00
  2063. X02 += X03
  2064. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  2065. X03 ^= X02
  2066. X04 += X05
  2067. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  2068. X05 ^= X04
  2069. X06 += X07
  2070. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  2071. X07 ^= X06
  2072. X08 += X09
  2073. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  2074. X09 ^= X08
  2075. X10 += X11
  2076. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  2077. X11 ^= X10
  2078. X12 += X13
  2079. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  2080. X13 ^= X12
  2081. X14 += X15
  2082. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  2083. X15 ^= X14
  2084. X00 += X09
  2085. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  2086. X09 ^= X00
  2087. X02 += X13
  2088. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  2089. X13 ^= X02
  2090. X06 += X11
  2091. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  2092. X11 ^= X06
  2093. X04 += X15
  2094. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  2095. X15 ^= X04
  2096. X10 += X07
  2097. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  2098. X07 ^= X10
  2099. X12 += X03
  2100. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  2101. X03 ^= X12
  2102. X14 += X05
  2103. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  2104. X05 ^= X14
  2105. X08 += X01
  2106. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  2107. X01 ^= X08
  2108. X00 += X07
  2109. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  2110. X07 ^= X00
  2111. X02 += X05
  2112. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  2113. X05 ^= X02
  2114. X04 += X03
  2115. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  2116. X03 ^= X04
  2117. X06 += X01
  2118. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  2119. X01 ^= X06
  2120. X12 += X15
  2121. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  2122. X15 ^= X12
  2123. X14 += X13
  2124. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  2125. X13 ^= X14
  2126. X08 += X11
  2127. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  2128. X11 ^= X08
  2129. X10 += X09
  2130. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  2131. X09 ^= X10
  2132. X00 += X15
  2133. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  2134. X15 ^= X00
  2135. X02 += X11
  2136. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  2137. X11 ^= X02
  2138. X06 += X13
  2139. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  2140. X13 ^= X06
  2141. X04 += X09
  2142. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  2143. X09 ^= X04
  2144. X14 += X01
  2145. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  2146. X01 ^= X14
  2147. X08 += X05
  2148. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  2149. X05 ^= X08
  2150. X10 += X03
  2151. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  2152. X03 ^= X10
  2153. X12 += X07
  2154. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  2155. X07 ^= X12
  2156. X00 += ks[((2*(8)+1)+ 1) % 17]
  2157. X01 += ks[((2*(8)+1)+ 2) % 17]
  2158. X02 += ks[((2*(8)+1)+ 3) % 17]
  2159. X03 += ks[((2*(8)+1)+ 4) % 17]
  2160. X04 += ks[((2*(8)+1)+ 5) % 17]
  2161. X05 += ks[((2*(8)+1)+ 6) % 17]
  2162. X06 += ks[((2*(8)+1)+ 7) % 17]
  2163. X07 += ks[((2*(8)+1)+ 8) % 17]
  2164. X08 += ks[((2*(8)+1)+ 9) % 17]
  2165. X09 += ks[((2*(8)+1)+10) % 17]
  2166. X10 += ks[((2*(8)+1)+11) % 17]
  2167. X11 += ks[((2*(8)+1)+12) % 17]
  2168. X12 += ks[((2*(8)+1)+13) % 17]
  2169. X13 += ks[((2*(8)+1)+14) % 17] + kw[((2*(8)+1)+1) % 3]
  2170. X14 += ks[((2*(8)+1)+15) % 17] + kw[((2*(8)+1)+2) % 3]
  2171. X15 += ks[((2*(8)+1)+16) % 17] + (2*(8)+1)+1
  2172. X00 += X01
  2173. X01 = (((X01) << (R1024_0_0)) | ((X01) >> (64-(R1024_0_0))))
  2174. X01 ^= X00
  2175. X02 += X03
  2176. X03 = (((X03) << (R1024_0_1)) | ((X03) >> (64-(R1024_0_1))))
  2177. X03 ^= X02
  2178. X04 += X05
  2179. X05 = (((X05) << (R1024_0_2)) | ((X05) >> (64-(R1024_0_2))))
  2180. X05 ^= X04
  2181. X06 += X07
  2182. X07 = (((X07) << (R1024_0_3)) | ((X07) >> (64-(R1024_0_3))))
  2183. X07 ^= X06
  2184. X08 += X09
  2185. X09 = (((X09) << (R1024_0_4)) | ((X09) >> (64-(R1024_0_4))))
  2186. X09 ^= X08
  2187. X10 += X11
  2188. X11 = (((X11) << (R1024_0_5)) | ((X11) >> (64-(R1024_0_5))))
  2189. X11 ^= X10
  2190. X12 += X13
  2191. X13 = (((X13) << (R1024_0_6)) | ((X13) >> (64-(R1024_0_6))))
  2192. X13 ^= X12
  2193. X14 += X15
  2194. X15 = (((X15) << (R1024_0_7)) | ((X15) >> (64-(R1024_0_7))))
  2195. X15 ^= X14
  2196. X00 += X09
  2197. X09 = (((X09) << (R1024_1_0)) | ((X09) >> (64-(R1024_1_0))))
  2198. X09 ^= X00
  2199. X02 += X13
  2200. X13 = (((X13) << (R1024_1_1)) | ((X13) >> (64-(R1024_1_1))))
  2201. X13 ^= X02
  2202. X06 += X11
  2203. X11 = (((X11) << (R1024_1_2)) | ((X11) >> (64-(R1024_1_2))))
  2204. X11 ^= X06
  2205. X04 += X15
  2206. X15 = (((X15) << (R1024_1_3)) | ((X15) >> (64-(R1024_1_3))))
  2207. X15 ^= X04
  2208. X10 += X07
  2209. X07 = (((X07) << (R1024_1_4)) | ((X07) >> (64-(R1024_1_4))))
  2210. X07 ^= X10
  2211. X12 += X03
  2212. X03 = (((X03) << (R1024_1_5)) | ((X03) >> (64-(R1024_1_5))))
  2213. X03 ^= X12
  2214. X14 += X05
  2215. X05 = (((X05) << (R1024_1_6)) | ((X05) >> (64-(R1024_1_6))))
  2216. X05 ^= X14
  2217. X08 += X01
  2218. X01 = (((X01) << (R1024_1_7)) | ((X01) >> (64-(R1024_1_7))))
  2219. X01 ^= X08
  2220. X00 += X07
  2221. X07 = (((X07) << (R1024_2_0)) | ((X07) >> (64-(R1024_2_0))))
  2222. X07 ^= X00
  2223. X02 += X05
  2224. X05 = (((X05) << (R1024_2_1)) | ((X05) >> (64-(R1024_2_1))))
  2225. X05 ^= X02
  2226. X04 += X03
  2227. X03 = (((X03) << (R1024_2_2)) | ((X03) >> (64-(R1024_2_2))))
  2228. X03 ^= X04
  2229. X06 += X01
  2230. X01 = (((X01) << (R1024_2_3)) | ((X01) >> (64-(R1024_2_3))))
  2231. X01 ^= X06
  2232. X12 += X15
  2233. X15 = (((X15) << (R1024_2_4)) | ((X15) >> (64-(R1024_2_4))))
  2234. X15 ^= X12
  2235. X14 += X13
  2236. X13 = (((X13) << (R1024_2_5)) | ((X13) >> (64-(R1024_2_5))))
  2237. X13 ^= X14
  2238. X08 += X11
  2239. X11 = (((X11) << (R1024_2_6)) | ((X11) >> (64-(R1024_2_6))))
  2240. X11 ^= X08
  2241. X10 += X09
  2242. X09 = (((X09) << (R1024_2_7)) | ((X09) >> (64-(R1024_2_7))))
  2243. X09 ^= X10
  2244. X00 += X15
  2245. X15 = (((X15) << (R1024_3_0)) | ((X15) >> (64-(R1024_3_0))))
  2246. X15 ^= X00
  2247. X02 += X11
  2248. X11 = (((X11) << (R1024_3_1)) | ((X11) >> (64-(R1024_3_1))))
  2249. X11 ^= X02
  2250. X06 += X13
  2251. X13 = (((X13) << (R1024_3_2)) | ((X13) >> (64-(R1024_3_2))))
  2252. X13 ^= X06
  2253. X04 += X09
  2254. X09 = (((X09) << (R1024_3_3)) | ((X09) >> (64-(R1024_3_3))))
  2255. X09 ^= X04
  2256. X14 += X01
  2257. X01 = (((X01) << (R1024_3_4)) | ((X01) >> (64-(R1024_3_4))))
  2258. X01 ^= X14
  2259. X08 += X05
  2260. X05 = (((X05) << (R1024_3_5)) | ((X05) >> (64-(R1024_3_5))))
  2261. X05 ^= X08
  2262. X10 += X03
  2263. X03 = (((X03) << (R1024_3_6)) | ((X03) >> (64-(R1024_3_6))))
  2264. X03 ^= X10
  2265. X12 += X07
  2266. X07 = (((X07) << (R1024_3_7)) | ((X07) >> (64-(R1024_3_7))))
  2267. X07 ^= X12
  2268. X00 += ks[((2*(9))+ 1) % 17]
  2269. X01 += ks[((2*(9))+ 2) % 17]
  2270. X02 += ks[((2*(9))+ 3) % 17]
  2271. X03 += ks[((2*(9))+ 4) % 17]
  2272. X04 += ks[((2*(9))+ 5) % 17]
  2273. X05 += ks[((2*(9))+ 6) % 17]
  2274. X06 += ks[((2*(9))+ 7) % 17]
  2275. X07 += ks[((2*(9))+ 8) % 17]
  2276. X08 += ks[((2*(9))+ 9) % 17]
  2277. X09 += ks[((2*(9))+10) % 17]
  2278. X10 += ks[((2*(9))+11) % 17]
  2279. X11 += ks[((2*(9))+12) % 17]
  2280. X12 += ks[((2*(9))+13) % 17]
  2281. X13 += ks[((2*(9))+14) % 17] + kw[((2*(9))+1) % 3]
  2282. X14 += ks[((2*(9))+15) % 17] + kw[((2*(9))+2) % 3]
  2283. X15 += ks[((2*(9))+16) % 17] + (2*(9))+1
  2284. X00 += X01
  2285. X01 = (((X01) << (R1024_4_0)) | ((X01) >> (64-(R1024_4_0))))
  2286. X01 ^= X00
  2287. X02 += X03
  2288. X03 = (((X03) << (R1024_4_1)) | ((X03) >> (64-(R1024_4_1))))
  2289. X03 ^= X02
  2290. X04 += X05
  2291. X05 = (((X05) << (R1024_4_2)) | ((X05) >> (64-(R1024_4_2))))
  2292. X05 ^= X04
  2293. X06 += X07
  2294. X07 = (((X07) << (R1024_4_3)) | ((X07) >> (64-(R1024_4_3))))
  2295. X07 ^= X06
  2296. X08 += X09
  2297. X09 = (((X09) << (R1024_4_4)) | ((X09) >> (64-(R1024_4_4))))
  2298. X09 ^= X08
  2299. X10 += X11
  2300. X11 = (((X11) << (R1024_4_5)) | ((X11) >> (64-(R1024_4_5))))
  2301. X11 ^= X10
  2302. X12 += X13
  2303. X13 = (((X13) << (R1024_4_6)) | ((X13) >> (64-(R1024_4_6))))
  2304. X13 ^= X12
  2305. X14 += X15
  2306. X15 = (((X15) << (R1024_4_7)) | ((X15) >> (64-(R1024_4_7))))
  2307. X15 ^= X14
  2308. X00 += X09
  2309. X09 = (((X09) << (R1024_5_0)) | ((X09) >> (64-(R1024_5_0))))
  2310. X09 ^= X00
  2311. X02 += X13
  2312. X13 = (((X13) << (R1024_5_1)) | ((X13) >> (64-(R1024_5_1))))
  2313. X13 ^= X02
  2314. X06 += X11
  2315. X11 = (((X11) << (R1024_5_2)) | ((X11) >> (64-(R1024_5_2))))
  2316. X11 ^= X06
  2317. X04 += X15
  2318. X15 = (((X15) << (R1024_5_3)) | ((X15) >> (64-(R1024_5_3))))
  2319. X15 ^= X04
  2320. X10 += X07
  2321. X07 = (((X07) << (R1024_5_4)) | ((X07) >> (64-(R1024_5_4))))
  2322. X07 ^= X10
  2323. X12 += X03
  2324. X03 = (((X03) << (R1024_5_5)) | ((X03) >> (64-(R1024_5_5))))
  2325. X03 ^= X12
  2326. X14 += X05
  2327. X05 = (((X05) << (R1024_5_6)) | ((X05) >> (64-(R1024_5_6))))
  2328. X05 ^= X14
  2329. X08 += X01
  2330. X01 = (((X01) << (R1024_5_7)) | ((X01) >> (64-(R1024_5_7))))
  2331. X01 ^= X08
  2332. X00 += X07
  2333. X07 = (((X07) << (R1024_6_0)) | ((X07) >> (64-(R1024_6_0))))
  2334. X07 ^= X00
  2335. X02 += X05
  2336. X05 = (((X05) << (R1024_6_1)) | ((X05) >> (64-(R1024_6_1))))
  2337. X05 ^= X02
  2338. X04 += X03
  2339. X03 = (((X03) << (R1024_6_2)) | ((X03) >> (64-(R1024_6_2))))
  2340. X03 ^= X04
  2341. X06 += X01
  2342. X01 = (((X01) << (R1024_6_3)) | ((X01) >> (64-(R1024_6_3))))
  2343. X01 ^= X06
  2344. X12 += X15
  2345. X15 = (((X15) << (R1024_6_4)) | ((X15) >> (64-(R1024_6_4))))
  2346. X15 ^= X12
  2347. X14 += X13
  2348. X13 = (((X13) << (R1024_6_5)) | ((X13) >> (64-(R1024_6_5))))
  2349. X13 ^= X14
  2350. X08 += X11
  2351. X11 = (((X11) << (R1024_6_6)) | ((X11) >> (64-(R1024_6_6))))
  2352. X11 ^= X08
  2353. X10 += X09
  2354. X09 = (((X09) << (R1024_6_7)) | ((X09) >> (64-(R1024_6_7))))
  2355. X09 ^= X10
  2356. X00 += X15
  2357. X15 = (((X15) << (R1024_7_0)) | ((X15) >> (64-(R1024_7_0))))
  2358. X15 ^= X00
  2359. X02 += X11
  2360. X11 = (((X11) << (R1024_7_1)) | ((X11) >> (64-(R1024_7_1))))
  2361. X11 ^= X02
  2362. X06 += X13
  2363. X13 = (((X13) << (R1024_7_2)) | ((X13) >> (64-(R1024_7_2))))
  2364. X13 ^= X06
  2365. X04 += X09
  2366. X09 = (((X09) << (R1024_7_3)) | ((X09) >> (64-(R1024_7_3))))
  2367. X09 ^= X04
  2368. X14 += X01
  2369. X01 = (((X01) << (R1024_7_4)) | ((X01) >> (64-(R1024_7_4))))
  2370. X01 ^= X14
  2371. X08 += X05
  2372. X05 = (((X05) << (R1024_7_5)) | ((X05) >> (64-(R1024_7_5))))
  2373. X05 ^= X08
  2374. X10 += X03
  2375. X03 = (((X03) << (R1024_7_6)) | ((X03) >> (64-(R1024_7_6))))
  2376. X03 ^= X10
  2377. X12 += X07
  2378. X07 = (((X07) << (R1024_7_7)) | ((X07) >> (64-(R1024_7_7))))
  2379. X07 ^= X12
  2380. X00 += ks[((2*(9)+1)+ 1) % 17]
  2381. X01 += ks[((2*(9)+1)+ 2) % 17]
  2382. X02 += ks[((2*(9)+1)+ 3) % 17]
  2383. X03 += ks[((2*(9)+1)+ 4) % 17]
  2384. X04 += ks[((2*(9)+1)+ 5) % 17]
  2385. X05 += ks[((2*(9)+1)+ 6) % 17]
  2386. X06 += ks[((2*(9)+1)+ 7) % 17]
  2387. X07 += ks[((2*(9)+1)+ 8) % 17]
  2388. X08 += ks[((2*(9)+1)+ 9) % 17]
  2389. X09 += ks[((2*(9)+1)+10) % 17]
  2390. X10 += ks[((2*(9)+1)+11) % 17]
  2391. X11 += ks[((2*(9)+1)+12) % 17]
  2392. X12 += ks[((2*(9)+1)+13) % 17]
  2393. X13 += ks[((2*(9)+1)+14) % 17] + kw[((2*(9)+1)+1) % 3]
  2394. X14 += ks[((2*(9)+1)+15) % 17] + kw[((2*(9)+1)+2) % 3]
  2395. X15 += ks[((2*(9)+1)+16) % 17] + (2*(9)+1)+1
  2396. s.X[ 0] = X00 ^ w[ 0]
  2397. s.X[ 1] = X01 ^ w[ 1]
  2398. s.X[ 2] = X02 ^ w[ 2]
  2399. s.X[ 3] = X03 ^ w[ 3]
  2400. s.X[ 4] = X04 ^ w[ 4]
  2401. s.X[ 5] = X05 ^ w[ 5]
  2402. s.X[ 6] = X06 ^ w[ 6]
  2403. s.X[ 7] = X07 ^ w[ 7]
  2404. s.X[ 8] = X08 ^ w[ 8]
  2405. s.X[ 9] = X09 ^ w[ 9]
  2406. s.X[10] = X10 ^ w[10]
  2407. s.X[11] = X11 ^ w[11]
  2408. s.X[12] = X12 ^ w[12]
  2409. s.X[13] = X13 ^ w[13]
  2410. s.X[14] = X14 ^ w[14]
  2411. s.X[15] = X15 ^ w[15]
  2412. kw[1] &= ^(uint64( 1 ) << ((126) - 64))
  2413. //blkPtr += ( 8*(16))
  2414. blk = blk[8*16:]
  2415. }
  2416. s.h.T[0] = kw[0]
  2417. s.h.T[1] = kw[1]
  2418. }