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.

95 lines
2.1 KiB

  1. // Copyright (c) 2016 Andreas Auernhammer. All rights reserved.
  2. // Use of this source code is governed by a license that can be
  3. // found in the LICENSE file.
  4. // +build amd64
  5. package threefish
  6. import "unsafe"
  7. func bytesToBlock256(block *[4]uint64, src []byte) {
  8. srcPtr := (*[4]uint64)(unsafe.Pointer(&src[0]))
  9. block[0] = srcPtr[0]
  10. block[1] = srcPtr[1]
  11. block[2] = srcPtr[2]
  12. block[3] = srcPtr[3]
  13. }
  14. func block256ToBytes(dst []byte, block *[4]uint64) {
  15. dstPtr := (*[4]uint64)(unsafe.Pointer(&dst[0]))
  16. dstPtr[0] = block[0]
  17. dstPtr[1] = block[1]
  18. dstPtr[2] = block[2]
  19. dstPtr[3] = block[3]
  20. }
  21. func bytesToBlock512(block *[8]uint64, src []byte) {
  22. srcPtr := (*[8]uint64)(unsafe.Pointer(&src[0]))
  23. block[0] = srcPtr[0]
  24. block[1] = srcPtr[1]
  25. block[2] = srcPtr[2]
  26. block[3] = srcPtr[3]
  27. block[4] = srcPtr[4]
  28. block[5] = srcPtr[5]
  29. block[6] = srcPtr[6]
  30. block[7] = srcPtr[7]
  31. }
  32. func block512ToBytes(dst []byte, block *[8]uint64) {
  33. dstPtr := (*[8]uint64)(unsafe.Pointer(&dst[0]))
  34. dstPtr[0] = block[0]
  35. dstPtr[1] = block[1]
  36. dstPtr[2] = block[2]
  37. dstPtr[3] = block[3]
  38. dstPtr[4] = block[4]
  39. dstPtr[5] = block[5]
  40. dstPtr[6] = block[6]
  41. dstPtr[7] = block[7]
  42. }
  43. func bytesToBlock1024(block *[16]uint64, src []byte) {
  44. srcPtr := (*[16]uint64)(unsafe.Pointer(&src[0]))
  45. block[0] = srcPtr[0]
  46. block[1] = srcPtr[1]
  47. block[2] = srcPtr[2]
  48. block[3] = srcPtr[3]
  49. block[4] = srcPtr[4]
  50. block[5] = srcPtr[5]
  51. block[6] = srcPtr[6]
  52. block[7] = srcPtr[7]
  53. block[8] = srcPtr[8]
  54. block[9] = srcPtr[9]
  55. block[10] = srcPtr[10]
  56. block[11] = srcPtr[11]
  57. block[12] = srcPtr[12]
  58. block[13] = srcPtr[13]
  59. block[14] = srcPtr[14]
  60. block[15] = srcPtr[15]
  61. }
  62. func block1024ToBytes(dst []byte, block *[16]uint64) {
  63. dstPtr := (*[16]uint64)(unsafe.Pointer(&dst[0]))
  64. dstPtr[0] = block[0]
  65. dstPtr[1] = block[1]
  66. dstPtr[2] = block[2]
  67. dstPtr[3] = block[3]
  68. dstPtr[4] = block[4]
  69. dstPtr[5] = block[5]
  70. dstPtr[6] = block[6]
  71. dstPtr[7] = block[7]
  72. dstPtr[8] = block[8]
  73. dstPtr[9] = block[9]
  74. dstPtr[10] = block[10]
  75. dstPtr[11] = block[11]
  76. dstPtr[12] = block[12]
  77. dstPtr[13] = block[13]
  78. dstPtr[14] = block[14]
  79. dstPtr[15] = block[15]
  80. }