Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.06 KB | None | 0 0
  1. /**
  2. * Author......: See docs/credits.txt
  3. * License.....: MIT
  4. */
  5.  
  6. #include "inc_vendor.cl"
  7. #include "inc_hash_constants.h"
  8. #include "inc_hash_functions.cl"
  9. #include "inc_types.cl"
  10. #include "inc_common.cl"
  11. #include "inc_hash_sha256.cl"
  12. #include "inc_cipher_aes.cl"
  13. #include "inc_cipher_twofish.cl"
  14.  
  15. #define COMPARE_S "inc_comp_single.cl"
  16. #define COMPARE_M "inc_comp_multi.cl"
  17.  
  18. __kernel void m13400_init (__global u32 * input, __global u32 * output, const unsigned int count)
  19. {
  20. const u64 gid = get_global_id (0);
  21.  
  22. //if (gid >= gid_max) return;
  23.  
  24. u32 w0[4];
  25. u32 w1[4];
  26. u32 w2[4];
  27. u32 w3[4];
  28.  
  29. w0[0] = input[0+(gid*32)];
  30. w0[1] = input[1+(gid*32)];
  31. w0[2] = input[2+(gid*32)];
  32. w0[3] = input[3+(gid*32)];
  33. w1[0] = input[4+(gid*32)];
  34. w1[1] = input[5+(gid*32)];
  35. w1[2] = input[6+(gid*32)];
  36. w1[3] = input[7+(gid*32)];
  37. w2[0] = 0;
  38. w2[1] = 0;
  39. w2[2] = 0;
  40. w2[3] = 0;
  41. w3[0] = 0;
  42. w3[1] = 0;
  43. w3[2] = 0;
  44. w3[3] = 0;
  45. sha256_ctx_t ctx;
  46.  
  47.  
  48. // This is just to get rid of any global memory access/initialization overhead for the benchmark
  49.  
  50. for (int i = 0; i < 1024; i += 1)
  51. {
  52.  
  53. // Running sha256 twice
  54. sha256_init (&ctx);
  55. sha256_update_64 (&ctx, w0, w1, w2, w3, 0);
  56. sha256_final (&ctx);
  57.  
  58. sha256_init (&ctx);
  59. sha256_update_64 (&ctx, w0, w1, w2, w3, 0);
  60. sha256_final (&ctx);
  61.  
  62.  
  63. // And aes once
  64.  
  65. u32 digest[8];
  66.  
  67. __local u32 s_td0[256];
  68. __local u32 s_td1[256];
  69. __local u32 s_td2[256];
  70. __local u32 s_td3[256];
  71. __local u32 s_td4[256];
  72.  
  73. __local u32 s_te0[256];
  74. __local u32 s_te1[256];
  75. __local u32 s_te2[256];
  76. __local u32 s_te3[256];
  77. __local u32 s_te4[256];
  78.  
  79.  
  80. #define KEYLEN 60
  81.  
  82. u32 ks[KEYLEN];
  83. u32 data[4];
  84. u32 out[4];
  85.  
  86. AES256_set_decrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4, s_td0, s_td1, s_td2, s_td3, s_td4);
  87.  
  88. AES256_decrypt (ks, data, out, s_td0, s_td1, s_td2, s_td3, s_td4);
  89.  
  90. }
  91.  
  92. output[0+(gid*32)] = ctx.h[0];
  93. output[1+(gid*32)] = ctx.h[1];
  94. output[2+(gid*32)] = ctx.h[2];
  95. output[3+(gid*32)] = ctx.h[3];
  96. output[4+(gid*32)] = ctx.h[4];
  97. output[5+(gid*32)] = ctx.h[5];
  98. output[6+(gid*32)] = ctx.h[6];
  99. output[7+(gid*32)] = ctx.h[7];
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement