digest-kangarootwelve 0.0.2 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +71 -37
  3. data/Rakefile +7 -9
  4. data/digest-kangarootwelve.gemspec +323 -14
  5. data/ext/digest/kangarootwelve/ext.c +228 -177
  6. data/ext/digest/kangarootwelve/extconf.rb +15 -1
  7. data/ext/digest/kangarootwelve/keccak/armv6m/KangarooTwelve.link.c +1 -0
  8. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakDuplexWidth1600.link.c +1 -0
  9. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakP-1600-SnP.h +36 -0
  10. data/ext/digest/kangarootwelve/{KeccakP-1600-times2-SnP.h → keccak/armv6m/KeccakP-1600-times2-SnP.h} +10 -10
  11. data/ext/digest/kangarootwelve/{KeccakP-1600-times2-on1.c → keccak/armv6m/KeccakP-1600-times2-on1.c} +13 -7
  12. data/ext/digest/kangarootwelve/{KeccakP-1600-times4-SnP.h → keccak/armv6m/KeccakP-1600-times4-SnP.h} +10 -10
  13. data/ext/digest/kangarootwelve/{KeccakP-1600-times4-on1.c → keccak/armv6m/KeccakP-1600-times4-on1.c} +13 -7
  14. data/ext/digest/kangarootwelve/{KeccakP-1600-times8-SnP.h → keccak/armv6m/KeccakP-1600-times8-SnP.h} +10 -10
  15. data/ext/digest/kangarootwelve/{KeccakP-1600-times8-on1.c → keccak/armv6m/KeccakP-1600-times8-on1.c} +13 -7
  16. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +1334 -0
  17. data/ext/digest/kangarootwelve/keccak/armv6m/KeccakSpongeWidth1600.link.c +1 -0
  18. data/ext/digest/kangarootwelve/{PlSnP-Fallback.inc → keccak/armv6m/PlSnP-Fallback.inc} +11 -7
  19. data/ext/digest/kangarootwelve/keccak/armv6m/ext.link.c +1 -0
  20. data/ext/digest/kangarootwelve/keccak/armv7a/KangarooTwelve.link.c +1 -0
  21. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakDuplexWidth1600.link.c +1 -0
  22. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-SnP.h +37 -0
  23. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-armv7a-le-neon-gcc.s +826 -0
  24. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +1245 -0
  25. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times2-SnP.h +38 -0
  26. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times4-SnP.h +45 -0
  27. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times4-on2.c +38 -0
  28. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times8-SnP.h +45 -0
  29. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times8-on2.c +38 -0
  30. data/ext/digest/kangarootwelve/keccak/armv7a/KeccakSpongeWidth1600.link.c +1 -0
  31. data/ext/digest/kangarootwelve/keccak/armv7a/PlSnP-Fallback.inc +287 -0
  32. data/ext/digest/kangarootwelve/keccak/armv7a/ext.link.c +1 -0
  33. data/ext/digest/kangarootwelve/keccak/armv7m/KangarooTwelve.link.c +1 -0
  34. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakDuplexWidth1600.link.c +1 -0
  35. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-SnP.h +36 -0
  36. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +1170 -0
  37. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times2-SnP.h +45 -0
  38. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times2-on1.c +37 -0
  39. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times4-SnP.h +45 -0
  40. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times4-on1.c +37 -0
  41. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times8-SnP.h +45 -0
  42. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times8-on1.c +37 -0
  43. data/ext/digest/kangarootwelve/keccak/armv7m/KeccakSpongeWidth1600.link.c +1 -0
  44. data/ext/digest/kangarootwelve/keccak/armv7m/PlSnP-Fallback.inc +287 -0
  45. data/ext/digest/kangarootwelve/keccak/armv7m/ext.link.c +1 -0
  46. data/ext/digest/kangarootwelve/keccak/armv8a/KangarooTwelve.link.c +1 -0
  47. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakDuplexWidth1600.link.c +1 -0
  48. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-SnP.h +28 -0
  49. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-armv8a-neon.s +537 -0
  50. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times2-SnP.h +45 -0
  51. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times2-on1.c +37 -0
  52. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times4-SnP.h +45 -0
  53. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times4-on1.c +37 -0
  54. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times8-SnP.h +45 -0
  55. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times8-on1.c +37 -0
  56. data/ext/digest/kangarootwelve/keccak/armv8a/KeccakSpongeWidth1600.link.c +1 -0
  57. data/ext/digest/kangarootwelve/keccak/armv8a/PlSnP-Fallback.inc +287 -0
  58. data/ext/digest/kangarootwelve/keccak/armv8a/ext.link.c +1 -0
  59. data/ext/digest/kangarootwelve/keccak/asmx86-64/KangarooTwelve.link.c +1 -0
  60. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakDuplexWidth1600.link.c +1 -0
  61. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-SnP.h +37 -0
  62. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times2-SnP.h +45 -0
  63. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times2-on1.c +37 -0
  64. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times4-SnP.h +45 -0
  65. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times4-on1.c +37 -0
  66. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times8-SnP.h +45 -0
  67. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times8-on1.c +37 -0
  68. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-x86-64-gas.s +1190 -0
  69. data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakSpongeWidth1600.link.c +1 -0
  70. data/ext/digest/kangarootwelve/keccak/asmx86-64/PlSnP-Fallback.inc +287 -0
  71. data/ext/digest/kangarootwelve/keccak/asmx86-64/ext.link.c +1 -0
  72. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KangarooTwelve.link.c +1 -0
  73. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakDuplexWidth1600.link.c +1 -0
  74. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-SnP.h +37 -0
  75. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times2-SnP.h +45 -0
  76. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times2-on1.c +37 -0
  77. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times4-SnP.h +45 -0
  78. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times4-on1.c +37 -0
  79. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times8-SnP.h +45 -0
  80. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times8-on1.c +37 -0
  81. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-x86-64-shld-gas.s +1190 -0
  82. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakSpongeWidth1600.link.c +1 -0
  83. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/PlSnP-Fallback.inc +287 -0
  84. data/ext/digest/kangarootwelve/keccak/asmx86-64shld/ext.link.c +1 -0
  85. data/ext/digest/kangarootwelve/keccak/avr8/KangarooTwelve.link.c +1 -0
  86. data/ext/digest/kangarootwelve/keccak/avr8/KeccakDuplexWidth1600.link.c +1 -0
  87. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-SnP.h +37 -0
  88. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-avr8-fast.s +1116 -0
  89. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times2-SnP.h +45 -0
  90. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times2-on1.c +37 -0
  91. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times4-SnP.h +45 -0
  92. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times4-on1.c +37 -0
  93. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times8-SnP.h +45 -0
  94. data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times8-on1.c +37 -0
  95. data/ext/digest/kangarootwelve/keccak/avr8/KeccakSpongeWidth1600.link.c +1 -0
  96. data/ext/digest/kangarootwelve/keccak/avr8/PlSnP-Fallback.inc +287 -0
  97. data/ext/digest/kangarootwelve/keccak/avr8/ext.link.c +1 -0
  98. data/ext/digest/kangarootwelve/keccak/bulldozer/KangarooTwelve.link.c +1 -0
  99. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakDuplexWidth1600.link.c +1 -0
  100. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-SnP.h +39 -0
  101. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-XOP-config.h +6 -0
  102. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-XOP.c +473 -0
  103. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times2-SIMD128.c +954 -0
  104. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times2-SnP.h +47 -0
  105. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times4-SnP.h +45 -0
  106. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times4-on2.c +38 -0
  107. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times8-SnP.h +45 -0
  108. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times8-on2.c +38 -0
  109. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-unrolling.macros +302 -0
  110. data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakSpongeWidth1600.link.c +1 -0
  111. data/ext/digest/kangarootwelve/keccak/bulldozer/PlSnP-Fallback.inc +287 -0
  112. data/ext/digest/kangarootwelve/keccak/bulldozer/SIMD128-config.h +9 -0
  113. data/ext/digest/kangarootwelve/{SnP-Relaned.h → keccak/bulldozer/SnP-Relaned.h} +13 -7
  114. data/ext/digest/kangarootwelve/keccak/bulldozer/ext.link.c +1 -0
  115. data/ext/digest/kangarootwelve/{KangarooTwelve.c → keccak/common/KangarooTwelve.c} +6 -10
  116. data/ext/digest/kangarootwelve/{KangarooTwelve.h → keccak/common/KangarooTwelve.h} +3 -7
  117. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplex-common.h +37 -0
  118. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplex.inc +192 -0
  119. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplexWidth1600.c +34 -0
  120. data/ext/digest/kangarootwelve/keccak/common/KeccakDuplexWidth1600.h +25 -0
  121. data/ext/digest/kangarootwelve/{KeccakSponge-common.h → keccak/common/KeccakSponge-common.h} +5 -7
  122. data/ext/digest/kangarootwelve/{KeccakSponge.inc → keccak/common/KeccakSponge.inc} +6 -8
  123. data/ext/digest/kangarootwelve/{KeccakSpongeWidth1600.c → keccak/common/KeccakSpongeWidth1600.c} +6 -8
  124. data/ext/digest/kangarootwelve/{KeccakSpongeWidth1600.h → keccak/common/KeccakSpongeWidth1600.h} +5 -7
  125. data/ext/digest/kangarootwelve/{Phases.h → keccak/common/Phases.h} +3 -7
  126. data/ext/digest/kangarootwelve/{align.h → keccak/common/align.h} +5 -7
  127. data/ext/digest/kangarootwelve/{brg_endian.h → keccak/common/brg_endian.h} +0 -0
  128. data/ext/digest/kangarootwelve/keccak/compact/KangarooTwelve.link.c +1 -0
  129. data/ext/digest/kangarootwelve/keccak/compact/KeccakDuplexWidth1600.link.c +1 -0
  130. data/ext/digest/kangarootwelve/{KeccakP-1600-SnP.h → keccak/compact/KeccakP-1600-SnP.h} +7 -10
  131. data/ext/digest/kangarootwelve/{KeccakP-1600-compact64.c → keccak/compact/KeccakP-1600-compact64.c} +11 -7
  132. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times2-SnP.h +45 -0
  133. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times2-on1.c +37 -0
  134. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times4-SnP.h +45 -0
  135. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times4-on1.c +37 -0
  136. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times8-SnP.h +45 -0
  137. data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times8-on1.c +37 -0
  138. data/ext/digest/kangarootwelve/keccak/compact/KeccakSpongeWidth1600.link.c +1 -0
  139. data/ext/digest/kangarootwelve/keccak/compact/PlSnP-Fallback.inc +287 -0
  140. data/ext/digest/kangarootwelve/keccak/compact/SnP-Relaned.h +140 -0
  141. data/ext/digest/kangarootwelve/keccak/compact/ext.link.c +1 -0
  142. data/ext/digest/kangarootwelve/keccak/generic32/KangarooTwelve.link.c +1 -0
  143. data/ext/digest/kangarootwelve/keccak/generic32/KeccakDuplexWidth1600.link.c +1 -0
  144. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-SnP.h +38 -0
  145. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-inplace32BI.c +1162 -0
  146. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times2-SnP.h +45 -0
  147. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times2-on1.c +37 -0
  148. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times4-SnP.h +45 -0
  149. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times4-on1.c +37 -0
  150. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times8-SnP.h +45 -0
  151. data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times8-on1.c +37 -0
  152. data/ext/digest/kangarootwelve/keccak/generic32/KeccakSpongeWidth1600.link.c +1 -0
  153. data/ext/digest/kangarootwelve/keccak/generic32/PlSnP-Fallback.inc +287 -0
  154. data/ext/digest/kangarootwelve/keccak/generic32/SnP-Relaned.h +140 -0
  155. data/ext/digest/kangarootwelve/keccak/generic32/ext.link.c +1 -0
  156. data/ext/digest/kangarootwelve/keccak/generic32lc/KangarooTwelve.link.c +1 -0
  157. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakDuplexWidth1600.link.c +1 -0
  158. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-SnP.h +38 -0
  159. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-inplace32BI.c +1162 -0
  160. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times2-SnP.h +45 -0
  161. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times2-on1.c +37 -0
  162. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times4-SnP.h +45 -0
  163. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times4-on1.c +37 -0
  164. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times8-SnP.h +45 -0
  165. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times8-on1.c +37 -0
  166. data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakSpongeWidth1600.link.c +1 -0
  167. data/ext/digest/kangarootwelve/keccak/generic32lc/PlSnP-Fallback.inc +287 -0
  168. data/ext/digest/kangarootwelve/keccak/generic32lc/SnP-Relaned.h +140 -0
  169. data/ext/digest/kangarootwelve/keccak/generic32lc/ext.link.c +1 -0
  170. data/ext/digest/kangarootwelve/keccak/generic64/KangarooTwelve.link.c +1 -0
  171. data/ext/digest/kangarootwelve/keccak/generic64/KeccakDuplexWidth1600.link.c +1 -0
  172. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-64.macros +2195 -0
  173. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-SnP.h +49 -0
  174. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-opt64-config.h +6 -0
  175. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-opt64.c +541 -0
  176. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times2-SnP.h +45 -0
  177. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times2-on1.c +37 -0
  178. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times4-SnP.h +45 -0
  179. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times4-on1.c +37 -0
  180. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times8-SnP.h +45 -0
  181. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times8-on1.c +37 -0
  182. data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-unrolling.macros +302 -0
  183. data/ext/digest/kangarootwelve/keccak/generic64/KeccakSpongeWidth1600.link.c +1 -0
  184. data/ext/digest/kangarootwelve/keccak/generic64/PlSnP-Fallback.inc +287 -0
  185. data/ext/digest/kangarootwelve/keccak/generic64/SnP-Relaned.h +140 -0
  186. data/ext/digest/kangarootwelve/keccak/generic64/ext.link.c +1 -0
  187. data/ext/digest/kangarootwelve/keccak/generic64lc/KangarooTwelve.link.c +1 -0
  188. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakDuplexWidth1600.link.c +1 -0
  189. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-64.macros +2195 -0
  190. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-SnP.h +49 -0
  191. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-opt64-config.h +7 -0
  192. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-opt64.c +541 -0
  193. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times2-SnP.h +45 -0
  194. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times2-on1.c +37 -0
  195. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times4-SnP.h +45 -0
  196. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times4-on1.c +37 -0
  197. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times8-SnP.h +45 -0
  198. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times8-on1.c +37 -0
  199. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-unrolling.macros +302 -0
  200. data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakSpongeWidth1600.link.c +1 -0
  201. data/ext/digest/kangarootwelve/keccak/generic64lc/PlSnP-Fallback.inc +287 -0
  202. data/ext/digest/kangarootwelve/keccak/generic64lc/SnP-Relaned.h +140 -0
  203. data/ext/digest/kangarootwelve/keccak/generic64lc/ext.link.c +1 -0
  204. data/ext/digest/kangarootwelve/keccak/haswell/KangarooTwelve.link.c +1 -0
  205. data/ext/digest/kangarootwelve/keccak/haswell/KeccakDuplexWidth1600.link.c +1 -0
  206. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-AVX2.s +993 -0
  207. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-SnP.h +41 -0
  208. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times2-SIMD128.c +954 -0
  209. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times2-SnP.h +47 -0
  210. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times4-SIMD256.c +1303 -0
  211. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times4-SnP.h +53 -0
  212. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times8-SnP.h +45 -0
  213. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times8-on4.c +38 -0
  214. data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-unrolling.macros +302 -0
  215. data/ext/digest/kangarootwelve/keccak/haswell/KeccakSpongeWidth1600.link.c +1 -0
  216. data/ext/digest/kangarootwelve/keccak/haswell/PlSnP-Fallback.inc +287 -0
  217. data/ext/digest/kangarootwelve/keccak/haswell/SIMD128-config.h +8 -0
  218. data/ext/digest/kangarootwelve/keccak/haswell/SIMD256-config.h +7 -0
  219. data/ext/digest/kangarootwelve/keccak/haswell/ext.link.c +1 -0
  220. data/ext/digest/kangarootwelve/keccak/nehalem/KangarooTwelve.link.c +1 -0
  221. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakDuplexWidth1600.link.c +1 -0
  222. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-64.macros +2195 -0
  223. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-SnP.h +49 -0
  224. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-opt64-config.h +7 -0
  225. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-opt64.c +541 -0
  226. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times2-SIMD128.c +954 -0
  227. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times2-SnP.h +47 -0
  228. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times4-SnP.h +45 -0
  229. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times4-on2.c +38 -0
  230. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times8-SnP.h +45 -0
  231. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times8-on2.c +38 -0
  232. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-unrolling.macros +302 -0
  233. data/ext/digest/kangarootwelve/keccak/nehalem/KeccakSpongeWidth1600.link.c +1 -0
  234. data/ext/digest/kangarootwelve/keccak/nehalem/PlSnP-Fallback.inc +287 -0
  235. data/ext/digest/kangarootwelve/keccak/nehalem/SIMD128-config.h +8 -0
  236. data/ext/digest/kangarootwelve/keccak/nehalem/SnP-Relaned.h +140 -0
  237. data/ext/digest/kangarootwelve/keccak/nehalem/ext.link.c +1 -0
  238. data/ext/digest/kangarootwelve/keccak/reference/KangarooTwelve.link.c +1 -0
  239. data/ext/digest/kangarootwelve/keccak/reference/KeccakDuplexWidth1600.link.c +1 -0
  240. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-SnP.h +41 -0
  241. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-reference.c +424 -0
  242. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-reference.h +20 -0
  243. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times2-SnP.h +45 -0
  244. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times2-on1.c +37 -0
  245. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times4-SnP.h +45 -0
  246. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times4-on1.c +37 -0
  247. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times8-SnP.h +45 -0
  248. data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times8-on1.c +37 -0
  249. data/ext/digest/kangarootwelve/keccak/reference/KeccakSpongeWidth1600.link.c +1 -0
  250. data/ext/digest/kangarootwelve/keccak/reference/PlSnP-Fallback.inc +287 -0
  251. data/ext/digest/kangarootwelve/keccak/reference/displayIntermediateValues.c +176 -0
  252. data/ext/digest/kangarootwelve/keccak/reference/displayIntermediateValues.h +29 -0
  253. data/ext/digest/kangarootwelve/keccak/reference/ext.link.c +1 -0
  254. data/ext/digest/kangarootwelve/keccak/reference32bits/KangarooTwelve.link.c +1 -0
  255. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakDuplexWidth1600.link.c +1 -0
  256. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-SnP.h +41 -0
  257. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-reference.h +20 -0
  258. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-reference32BI.c +612 -0
  259. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times2-SnP.h +45 -0
  260. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times2-on1.c +37 -0
  261. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times4-SnP.h +45 -0
  262. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times4-on1.c +37 -0
  263. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times8-SnP.h +45 -0
  264. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times8-on1.c +37 -0
  265. data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakSpongeWidth1600.link.c +1 -0
  266. data/ext/digest/kangarootwelve/keccak/reference32bits/PlSnP-Fallback.inc +287 -0
  267. data/ext/digest/kangarootwelve/keccak/reference32bits/displayIntermediateValues.c +176 -0
  268. data/ext/digest/kangarootwelve/keccak/reference32bits/displayIntermediateValues.h +29 -0
  269. data/ext/digest/kangarootwelve/keccak/reference32bits/ext.link.c +1 -0
  270. data/ext/digest/kangarootwelve/keccak/sandybridge/KangarooTwelve.link.c +1 -0
  271. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakDuplexWidth1600.link.c +1 -0
  272. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-64.macros +2195 -0
  273. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-SnP.h +49 -0
  274. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-opt64-config.h +8 -0
  275. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-opt64.c +541 -0
  276. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times2-SIMD128.c +954 -0
  277. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times2-SnP.h +47 -0
  278. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times4-SnP.h +45 -0
  279. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times4-on2.c +38 -0
  280. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times8-SnP.h +45 -0
  281. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times8-on2.c +38 -0
  282. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-unrolling.macros +302 -0
  283. data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakSpongeWidth1600.link.c +1 -0
  284. data/ext/digest/kangarootwelve/keccak/sandybridge/PlSnP-Fallback.inc +287 -0
  285. data/ext/digest/kangarootwelve/keccak/sandybridge/SIMD128-config.h +8 -0
  286. data/ext/digest/kangarootwelve/keccak/sandybridge/SnP-Relaned.h +140 -0
  287. data/ext/digest/kangarootwelve/keccak/sandybridge/ext.link.c +1 -0
  288. data/ext/digest/kangarootwelve/keccak/skylakex/KangarooTwelve.link.c +1 -0
  289. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakDuplexWidth1600.link.c +1 -0
  290. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-AVX512-config.h +6 -0
  291. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-AVX512.c +621 -0
  292. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-SnP.h +42 -0
  293. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times2-SIMD512.c +852 -0
  294. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times2-SnP.h +49 -0
  295. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times4-SIMD512.c +883 -0
  296. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times4-SnP.h +49 -0
  297. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times8-SIMD512.c +1473 -0
  298. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times8-SnP.h +53 -0
  299. data/ext/digest/kangarootwelve/keccak/skylakex/KeccakSpongeWidth1600.link.c +1 -0
  300. data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-2-config.h +7 -0
  301. data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-4-config.h +7 -0
  302. data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-config.h +7 -0
  303. data/ext/digest/kangarootwelve/keccak/skylakex/ext.link.c +1 -0
  304. data/ext/digest/kangarootwelve/utils.h +101 -0
  305. data/lib/digest/kangarootwelve/version.rb +2 -2
  306. data/test/test.rb +68 -31
  307. metadata +305 -27
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2017 konsolebox
2
+ * Copyright (c) 2017-2018 konsolebox
3
3
  *
4
4
  * MIT License
5
5
  *
@@ -23,14 +23,15 @@
23
23
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
24
  */
25
25
 
26
- #include "KangarooTwelve.h"
27
26
  #include <ruby.h>
28
27
  #include <ruby/digest.h>
29
28
 
29
+ #include "KangarooTwelve.h"
30
+ #include "utils.h"
31
+
30
32
  #define KT_DEFAULT_DIGEST_LENGTH 64 /* 512 bits */
31
- #define KT_DEFAULT_BLOCK_LENGTH 8192 * 8 /* chunkSize * Parallellism */
33
+ #define KT_BLOCK_LENGTH 8192 /* chunkSize */
32
34
  #define KT_MIN_DIGEST_LENGTH 1
33
- #define KT_MIN_BLOCK_LENGTH 64
34
35
 
35
36
  #define KT_DIGEST_API_VERSION_IS_SUPPORTED(version) (version == 3)
36
37
 
@@ -44,7 +45,9 @@ static ID _id_auto;
44
45
  static ID _id_block_length;
45
46
  static ID _id_b;
46
47
  static ID _id_customization;
48
+ static ID _id_customization_hex;
47
49
  static ID _id_c;
50
+ static ID _id_ch;
48
51
  static ID _id_default;
49
52
  static ID _id_digest_length;
50
53
  static ID _id_d;
@@ -55,11 +58,10 @@ static ID _id_new;
55
58
  static ID _id_n;
56
59
  static ID _id_unpack;
57
60
 
58
- static VALUE _module_Digest;
59
- static VALUE _class_Digest_Base;
60
- static VALUE _module_Digest_KangarooTwelve;
61
- static VALUE _class_Digest_KangarooTwelve_Impl;
62
- static VALUE _class_Digest_KangarooTwelve_Metadata;
61
+ static VALUE _Digest;
62
+ static VALUE _Digest_KangarooTwelve;
63
+ static VALUE _Digest_KangarooTwelve_Impl;
64
+ static VALUE _Digest_KangarooTwelve_Metadata;
63
65
 
64
66
  typedef struct {
65
67
  KangarooTwelve_Instance instance;
@@ -69,38 +71,63 @@ typedef struct {
69
71
  #define KT_CONTEXT kangarootwelve_context_t
70
72
  #define KT_CONTEXT_PTR(void_ctx_ptr) ((KT_CONTEXT *) void_ctx_ptr)
71
73
 
74
+ #define _RSTRING_PTR_U(x) (unsigned char *)RSTRING_PTR(x)
75
+
72
76
  static void check_digest_length(int digest_length)
73
77
  {
74
78
  if (!(digest_length >= KT_MIN_DIGEST_LENGTH))
75
79
  rb_raise(rb_eArgError, "Digest length lesser than minimum (%d): %d", KT_MIN_DIGEST_LENGTH, digest_length);
76
80
  }
77
81
 
78
- static void check_block_length(int block_length)
82
+ static VALUE hex_encode_str(VALUE str)
83
+ {
84
+ int len;
85
+ VALUE hex;
86
+
87
+ len = RSTRING_LEN(str);
88
+ hex = rb_str_new(0, len * 2);
89
+ hex_encode_str_implied(_RSTRING_PTR_U(str), len, _RSTRING_PTR_U(hex));
90
+ return hex;
91
+ }
92
+
93
+ static VALUE hex_decode_str(VALUE str)
79
94
  {
80
- if (!(block_length >= KT_MIN_BLOCK_LENGTH))
81
- rb_raise(rb_eArgError, "Block length lesser than minimum (%d): %d", KT_MIN_BLOCK_LENGTH, block_length);
95
+ int len;
96
+ VALUE decoded;
97
+
98
+ len = RSTRING_LEN(str);
99
+ decoded = rb_str_new(0, calc_hex_decoded_str_length(len));
100
+
101
+ if (! hex_decode_str_implied(_RSTRING_PTR_U(str), len, _RSTRING_PTR_U(decoded))) {
102
+ VALUE inspect = rb_inspect(str);
103
+ rb_raise(rb_eArgError, "Failed to decode hex string %s.", RSTRING_PTR(inspect));
104
+ }
105
+
106
+ return decoded;
82
107
  }
83
108
 
84
109
  static int kangarootwelve_init(void *ctx)
85
110
  {
111
+ VALUE klass_or_instance, digest_length, digest_length_int, customization;
112
+
86
113
  if (ctx == NULL)
87
114
  rb_raise(rb_eRuntimeError, "Context pointer is NULL.");
88
115
 
89
- VALUE klass_or_instance = rb_current_receiver();
116
+ klass_or_instance = rb_current_receiver();
90
117
 
91
- if (TYPE(klass_or_instance) == T_CLASS && klass_or_instance == _class_Digest_KangarooTwelve_Impl)
118
+ if (TYPE(klass_or_instance) == T_CLASS && klass_or_instance == _Digest_KangarooTwelve_Impl)
92
119
  rb_raise(rb_eStandardError, "Digest::KangarooTwelve::Impl is a base class and cannot be instantiated.");
93
120
 
94
- VALUE digest_length = rb_funcall(klass_or_instance, _id_digest_length, 0);
121
+ digest_length = rb_funcall(klass_or_instance, _id_digest_length, 0);
95
122
 
96
123
  if (TYPE(digest_length) != T_FIXNUM)
97
124
  rb_raise(rb_eTypeError, "Invalid object type for digest length.");
98
125
 
99
- int digest_length_int = FIX2INT(digest_length);
126
+ digest_length_int = FIX2INT(digest_length);
100
127
 
101
128
  check_digest_length(digest_length_int);
102
129
 
103
- VALUE customization = rb_funcall(klass_or_instance, _id_customization, 0);
130
+ customization = rb_funcall(klass_or_instance, _id_customization, 0);
104
131
 
105
132
  if (TYPE(customization) != T_NIL && TYPE(customization) != T_STRING)
106
133
  rb_raise(rb_eTypeError, "Invalid object type for a customization string.");
@@ -127,34 +154,34 @@ static void kangarootwelve_update(void *ctx, unsigned char *data, size_t length)
127
154
 
128
155
  static int kangarootwelve_finish(void *ctx, unsigned char *data)
129
156
  {
157
+ VALUE customization;
158
+
130
159
  if (ctx == NULL)
131
160
  rb_raise(rb_eRuntimeError, "Context pointer is NULL.");
132
161
 
133
- VALUE customization = KT_CONTEXT_PTR(ctx)->customization;
162
+ customization = KT_CONTEXT_PTR(ctx)->customization;
134
163
 
135
164
  switch (TYPE(customization)) {
136
165
  case T_NIL:
137
166
  return KangarooTwelve_Final(&KT_CONTEXT_PTR(ctx)->instance, data, 0, 0) == 0;
138
167
  case T_STRING:
139
- return KangarooTwelve_Final(&KT_CONTEXT_PTR(ctx)->instance, data, RSTRING_PTR(customization),
140
- RSTRING_LEN(customization)) == 0;
168
+ return KangarooTwelve_Final(&KT_CONTEXT_PTR(ctx)->instance, data,
169
+ _RSTRING_PTR_U(customization), RSTRING_LEN(customization)) == 0;
141
170
  default:
142
171
  rb_raise(rb_eRuntimeError, "Object type of customization string became invalid.");
143
172
  }
144
173
  }
145
174
 
146
- static VALUE do_nothing(VALUE self)
175
+ static VALUE implement(VALUE name, VALUE digest_length, VALUE customization)
147
176
  {
148
- return Qnil;
149
- }
177
+ VALUE impl_class, impl_class_name, prev_digest_length, metadata_obj;
178
+ ID impl_class_name_id, id;
179
+ int digest_length_int, prev_digest_length_int;
180
+ rb_digest_metadata_t *metadata;
150
181
 
151
- static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALUE customization)
152
- {
153
182
  if (!KT_DIGEST_API_VERSION_IS_SUPPORTED(RUBY_DIGEST_API_VERSION))
154
183
  rb_raise(rb_eRuntimeError, "Digest API version is not supported.");
155
184
 
156
- int digest_length_int, block_length_int;
157
-
158
185
  switch (TYPE(digest_length)) {
159
186
  case T_NIL:
160
187
  digest_length_int = KT_DEFAULT_DIGEST_LENGTH;
@@ -167,18 +194,6 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
167
194
  rb_raise(rb_eTypeError, "Invalid value type for digest length.");
168
195
  }
169
196
 
170
- switch (TYPE(block_length)) {
171
- case T_NIL:
172
- block_length_int = KT_DEFAULT_BLOCK_LENGTH;
173
- break;
174
- case T_FIXNUM:
175
- block_length_int = FIX2INT(block_length);
176
- check_block_length(block_length_int);
177
- break;
178
- default:
179
- rb_raise(rb_eTypeError, "Invalid value type for block length.");
180
- }
181
-
182
197
  switch (TYPE(customization)) {
183
198
  case T_NIL:
184
199
  case T_STRING:
@@ -187,8 +202,7 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
187
202
  rb_raise(rb_eTypeError, "Invalid value type for customization string.");
188
203
  }
189
204
 
190
- VALUE impl_class_name = Qnil;
191
- ID impl_class_name_id, id;
205
+ impl_class_name = Qnil;
192
206
 
193
207
  switch (TYPE(name)) {
194
208
  case T_NIL:
@@ -198,12 +212,7 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
198
212
 
199
213
  if (id == _id_auto) {
200
214
  if (customization != Qnil) {
201
- VALUE customization_hex_in_array = rb_funcall(customization, _id_unpack, 1, rb_str_new_literal("H*"));
202
- VALUE customization_hex = rb_ary_pop(customization_hex_in_array);
203
- impl_class_name = rb_sprintf("KangarooTwelve_%d_%d_%s", digest_length_int, block_length_int,
204
- StringValueCStr(customization_hex));
205
- } else if (block_length_int != KT_DEFAULT_BLOCK_LENGTH) {
206
- impl_class_name = rb_sprintf("KangarooTwelve_%d_%d", digest_length_int, block_length_int);
215
+ impl_class_name = hex_encode_str(customization);
207
216
  } else {
208
217
  impl_class_name = rb_sprintf("KangarooTwelve_%d", digest_length_int);
209
218
  }
@@ -228,13 +237,11 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
228
237
  rb_raise(rb_eTypeError, "Invalid argument type for class name.");
229
238
  }
230
239
 
231
- VALUE impl_class;
232
-
233
240
  if (impl_class_name == Qnil) {
234
- impl_class = rb_funcall(rb_cClass, _id_new, 1, _class_Digest_KangarooTwelve_Impl);
241
+ impl_class = rb_funcall(rb_cClass, _id_new, 1, _Digest_KangarooTwelve_Impl);
235
242
  } else {
236
- if (rb_const_defined(_module_Digest, impl_class_name_id)) {
237
- impl_class = rb_const_get(_module_Digest, impl_class_name_id);
243
+ if (rb_const_defined(_Digest, impl_class_name_id)) {
244
+ impl_class = rb_const_get(_Digest, impl_class_name_id);
238
245
 
239
246
  if (TYPE(impl_class) != T_CLASS) {
240
247
  rb_raise(rb_eTypeError,
@@ -242,13 +249,13 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
242
249
  StringValueCStr(impl_class_name));
243
250
  }
244
251
 
245
- if (rb_class_superclass(impl_class) != _class_Digest_KangarooTwelve_Impl) {
252
+ if (rb_class_superclass(impl_class) != _Digest_KangarooTwelve_Impl) {
246
253
  rb_raise(rb_eTypeError,
247
254
  "Digest::%s was already defined but not derived from Digest::KangarooTwelve::Impl.",
248
255
  StringValueCStr(impl_class_name));
249
256
  }
250
257
 
251
- VALUE prev_digest_length = rb_ivar_get(impl_class, _id_digest_length);
258
+ prev_digest_length = rb_ivar_get(impl_class, _id_digest_length);
252
259
 
253
260
  if (TYPE(prev_digest_length) != T_FIXNUM) {
254
261
  rb_raise(rb_eRuntimeError,
@@ -256,7 +263,7 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
256
263
  StringValueCStr(impl_class_name));
257
264
  }
258
265
 
259
- int prev_digest_length_int = FIX2INT(prev_digest_length);
266
+ prev_digest_length_int = FIX2INT(prev_digest_length);
260
267
 
261
268
  if (prev_digest_length_int != digest_length_int) {
262
269
  rb_raise(rb_eTypeError,
@@ -266,37 +273,17 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
266
273
  digest_length_int);
267
274
  }
268
275
 
269
- VALUE prev_block_length = rb_ivar_get(impl_class, _id_block_length);
270
-
271
- if (TYPE(prev_block_length) != T_FIXNUM) {
272
- rb_raise(rb_eRuntimeError,
273
- "Previous definition of Digest::%s has invalid block length value type.",
274
- StringValueCStr(impl_class_name));
275
- }
276
-
277
- int prev_block_length_int = FIX2INT(prev_block_length);
278
-
279
- if (prev_block_length_int != block_length_int) {
280
- rb_raise(rb_eTypeError,
281
- "Digest::%s was already defined but has different block length (%d instead of %d).",
282
- StringValueCStr(impl_class_name),
283
- prev_block_length_int,
284
- block_length_int);
285
- }
286
-
287
276
  return impl_class;
288
277
  }
289
278
 
290
- impl_class = rb_define_class_id_under(_module_Digest, impl_class_name_id, _class_Digest_KangarooTwelve_Impl);
279
+ impl_class = rb_define_class_id_under(_Digest, impl_class_name_id, _Digest_KangarooTwelve_Impl);
291
280
  }
292
281
 
293
- VALUE metadata_obj;
294
- rb_digest_metadata_t *metadata;
295
- metadata_obj = Data_Make_Struct(_class_Digest_KangarooTwelve_Metadata, rb_digest_metadata_t, 0, -1, metadata);
282
+ metadata_obj = Data_Make_Struct(_Digest_KangarooTwelve_Metadata, rb_digest_metadata_t, 0, -1, metadata);
296
283
 
297
284
  metadata->api_version = RUBY_DIGEST_API_VERSION;
298
285
  metadata->digest_len = digest_length_int;
299
- metadata->block_len = block_length_int;
286
+ metadata->block_len = KT_BLOCK_LENGTH;
300
287
  metadata->ctx_size = sizeof(KT_CONTEXT);
301
288
  metadata->init_func = kangarootwelve_init;
302
289
  metadata->update_func = kangarootwelve_update;
@@ -304,7 +291,7 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
304
291
 
305
292
  rb_ivar_set(impl_class, _id_metadata, metadata_obj);
306
293
  rb_ivar_set(impl_class, _id_digest_length, INT2FIX(digest_length_int));
307
- rb_ivar_set(impl_class, _id_block_length, INT2FIX(block_length_int));
294
+ rb_ivar_set(impl_class, _id_block_length, INT2FIX(KT_BLOCK_LENGTH));
308
295
  rb_ivar_set(impl_class, _id_customization, customization);
309
296
 
310
297
  return impl_class;
@@ -314,16 +301,25 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
314
301
  * Document-module: Digest::KangarooTwelve
315
302
  *
316
303
  * The Digest::KangarooTwelve module is the main component of the KangarooTwelve
317
- * extension.
304
+ * extension for Ruby.
318
305
  *
319
- * To create a hashing object, one must use one of the singleton methods in this
320
- * module to produce an implementation class, which can then be used to create
321
- * the hashing object.
306
+ * It contains singleton methods that can be used to create implementation
307
+ * classes. These implementation classes can then be used to create instances
308
+ * for producing hashes.
322
309
  *
323
- * An example to this is <code>hash = Digest::KangarooTwelve[32].new</code>.
310
+ * Example:
324
311
  *
325
- * The produced implementation class and the hash object can be used just like
326
- * any other implementation classes and instances in Digest.
312
+ * <tt>Digest::KangarooTwelve[32].new.update("one").update("two").digest</tt>
313
+ *
314
+ * The implementation classes can also be used to directly produce hashes.
315
+ *
316
+ * Example:
317
+ *
318
+ * <tt>Digest::KangarooTwelve[32].hexdigest("1234")</tt>
319
+ *
320
+ * The produced implementation classes and their instances can be used just like
321
+ * any other classes and instances in the Digest namespace that's based on
322
+ * Digest::Base.
327
323
  */
328
324
 
329
325
  /*
@@ -332,12 +328,15 @@ static VALUE implement(VALUE name, VALUE digest_length, VALUE block_length, VALU
332
328
  * Returns the default implementation class which has a digest length of 64
333
329
  * bytes, and doesn't have a customization string.
334
330
  */
335
- VALUE rbx_Digest_KangarooTwelve_singleton_default(VALUE self)
331
+ static VALUE _Digest_KangarooTwelve_singleton_default(VALUE self)
336
332
  {
337
- VALUE default_ = rb_ivar_get(self, _id_default);
333
+ VALUE default_ = Qnil;
334
+
335
+ if (rb_ivar_defined(self, _id_default) == Qtrue)
336
+ default_ = rb_ivar_get(self, _id_default);
338
337
 
339
338
  if (NIL_P(default_)) {
340
- default_ = implement(ID2SYM(_id_auto), INT2FIX(KT_DEFAULT_DIGEST_LENGTH), Qnil, Qnil);
339
+ default_ = implement(ID2SYM(_id_auto), INT2FIX(KT_DEFAULT_DIGEST_LENGTH), Qnil);
341
340
  rb_ivar_set(self, _id_default, default_);
342
341
  }
343
342
 
@@ -360,15 +359,12 @@ VALUE rbx_Digest_KangarooTwelve_singleton_default(VALUE self)
360
359
  * module.
361
360
  *
362
361
  * The default value for this option is +:auto+, and it implies automatic
363
- * generation of the name. The generated name is in the format of
364
- * Digest::KangarooTwelve_<digest_length> if neither a customization string
365
- * nor a custom block length is specified.
362
+ * generation of the name. The generated name is in the form of
363
+ * Digest::KangarooTwelve_<digest_length> if a customization string is not
364
+ * specified.
366
365
  *
367
- * If a customization string is specified, the format would become
368
- * Digest::KangarooTwelve_<digest_length>_<block_length>_<cust_str_hex>.
369
- *
370
- * If no customization string is specified but a custom block is, the format
371
- * would be Digest::KangarooTwelve_<digest_length>_<block_length>.
366
+ * If a customization string is specified, the format would be
367
+ * Digest::KangarooTwelve_<digest_length>_<cust_str_hex>.
372
368
  *
373
369
  * Specifying a string would make the method produce Digest::<string>.
374
370
  *
@@ -381,30 +377,25 @@ VALUE rbx_Digest_KangarooTwelve_singleton_default(VALUE self)
381
377
  *
382
378
  * See Digest::KangarooTwelve::DEFAULT_DIGEST_LENGTH for the default value.
383
379
  *
384
- * :b, :block_length ::
385
- * Specifies a custom block length. This doesn't affect the digest results
386
- * and is mostly just used for tweaking performance or memory usage. Examine
387
- * the update function in KangarooTwelve.c to know if this is needed to be
388
- * configured.
389
- *
390
- * See Digest::KangarooTwelve::DEFAULT_BLOCK_LENGTH for the default value.
391
- *
392
380
  * :c, :customization ::
393
381
  * Specifies the customization string. Adding a customization string changes
394
382
  * the resulting digest of every input.
395
383
  *
396
- * Calling the method with no argument would be the same as calling the
384
+ * :ch, :customization_hex ::
385
+ * Specifies the customization string in hex mode.
386
+ *
387
+ * Calling the method with no argument is the same as calling the
397
388
  * Digest::KangarooTwelve::default method.
398
389
  */
399
- VALUE rbx_Digest_KangarooTwelve_singleton_implement(int argc, VALUE *argv, VALUE self)
390
+ static VALUE _Digest_KangarooTwelve_singleton_implement(int argc, VALUE *argv, VALUE self)
400
391
  {
401
- VALUE opts, name, digest_length, block_length, customization;
392
+ VALUE opts, name, digest_length, customization;
402
393
 
403
394
  rb_scan_args(argc, argv, "0:", &opts);
404
395
 
405
396
  if (NIL_P(opts)) {
406
397
  name = ID2SYM(_id_auto);
407
- digest_length = block_length = customization = Qnil;
398
+ digest_length = customization = Qnil;
408
399
  } else {
409
400
  name = rb_hash_lookup2(opts, ID2SYM(_id_n), Qundef);
410
401
 
@@ -416,18 +407,29 @@ VALUE rbx_Digest_KangarooTwelve_singleton_implement(int argc, VALUE *argv, VALUE
416
407
  if (digest_length == Qundef)
417
408
  digest_length = rb_hash_lookup2(opts, ID2SYM(_id_digest_length), Qnil);
418
409
 
419
- block_length = rb_hash_lookup2(opts, ID2SYM(_id_b), Qundef);
420
-
421
- if (block_length == Qundef)
422
- block_length = rb_hash_lookup2(opts, ID2SYM(_id_block_length), Qnil);
423
-
424
410
  customization = rb_hash_lookup2(opts, ID2SYM(_id_c), Qundef);
425
411
 
426
412
  if (customization == Qundef)
427
- customization = rb_hash_lookup2(opts, ID2SYM(_id_customization), Qnil);
413
+ customization = rb_hash_lookup2(opts, ID2SYM(_id_customization), Qundef);
414
+
415
+ if (customization == Qundef) {
416
+ VALUE customization_hex = rb_hash_lookup2(opts, ID2SYM(_id_customization_hex), Qundef);
417
+
418
+ if (customization_hex == Qundef)
419
+ customization_hex = rb_hash_lookup2(opts, ID2SYM(_id_ch), Qundef);
420
+
421
+ if (customization_hex == Qundef) {
422
+ customization = Qnil;
423
+ } else {
424
+ if (TYPE(customization_hex) != T_STRING)
425
+ rb_raise(rb_eTypeError, "Customization argument not a string.");
426
+
427
+ customization = hex_decode_str(customization_hex);
428
+ }
429
+ }
428
430
  }
429
431
 
430
- return implement(name, digest_length, block_length, customization);
432
+ return implement(name, digest_length, customization);
431
433
  }
432
434
 
433
435
  /*
@@ -440,9 +442,9 @@ VALUE rbx_Digest_KangarooTwelve_singleton_implement(int argc, VALUE *argv, VALUE
440
442
  * Digest::KangarooTwelve_<digest_length>, and can be directly referenced after
441
443
  * this method is called.
442
444
  */
443
- VALUE rbx_Digest_KangarooTwelve_singleton_implement_simple(VALUE self, VALUE digest_length)
445
+ static VALUE _Digest_KangarooTwelve_singleton_implement_simple(VALUE self, VALUE digest_length)
444
446
  {
445
- return implement(ID2SYM(_id_auto), digest_length, Qnil, Qnil);
447
+ return implement(ID2SYM(_id_auto), digest_length, Qnil);
446
448
  }
447
449
 
448
450
  /*
@@ -459,12 +461,12 @@ VALUE rbx_Digest_KangarooTwelve_singleton_implement_simple(VALUE self, VALUE dig
459
461
  *
460
462
  * Creates a new object instance of the implementation class.
461
463
  */
462
- VALUE rbx_Digest_KangarooTwelve_Impl_singleton_new(VALUE self)
464
+ static VALUE _Digest_KangarooTwelve_Impl_singleton_new(VALUE self)
463
465
  {
464
- if (self == _class_Digest_KangarooTwelve_Impl)
466
+ if (self == _Digest_KangarooTwelve_Impl)
465
467
  rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
466
468
 
467
- if (rb_obj_class(rb_ivar_get(self, _id_metadata)) != _class_Digest_KangarooTwelve_Metadata)
469
+ if (rb_ivar_defined(self, _id_metadata) == Qfalse || rb_obj_class(rb_ivar_get(self, _id_metadata)) != _Digest_KangarooTwelve_Metadata)
468
470
  rb_raise(rb_eRuntimeError, "Metadata not set or invalid. Please do not manually inherit KangarooTwelve.");
469
471
 
470
472
  return rb_call_super(0, 0);
@@ -475,9 +477,9 @@ VALUE rbx_Digest_KangarooTwelve_Impl_singleton_new(VALUE self)
475
477
  *
476
478
  * Returns configured digest length of the implementation class.
477
479
  */
478
- VALUE rbx_Digest_KangarooTwelve_Impl_singleton_digest_length(VALUE self)
480
+ static VALUE _Digest_KangarooTwelve_Impl_singleton_digest_length(VALUE self)
479
481
  {
480
- if (self == _class_Digest_KangarooTwelve_Impl)
482
+ if (self == _Digest_KangarooTwelve_Impl)
481
483
  rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
482
484
 
483
485
  return rb_ivar_get(self, _id_digest_length);
@@ -486,14 +488,11 @@ VALUE rbx_Digest_KangarooTwelve_Impl_singleton_digest_length(VALUE self)
486
488
  /*
487
489
  * call-seq: block_length -> int
488
490
  *
489
- * Returns configured block length of the implementation class.
491
+ * Returns 8192.
490
492
  */
491
- VALUE rbx_Digest_KangarooTwelve_Impl_singleton_block_length(VALUE self)
493
+ static VALUE _Digest_KangarooTwelve_Impl_singleton_block_length(VALUE self)
492
494
  {
493
- if (self == _class_Digest_KangarooTwelve_Impl)
494
- rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
495
-
496
- return rb_ivar_get(self, _id_block_length);
495
+ return INT2FIX(KT_BLOCK_LENGTH);
497
496
  }
498
497
 
499
498
  /*
@@ -501,12 +500,36 @@ VALUE rbx_Digest_KangarooTwelve_Impl_singleton_block_length(VALUE self)
501
500
  *
502
501
  * Returns configured customization string of the implementation class.
503
502
  */
504
- VALUE rbx_Digest_KangarooTwelve_Impl_singleton_customization(VALUE self)
503
+ static VALUE _Digest_KangarooTwelve_Impl_singleton_customization(VALUE self)
505
504
  {
506
- if (self == _class_Digest_KangarooTwelve_Impl)
505
+ if (self == _Digest_KangarooTwelve_Impl)
507
506
  rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
508
507
 
509
- return rb_ivar_get(self, _id_customization);
508
+ return rb_ivar_defined(self, _id_customization) == Qtrue ? rb_ivar_get(self, _id_customization) : Qnil;
509
+ }
510
+
511
+ /*
512
+ * call-seq: customization_hex -> string or nil
513
+ *
514
+ * Returns configured customization string of the implementation class in hex.
515
+ */
516
+ static VALUE _Digest_KangarooTwelve_Impl_singleton_customization_hex(VALUE self)
517
+ {
518
+ if (self == _Digest_KangarooTwelve_Impl)
519
+ rb_raise(rb_eRuntimeError, "Digest::KangarooTwelve::Impl is an abstract class.");
520
+
521
+ if (rb_ivar_defined(self, _id_customization)) {
522
+ VALUE customization = rb_ivar_get(self, _id_customization);
523
+
524
+ if (!NIL_P(customization)) {
525
+ if (TYPE(customization) != T_STRING)
526
+ rb_raise(rb_eTypeError, "Unexpected class for a customization string.");
527
+
528
+ return hex_encode_str(customization);
529
+ }
530
+ }
531
+
532
+ return Qnil;
510
533
  }
511
534
 
512
535
  /*
@@ -514,7 +537,7 @@ VALUE rbx_Digest_KangarooTwelve_Impl_singleton_customization(VALUE self)
514
537
  *
515
538
  * Returns configured customization string of the implementation object.
516
539
  */
517
- VALUE rbx_Digest_KangarooTwelve_Impl_customization(VALUE self)
540
+ static VALUE _Digest_KangarooTwelve_Impl_customization(VALUE self)
518
541
  {
519
542
  VALUE customization;
520
543
 
@@ -529,26 +552,41 @@ VALUE rbx_Digest_KangarooTwelve_Impl_customization(VALUE self)
529
552
  return customization;
530
553
  }
531
554
 
555
+ /*
556
+ * call-seq: customization_hex -> string or nil
557
+ *
558
+ * Returns configured customization string of the implementation object in hex.
559
+ */
560
+ static VALUE _Digest_KangarooTwelve_Impl_customization_hex(VALUE self)
561
+ {
562
+ VALUE customization = rb_funcall(self, _id_customization, 0);
563
+ return hex_encode_str(customization);
564
+ }
565
+
532
566
  /*
533
567
  * call-seq: inspect -> string
534
568
  *
535
- * Returns a string in the format of #<implementation_class_name|digest_length|block_length|customization_string|digest>
569
+ * Returns a string in the form of #<impl_class_name|digest_length|hex_cust_string|hex_digest>
536
570
  */
537
- VALUE rbx_Digest_KangarooTwelve_inspect(VALUE self)
571
+ static VALUE _Digest_KangarooTwelve_Impl_inspect(VALUE self)
538
572
  {
539
- VALUE klass = rb_obj_class(self);
540
- VALUE klass_name = rb_class_name(klass);
573
+ VALUE klass, klass_name, digest_length, customization_hex, hexdigest, args[4];
574
+
575
+ klass = rb_obj_class(self);
576
+ klass_name = rb_class_name(klass);
541
577
 
542
578
  if (klass_name == Qnil)
543
579
  klass_name = rb_inspect(klass);
544
580
 
545
- VALUE digest_length = rb_funcall(self, _id_digest_length, 0);
546
- VALUE block_length = rb_funcall(self, _id_block_length, 0);
547
- VALUE customization = rb_funcall(self, _id_customization, 0);
548
- VALUE hexdigest = rb_funcall(self, _id_hexdigest, 0);
581
+ digest_length = rb_funcall(self, _id_digest_length, 0);
582
+ customization_hex = rb_funcall(self, _id_customization_hex, 0);
583
+ hexdigest = rb_funcall(self, _id_hexdigest, 0);
549
584
 
550
- VALUE args[] = { klass_name, digest_length, block_length, customization, hexdigest };
551
- return rb_str_format(sizeof(args), args, rb_str_new_literal("#<%s|%d|%d|%s|%s>"));
585
+ args[0] = klass_name;
586
+ args[1] = digest_length;
587
+ args[2] = customization_hex;
588
+ args[3] = hexdigest;
589
+ return rb_str_format(sizeof(args), args, rb_str_new_literal("#<%s:%d|%s|%s>"));
552
590
  }
553
591
 
554
592
  /*
@@ -562,7 +600,9 @@ void Init_kangarootwelve()
562
600
  DEFINE_ID(auto)
563
601
  DEFINE_ID(block_length)
564
602
  DEFINE_ID(b)
603
+ DEFINE_ID(ch)
565
604
  DEFINE_ID(customization)
605
+ DEFINE_ID(customization_hex)
566
606
  DEFINE_ID(c)
567
607
  DEFINE_ID(default)
568
608
  DEFINE_ID(digest_length)
@@ -575,66 +615,77 @@ void Init_kangarootwelve()
575
615
  DEFINE_ID(unpack)
576
616
 
577
617
  rb_require("digest");
578
- _module_Digest = rb_path2class("Digest");
579
- _class_Digest_Base = rb_path2class("Digest::Base");
618
+ _Digest = rb_path2class("Digest");
580
619
 
581
620
  #if 0
582
- _module_Digest = rb_define_module("Digest"); /* Tell RDoc about Digest since it doesn't recognize rb_path2class. */
621
+ _Digest = rb_define_module("Digest"); /* Tell RDoc about Digest since it doesn't recognize rb_path2class. */
583
622
  #endif
584
623
 
585
624
  /*
586
- * module Digest::KangarooTwelve
625
+ * Document-module: Digest::KangarooTwelve
587
626
  */
588
627
 
589
- _module_Digest_KangarooTwelve = rb_define_module_under(_module_Digest, "KangarooTwelve");
628
+ _Digest_KangarooTwelve = rb_define_module_under(_Digest, "KangarooTwelve");
590
629
 
591
- rb_define_singleton_method(_module_Digest_KangarooTwelve, "default",
592
- rbx_Digest_KangarooTwelve_singleton_default, 0);
593
- rb_define_singleton_method(_module_Digest_KangarooTwelve, "implement",
594
- rbx_Digest_KangarooTwelve_singleton_implement, -1);
595
- rb_define_singleton_method(_module_Digest_KangarooTwelve, "[]",
596
- rbx_Digest_KangarooTwelve_singleton_implement_simple, 1);
630
+ rb_define_singleton_method(_Digest_KangarooTwelve, "default",
631
+ _Digest_KangarooTwelve_singleton_default, 0);
632
+ rb_define_singleton_method(_Digest_KangarooTwelve, "implement",
633
+ _Digest_KangarooTwelve_singleton_implement, -1);
634
+ rb_define_singleton_method(_Digest_KangarooTwelve, "[]",
635
+ _Digest_KangarooTwelve_singleton_implement_simple, 1);
597
636
 
598
637
  /*
599
- * Currently 65536 bytes (8192 x 8)
638
+ * Document-const: Digest::KangarooTwelve::BLOCK_LENGTH
639
+ *
640
+ * 8192 bytes
600
641
  */
601
642
 
602
- rb_define_const(_module_Digest_KangarooTwelve, "DEFAULT_BLOCK_LENGTH", INT2FIX(KT_DEFAULT_BLOCK_LENGTH));
643
+ /* 8192 bytes */
644
+
645
+ rb_define_const(_Digest_KangarooTwelve, "BLOCK_LENGTH", INT2FIX(KT_BLOCK_LENGTH));
603
646
 
604
647
  /*
648
+ * Document-const: Digest::KangarooTwelve::DEFAULT_DIGEST_LENGTH
649
+ *
605
650
  * 64 bytes (512 bits)
606
651
  */
607
652
 
608
- rb_define_const(_module_Digest_KangarooTwelve, "DEFAULT_DIGEST_LENGTH", INT2FIX(KT_DEFAULT_DIGEST_LENGTH));
653
+ /* 64 bytes (512 bits) */
654
+
655
+ rb_define_const(_Digest_KangarooTwelve, "DEFAULT_DIGEST_LENGTH", INT2FIX(KT_DEFAULT_DIGEST_LENGTH));
609
656
 
610
657
  /*
611
- * class Digest::KangarooTwelve::Impl < Digest::Base
658
+ * Document-class: Digest::KangarooTwelve::Impl
612
659
  */
613
660
 
614
- _class_Digest_KangarooTwelve_Impl = rb_define_class_under(_module_Digest_KangarooTwelve, "Impl",
615
- _class_Digest_Base);
616
-
617
- rb_define_singleton_method(_class_Digest_KangarooTwelve_Impl, "new",
618
- rbx_Digest_KangarooTwelve_Impl_singleton_new, 0);
619
- rb_define_singleton_method(_class_Digest_KangarooTwelve_Impl, "block_length",
620
- rbx_Digest_KangarooTwelve_Impl_singleton_block_length, 0);
621
- rb_define_singleton_method(_class_Digest_KangarooTwelve_Impl, "digest_length",
622
- rbx_Digest_KangarooTwelve_Impl_singleton_digest_length, 0);
623
- rb_define_singleton_method(_class_Digest_KangarooTwelve_Impl, "customization",
624
- rbx_Digest_KangarooTwelve_Impl_singleton_customization, 0);
625
-
626
- rb_define_method(_class_Digest_KangarooTwelve_Impl, "customization",
627
- rbx_Digest_KangarooTwelve_Impl_customization, 0);
628
- rb_define_method(_class_Digest_KangarooTwelve_Impl, "inspect",
629
- rbx_Digest_KangarooTwelve_inspect, 0);
661
+ _Digest_KangarooTwelve_Impl = rb_define_class_under(_Digest_KangarooTwelve, "Impl",
662
+ rb_path2class("Digest::Base"));
663
+
664
+ rb_define_singleton_method(_Digest_KangarooTwelve_Impl, "new",
665
+ _Digest_KangarooTwelve_Impl_singleton_new, 0);
666
+ rb_define_singleton_method(_Digest_KangarooTwelve_Impl, "block_length",
667
+ _Digest_KangarooTwelve_Impl_singleton_block_length, 0);
668
+ rb_define_singleton_method(_Digest_KangarooTwelve_Impl, "digest_length",
669
+ _Digest_KangarooTwelve_Impl_singleton_digest_length, 0);
670
+ rb_define_singleton_method(_Digest_KangarooTwelve_Impl, "customization",
671
+ _Digest_KangarooTwelve_Impl_singleton_customization, 0);
672
+ rb_define_singleton_method(_Digest_KangarooTwelve_Impl, "customization_hex",
673
+ _Digest_KangarooTwelve_Impl_singleton_customization_hex, 0);
674
+
675
+ rb_define_method(_Digest_KangarooTwelve_Impl, "customization",
676
+ _Digest_KangarooTwelve_Impl_customization, 0);
677
+ rb_define_method(_Digest_KangarooTwelve_Impl, "customization_hex",
678
+ _Digest_KangarooTwelve_Impl_customization_hex, 0);
679
+ rb_define_method(_Digest_KangarooTwelve_Impl, "inspect",
680
+ _Digest_KangarooTwelve_Impl_inspect, 0);
630
681
 
631
682
  /*
632
- * class Digest::KangarooTwelve::Metadata < Data
683
+ * Document-class: Digest::KangarooTwelve::Metadata
633
684
  *
634
685
  * This class represents the internal metadata produced for the
635
686
  * implementation classes.
636
687
  */
637
688
 
638
- _class_Digest_KangarooTwelve_Metadata = rb_define_class_under(_module_Digest_KangarooTwelve, "Metadata",
639
- rb_path2class("Data"));
689
+ _Digest_KangarooTwelve_Metadata = rb_define_class_under(_Digest_KangarooTwelve, "Metadata",
690
+ rb_cObject);
640
691
  }