rbnacl-libsodium 0.4.5a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (409) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +35 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGES.md +3 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE +21 -0
  7. data/README.md +23 -0
  8. data/Rakefile +1 -0
  9. data/ext/rbnacl/extconf.rb +30 -0
  10. data/lib/rbnacl/libsodium.rb +11 -0
  11. data/lib/rbnacl/libsodium/version.rb +5 -0
  12. data/rbnacl-libsodium.gemspec +25 -0
  13. data/vendor/libsodium/AUTHORS +101 -0
  14. data/vendor/libsodium/ChangeLog +68 -0
  15. data/vendor/libsodium/LICENSE +16 -0
  16. data/vendor/libsodium/Makefile.am +20 -0
  17. data/vendor/libsodium/README +1 -0
  18. data/vendor/libsodium/README.markdown +246 -0
  19. data/vendor/libsodium/THANKS +17 -0
  20. data/vendor/libsodium/autogen.sh +16 -0
  21. data/vendor/libsodium/configure.ac +405 -0
  22. data/vendor/libsodium/dist-build/android.sh +48 -0
  23. data/vendor/libsodium/dist-build/iphone.sh +16 -0
  24. data/vendor/libsodium/dist-build/msys.sh +9 -0
  25. data/vendor/libsodium/libsodium.pc.in +11 -0
  26. data/vendor/libsodium/libsodium.sln +38 -0
  27. data/vendor/libsodium/libsodium.vcxproj +508 -0
  28. data/vendor/libsodium/libsodium.vcxproj.filters +569 -0
  29. data/vendor/libsodium/logo.png +0 -0
  30. data/vendor/libsodium/m4/ax_check_compile_flag.m4 +73 -0
  31. data/vendor/libsodium/m4/ax_check_gnu_make.m4 +78 -0
  32. data/vendor/libsodium/m4/ax_check_link_flag.m4 +72 -0
  33. data/vendor/libsodium/m4/ld-output-def.m4 +29 -0
  34. data/vendor/libsodium/m4/pkg.m4 +214 -0
  35. data/vendor/libsodium/msvc-scripts/Makefile.am +4 -0
  36. data/vendor/libsodium/msvc-scripts/process.bat +8 -0
  37. data/vendor/libsodium/msvc-scripts/rep.vbs +12 -0
  38. data/vendor/libsodium/msvc-scripts/sodium.props +25 -0
  39. data/vendor/libsodium/src/Makefile.am +3 -0
  40. data/vendor/libsodium/src/libsodium/Makefile.am +232 -0
  41. data/vendor/libsodium/src/libsodium/crypto_auth/crypto_auth.c +34 -0
  42. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +16 -0
  43. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/checksum +1 -0
  44. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/api.h +10 -0
  45. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/hmac_hmacsha256.c +83 -0
  46. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/verify_hmacsha256.c +9 -0
  47. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +16 -0
  48. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/checksum +1 -0
  49. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/api.h +10 -0
  50. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/hmac_hmacsha512256.c +86 -0
  51. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/verify_hmacsha512256.c +9 -0
  52. data/vendor/libsodium/src/libsodium/crypto_auth/try.c +119 -0
  53. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +95 -0
  54. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +41 -0
  55. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/checksum +1 -0
  56. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +22 -0
  57. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +19 -0
  58. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +19 -0
  59. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +27 -0
  60. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +12 -0
  61. data/vendor/libsodium/src/libsodium/crypto_box/try.c +195 -0
  62. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/checksum +1 -0
  63. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/core_hsalsa20_api.c +26 -0
  64. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +11 -0
  65. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +108 -0
  66. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/checksum +1 -0
  67. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c +26 -0
  68. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +11 -0
  69. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +134 -0
  70. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/checksum +1 -0
  71. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c +26 -0
  72. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +11 -0
  73. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +134 -0
  74. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/checksum +1 -0
  75. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c +26 -0
  76. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +11 -0
  77. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +134 -0
  78. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +31 -0
  79. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +4 -0
  80. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +132 -0
  81. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +169 -0
  82. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +364 -0
  83. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +355 -0
  84. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +61 -0
  85. data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +84 -0
  86. data/vendor/libsodium/src/libsodium/crypto_hash/crypto_hash.c +9 -0
  87. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/checksum +1 -0
  88. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/hash_sha256_api.c +11 -0
  89. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/ref/api.h +8 -0
  90. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/ref/hash_sha256.c +69 -0
  91. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/checksum +1 -0
  92. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c +11 -0
  93. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/ref/api.h +8 -0
  94. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/ref/hash_sha512.c +71 -0
  95. data/vendor/libsodium/src/libsodium/crypto_hash/try.c +76 -0
  96. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/checksum +1 -0
  97. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/hashblocks_sha256_api.c +16 -0
  98. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/api.h +9 -0
  99. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/blocks_sha256.c +212 -0
  100. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/checksum +1 -0
  101. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/hashblocks_sha512_api.c +16 -0
  102. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/api.h +9 -0
  103. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/blocks_sha512.c +239 -0
  104. data/vendor/libsodium/src/libsodium/crypto_hashblocks/try.c +78 -0
  105. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +34 -0
  106. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/api.h +8 -0
  107. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/auth_poly1305_53.c +1661 -0
  108. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/verify_poly1305_53.c +10 -0
  109. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/api.h +8 -0
  110. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +151 -0
  111. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h +772 -0
  112. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/verify_poly1305_donna.c +10 -0
  113. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +36 -0
  114. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c +16 -0
  115. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +152 -0
  116. data/vendor/libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c +34 -0
  117. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/checksum +1 -0
  118. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +9 -0
  119. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/base_curve25519_donna_c64.c +13 -0
  120. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +426 -0
  121. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/api.h +8 -0
  122. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/base_curve25519_ref.c +20 -0
  123. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/smult_curve25519_ref.c +268 -0
  124. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519_api.c +14 -0
  125. data/vendor/libsodium/src/libsodium/crypto_scalarmult/try.c +125 -0
  126. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +48 -0
  127. data/vendor/libsodium/src/libsodium/crypto_secretbox/try.c +129 -0
  128. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/checksum +1 -0
  129. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +12 -0
  130. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +35 -0
  131. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c +26 -0
  132. data/vendor/libsodium/src/libsodium/crypto_shorthash/crypto_shorthash.c +27 -0
  133. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +8 -0
  134. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +91 -0
  135. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphash24_api.c +11 -0
  136. data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +61 -0
  137. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/description +1 -0
  138. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +14 -0
  139. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/base.h +1344 -0
  140. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/base2.h +40 -0
  141. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/d.h +1 -0
  142. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/d2.h +1 -0
  143. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe.h +56 -0
  144. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_0.c +19 -0
  145. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_1.c +19 -0
  146. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c +57 -0
  147. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c +63 -0
  148. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c +29 -0
  149. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +73 -0
  150. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_invert.c +14 -0
  151. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnegative.c +16 -0
  152. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c +19 -0
  153. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +253 -0
  154. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c +45 -0
  155. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_pow22523.c +13 -0
  156. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +149 -0
  157. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +160 -0
  158. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c +57 -0
  159. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c +119 -0
  160. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge.h +95 -0
  161. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.c +11 -0
  162. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.h +97 -0
  163. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_double_scalarmult.c +96 -0
  164. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_frombytes.c +50 -0
  165. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.c +11 -0
  166. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.h +88 -0
  167. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.c +11 -0
  168. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.h +88 -0
  169. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p2.c +12 -0
  170. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p3.c +13 -0
  171. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_0.c +8 -0
  172. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.c +11 -0
  173. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.h +73 -0
  174. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_0.c +9 -0
  175. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_dbl.c +12 -0
  176. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_cached.c +17 -0
  177. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_p2.c +12 -0
  178. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_tobytes.c +14 -0
  179. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_precomp_0.c +8 -0
  180. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +105 -0
  181. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.c +11 -0
  182. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.h +97 -0
  183. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_tobytes.c +14 -0
  184. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +31 -0
  185. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +40 -0
  186. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow22523.h +160 -0
  187. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow225521.h +160 -0
  188. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc.h +15 -0
  189. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c +368 -0
  190. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c +275 -0
  191. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +38 -0
  192. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sqrtm1.h +1 -0
  193. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +26 -0
  194. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +13 -0
  195. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519.h +54 -0
  196. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c +348 -0
  197. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519.h +34 -0
  198. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519_edwards25519sha512batch.c +230 -0
  199. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519.h +51 -0
  200. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +146 -0
  201. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +102 -0
  202. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +21 -0
  203. data/vendor/libsodium/src/libsodium/crypto_sign/try.c +87 -0
  204. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/checksum +1 -0
  205. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +159 -0
  206. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +14 -0
  207. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +59 -0
  208. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +788 -0
  209. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c +64 -0
  210. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts.h +28 -0
  211. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +14 -0
  212. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +47 -0
  213. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +131 -0
  214. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +28 -0
  215. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +10 -0
  216. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +181 -0
  217. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr_api.c +21 -0
  218. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-be.h +274 -0
  219. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-le.h +274 -0
  220. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table.h +56 -0
  221. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +238 -0
  222. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256.h +171 -0
  223. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/api.h +14 -0
  224. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/ecrypt-sync.h +27 -0
  225. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/stream_aes256estream_api.c +21 -0
  226. data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +36 -0
  227. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/api.h +1 -0
  228. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +950 -0
  229. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/checksum +1 -0
  230. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +8 -0
  231. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +55 -0
  232. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +58 -0
  233. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +16 -0
  234. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/checksum +1 -0
  235. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +11 -0
  236. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +51 -0
  237. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +54 -0
  238. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c +16 -0
  239. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/checksum +1 -0
  240. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +10 -0
  241. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +51 -0
  242. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +54 -0
  243. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c +16 -0
  244. data/vendor/libsodium/src/libsodium/crypto_stream/try.c +122 -0
  245. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/checksum +1 -0
  246. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +11 -0
  247. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +24 -0
  248. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +25 -0
  249. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c +16 -0
  250. data/vendor/libsodium/src/libsodium/crypto_verify/16/checksum +1 -0
  251. data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/api.h +2 -0
  252. data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +24 -0
  253. data/vendor/libsodium/src/libsodium/crypto_verify/16/verify_16_api.c +6 -0
  254. data/vendor/libsodium/src/libsodium/crypto_verify/32/checksum +1 -0
  255. data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/api.h +2 -0
  256. data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +40 -0
  257. data/vendor/libsodium/src/libsodium/crypto_verify/32/verify_32_api.c +6 -0
  258. data/vendor/libsodium/src/libsodium/crypto_verify/try.c +76 -0
  259. data/vendor/libsodium/src/libsodium/include/Makefile.am +63 -0
  260. data/vendor/libsodium/src/libsodium/include/sodium.h +48 -0
  261. data/vendor/libsodium/src/libsodium/include/sodium/core.h +18 -0
  262. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +36 -0
  263. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +36 -0
  264. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +36 -0
  265. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +83 -0
  266. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +72 -0
  267. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hsalsa20.h +40 -0
  268. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa20.h +40 -0
  269. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa2012.h +40 -0
  270. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +40 -0
  271. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +70 -0
  272. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +87 -0
  273. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +23 -0
  274. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +29 -0
  275. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +29 -0
  276. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha256.h +32 -0
  277. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha512.h +32 -0
  278. data/vendor/libsodium/src/libsodium/include/sodium/crypto_int32.h +8 -0
  279. data/vendor/libsodium/src/libsodium/include/sodium/crypto_int64.h +8 -0
  280. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +37 -0
  281. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +65 -0
  282. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h +34 -0
  283. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +34 -0
  284. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult.h +36 -0
  285. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in +44 -0
  286. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +47 -0
  287. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +44 -0
  288. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +33 -0
  289. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +29 -0
  290. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +61 -0
  291. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +52 -0
  292. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +44 -0
  293. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +46 -0
  294. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +60 -0
  295. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +61 -0
  296. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h.in +54 -0
  297. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +43 -0
  298. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +43 -0
  299. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +44 -0
  300. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint16.h +8 -0
  301. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint32.h +8 -0
  302. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint64.h +8 -0
  303. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint8.h +8 -0
  304. data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_16.h +25 -0
  305. data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_32.h +25 -0
  306. data/vendor/libsodium/src/libsodium/include/sodium/export.h +32 -0
  307. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +53 -0
  308. data/vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h +45 -0
  309. data/vendor/libsodium/src/libsodium/include/sodium/randombytes_sysrandom.h +45 -0
  310. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +36 -0
  311. data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +29 -0
  312. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +63 -0
  313. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +317 -0
  314. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +212 -0
  315. data/vendor/libsodium/src/libsodium/sodium/compat.c +248 -0
  316. data/vendor/libsodium/src/libsodium/sodium/core.c +21 -0
  317. data/vendor/libsodium/src/libsodium/sodium/utils.c +94 -0
  318. data/vendor/libsodium/src/libsodium/sodium/version.c +20 -0
  319. data/vendor/libsodium/test/Makefile.am +5 -0
  320. data/vendor/libsodium/test/default/Makefile.am +277 -0
  321. data/vendor/libsodium/test/default/auth.c +21 -0
  322. data/vendor/libsodium/test/default/auth.exp +4 -0
  323. data/vendor/libsodium/test/default/auth2.c +36 -0
  324. data/vendor/libsodium/test/default/auth2.exp +4 -0
  325. data/vendor/libsodium/test/default/auth3.c +36 -0
  326. data/vendor/libsodium/test/default/auth3.exp +1 -0
  327. data/vendor/libsodium/test/default/auth5.c +37 -0
  328. data/vendor/libsodium/test/default/auth5.exp +0 -0
  329. data/vendor/libsodium/test/default/box.c +65 -0
  330. data/vendor/libsodium/test/default/box.exp +19 -0
  331. data/vendor/libsodium/test/default/box2.c +66 -0
  332. data/vendor/libsodium/test/default/box2.exp +17 -0
  333. data/vendor/libsodium/test/default/box7.c +37 -0
  334. data/vendor/libsodium/test/default/box7.exp +0 -0
  335. data/vendor/libsodium/test/default/box8.c +44 -0
  336. data/vendor/libsodium/test/default/box8.exp +0 -0
  337. data/vendor/libsodium/test/default/cmptest.h +51 -0
  338. data/vendor/libsodium/test/default/core1.c +32 -0
  339. data/vendor/libsodium/test/default/core1.exp +4 -0
  340. data/vendor/libsodium/test/default/core2.c +35 -0
  341. data/vendor/libsodium/test/default/core2.exp +4 -0
  342. data/vendor/libsodium/test/default/core3.c +42 -0
  343. data/vendor/libsodium/test/default/core3.exp +1 -0
  344. data/vendor/libsodium/test/default/core4.c +35 -0
  345. data/vendor/libsodium/test/default/core4.exp +8 -0
  346. data/vendor/libsodium/test/default/core5.c +34 -0
  347. data/vendor/libsodium/test/default/core5.exp +4 -0
  348. data/vendor/libsodium/test/default/core6.c +49 -0
  349. data/vendor/libsodium/test/default/core6.exp +4 -0
  350. data/vendor/libsodium/test/default/generichash.c +27 -0
  351. data/vendor/libsodium/test/default/generichash.exp +64 -0
  352. data/vendor/libsodium/test/default/generichash2.c +31 -0
  353. data/vendor/libsodium/test/default/generichash2.exp +64 -0
  354. data/vendor/libsodium/test/default/hash.c +16 -0
  355. data/vendor/libsodium/test/default/hash.exp +1 -0
  356. data/vendor/libsodium/test/default/hash2.exp +1 -0
  357. data/vendor/libsodium/test/default/hash3.c +16 -0
  358. data/vendor/libsodium/test/default/hash3.exp +1 -0
  359. data/vendor/libsodium/test/default/onetimeauth.c +44 -0
  360. data/vendor/libsodium/test/default/onetimeauth.exp +2 -0
  361. data/vendor/libsodium/test/default/onetimeauth2.c +42 -0
  362. data/vendor/libsodium/test/default/onetimeauth2.exp +1 -0
  363. data/vendor/libsodium/test/default/onetimeauth7.c +37 -0
  364. data/vendor/libsodium/test/default/onetimeauth7.exp +0 -0
  365. data/vendor/libsodium/test/default/pre.js +33 -0
  366. data/vendor/libsodium/test/default/randombytes.c +16 -0
  367. data/vendor/libsodium/test/default/scalarmult.c +25 -0
  368. data/vendor/libsodium/test/default/scalarmult.exp +4 -0
  369. data/vendor/libsodium/test/default/scalarmult2.c +25 -0
  370. data/vendor/libsodium/test/default/scalarmult2.exp +4 -0
  371. data/vendor/libsodium/test/default/scalarmult5.c +32 -0
  372. data/vendor/libsodium/test/default/scalarmult5.exp +4 -0
  373. data/vendor/libsodium/test/default/scalarmult6.c +32 -0
  374. data/vendor/libsodium/test/default/scalarmult6.exp +4 -0
  375. data/vendor/libsodium/test/default/scalarmult7.c +34 -0
  376. data/vendor/libsodium/test/default/scalarmult7.exp +1 -0
  377. data/vendor/libsodium/test/default/scalarmult8.c +34 -0
  378. data/vendor/libsodium/test/default/scalarmult8.exp +1 -0
  379. data/vendor/libsodium/test/default/secretbox.c +58 -0
  380. data/vendor/libsodium/test/default/secretbox.exp +19 -0
  381. data/vendor/libsodium/test/default/secretbox2.c +59 -0
  382. data/vendor/libsodium/test/default/secretbox2.exp +17 -0
  383. data/vendor/libsodium/test/default/secretbox7.c +33 -0
  384. data/vendor/libsodium/test/default/secretbox7.exp +0 -0
  385. data/vendor/libsodium/test/default/secretbox8.c +40 -0
  386. data/vendor/libsodium/test/default/secretbox8.exp +0 -0
  387. data/vendor/libsodium/test/default/shorthash.c +23 -0
  388. data/vendor/libsodium/test/default/shorthash.exp +64 -0
  389. data/vendor/libsodium/test/default/sodium_core.c +11 -0
  390. data/vendor/libsodium/test/default/sodium_core.exp +1 -0
  391. data/vendor/libsodium/test/default/sodium_utils.c +27 -0
  392. data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
  393. data/vendor/libsodium/test/default/sodium_version.c +13 -0
  394. data/vendor/libsodium/test/default/sodium_version.exp +3 -0
  395. data/vendor/libsodium/test/default/stream.c +30 -0
  396. data/vendor/libsodium/test/default/stream.exp +1 -0
  397. data/vendor/libsodium/test/default/stream2.c +28 -0
  398. data/vendor/libsodium/test/default/stream2.exp +1 -0
  399. data/vendor/libsodium/test/default/stream3.c +30 -0
  400. data/vendor/libsodium/test/default/stream3.exp +4 -0
  401. data/vendor/libsodium/test/default/stream4.c +55 -0
  402. data/vendor/libsodium/test/default/stream4.exp +17 -0
  403. data/vendor/libsodium/test/default/stream5.c +29 -0
  404. data/vendor/libsodium/test/default/stream5.exp +1 -0
  405. data/vendor/libsodium/test/default/stream6.c +54 -0
  406. data/vendor/libsodium/test/default/stream6.exp +17 -0
  407. data/vendor/libsodium/test/default/wintest.bat +56 -0
  408. data/vendor/libsodium/test/quirks/windows/windows-quirks.h +18 -0
  409. metadata +500 -0
@@ -0,0 +1,10 @@
1
+ #include "api.h"
2
+ #include "crypto_onetimeauth_poly1305_53.h"
3
+ #include "crypto_verify_16.h"
4
+
5
+ int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
6
+ {
7
+ unsigned char correct[16];
8
+ crypto_onetimeauth(correct,in,inlen,k);
9
+ return crypto_verify_16(h,correct);
10
+ }
@@ -0,0 +1,8 @@
1
+
2
+ #include "crypto_onetimeauth_poly1305.h"
3
+
4
+ #define crypto_onetimeauth_poly1305_implementation_name \
5
+ crypto_onetimeauth_poly1305_donna_implementation_name
6
+
7
+ #define crypto_onetimeauth crypto_onetimeauth_poly1305_donna
8
+ #define crypto_onetimeauth_verify crypto_onetimeauth_poly1305_donna_verify
@@ -0,0 +1,151 @@
1
+
2
+ #include "api.h"
3
+ #include "crypto_onetimeauth_poly1305_donna.h"
4
+ #include "utils.h"
5
+
6
+ #include "portable-jane.h"
7
+
8
+ int
9
+ crypto_onetimeauth(unsigned char *out, const unsigned char *m,
10
+ unsigned long long inlen, const unsigned char *key)
11
+ {
12
+ uint32_t t0,t1,t2,t3;
13
+ uint32_t h0,h1,h2,h3,h4;
14
+ uint32_t r0,r1,r2,r3,r4;
15
+ uint32_t s1,s2,s3,s4;
16
+ uint32_t b, nb;
17
+ unsigned long long j;
18
+ uint64_t t[5];
19
+ uint64_t f0,f1,f2,f3;
20
+ uint32_t g0,g1,g2,g3,g4;
21
+ uint64_t c;
22
+ unsigned char mp[16];
23
+
24
+ /* clamp key */
25
+ t0 = U8TO32_LE(key+0);
26
+ t1 = U8TO32_LE(key+4);
27
+ t2 = U8TO32_LE(key+8);
28
+ t3 = U8TO32_LE(key+12);
29
+
30
+ /* precompute multipliers */
31
+ r0 = t0 & 0x3ffffff; t0 >>= 26; t0 |= t1 << 6;
32
+ r1 = t0 & 0x3ffff03; t1 >>= 20; t1 |= t2 << 12;
33
+ r2 = t1 & 0x3ffc0ff; t2 >>= 14; t2 |= t3 << 18;
34
+ r3 = t2 & 0x3f03fff; t3 >>= 8;
35
+ r4 = t3 & 0x00fffff;
36
+
37
+ s1 = r1 * 5;
38
+ s2 = r2 * 5;
39
+ s3 = r3 * 5;
40
+ s4 = r4 * 5;
41
+
42
+ /* init state */
43
+ h0 = 0;
44
+ h1 = 0;
45
+ h2 = 0;
46
+ h3 = 0;
47
+ h4 = 0;
48
+
49
+ /* full blocks */
50
+ if (inlen < 16) goto poly1305_donna_atmost15bytes;
51
+ poly1305_donna_16bytes:
52
+ m += 16;
53
+ inlen -= 16;
54
+
55
+ t0 = U8TO32_LE(m-16);
56
+ t1 = U8TO32_LE(m-12);
57
+ t2 = U8TO32_LE(m-8);
58
+ t3 = U8TO32_LE(m-4);
59
+
60
+ h0 += t0 & 0x3ffffff;
61
+ h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff;
62
+ h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff;
63
+ h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff;
64
+ h4 += (t3 >> 8) | (1 << 24);
65
+
66
+
67
+ poly1305_donna_mul:
68
+ t[0] = mul32x32_64(h0,r0) + mul32x32_64(h1,s4) + mul32x32_64(h2,s3) + mul32x32_64(h3,s2) + mul32x32_64(h4,s1);
69
+ t[1] = mul32x32_64(h0,r1) + mul32x32_64(h1,r0) + mul32x32_64(h2,s4) + mul32x32_64(h3,s3) + mul32x32_64(h4,s2);
70
+ t[2] = mul32x32_64(h0,r2) + mul32x32_64(h1,r1) + mul32x32_64(h2,r0) + mul32x32_64(h3,s4) + mul32x32_64(h4,s3);
71
+ t[3] = mul32x32_64(h0,r3) + mul32x32_64(h1,r2) + mul32x32_64(h2,r1) + mul32x32_64(h3,r0) + mul32x32_64(h4,s4);
72
+ t[4] = mul32x32_64(h0,r4) + mul32x32_64(h1,r3) + mul32x32_64(h2,r2) + mul32x32_64(h3,r1) + mul32x32_64(h4,r0);
73
+
74
+ h0 = (uint32_t)t[0] & 0x3ffffff; c = (t[0] >> 26);
75
+ t[1] += c; h1 = (uint32_t)t[1] & 0x3ffffff; b = (uint32_t)(t[1] >> 26);
76
+ t[2] += b; h2 = (uint32_t)t[2] & 0x3ffffff; b = (uint32_t)(t[2] >> 26);
77
+ t[3] += b; h3 = (uint32_t)t[3] & 0x3ffffff; b = (uint32_t)(t[3] >> 26);
78
+ t[4] += b; h4 = (uint32_t)t[4] & 0x3ffffff; b = (uint32_t)(t[4] >> 26);
79
+ h0 += b * 5;
80
+
81
+ if (inlen >= 16) goto poly1305_donna_16bytes;
82
+
83
+ /* final bytes */
84
+ poly1305_donna_atmost15bytes:
85
+ if (!inlen) goto poly1305_donna_finish;
86
+
87
+ for (j = 0; j < inlen; j++) mp[j] = m[j];
88
+ mp[j++] = 1;
89
+ for (; j < 16; j++) mp[j] = 0;
90
+ inlen = 0;
91
+
92
+ t0 = U8TO32_LE(mp+0);
93
+ t1 = U8TO32_LE(mp+4);
94
+ t2 = U8TO32_LE(mp+8);
95
+ t3 = U8TO32_LE(mp+12);
96
+
97
+ h0 += t0 & 0x3ffffff;
98
+ h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff;
99
+ h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff;
100
+ h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff;
101
+ h4 += (t3 >> 8);
102
+
103
+ goto poly1305_donna_mul;
104
+
105
+ poly1305_donna_finish:
106
+ b = h0 >> 26; h0 = h0 & 0x3ffffff;
107
+ h1 += b; b = h1 >> 26; h1 = h1 & 0x3ffffff;
108
+ h2 += b; b = h2 >> 26; h2 = h2 & 0x3ffffff;
109
+ h3 += b; b = h3 >> 26; h3 = h3 & 0x3ffffff;
110
+ h4 += b; b = h4 >> 26; h4 = h4 & 0x3ffffff;
111
+ h0 += b * 5;
112
+
113
+ g0 = h0 + 5; b = g0 >> 26; g0 &= 0x3ffffff;
114
+ g1 = h1 + b; b = g1 >> 26; g1 &= 0x3ffffff;
115
+ g2 = h2 + b; b = g2 >> 26; g2 &= 0x3ffffff;
116
+ g3 = h3 + b; b = g3 >> 26; g3 &= 0x3ffffff;
117
+ g4 = h4 + b - (1 << 26);
118
+
119
+ b = (g4 >> 31) - 1;
120
+ nb = ~b;
121
+ h0 = (h0 & nb) | (g0 & b);
122
+ h1 = (h1 & nb) | (g1 & b);
123
+ h2 = (h2 & nb) | (g2 & b);
124
+ h3 = (h3 & nb) | (g3 & b);
125
+ h4 = (h4 & nb) | (g4 & b);
126
+
127
+ f0 = ((h0 ) | (h1 << 26)) + (uint64_t)U8TO32_LE(&key[16]);
128
+ f1 = ((h1 >> 6) | (h2 << 20)) + (uint64_t)U8TO32_LE(&key[20]);
129
+ f2 = ((h2 >> 12) | (h3 << 14)) + (uint64_t)U8TO32_LE(&key[24]);
130
+ f3 = ((h3 >> 18) | (h4 << 8)) + (uint64_t)U8TO32_LE(&key[28]);
131
+
132
+ U32TO8_LE(&out[ 0], f0); f1 += (f0 >> 32);
133
+ U32TO8_LE(&out[ 4], f1); f2 += (f1 >> 32);
134
+ U32TO8_LE(&out[ 8], f2); f3 += (f2 >> 32);
135
+ U32TO8_LE(&out[12], f3);
136
+
137
+ return 0;
138
+ }
139
+
140
+ const char *
141
+ crypto_onetimeauth_poly1305_implementation_name(void)
142
+ {
143
+ return "donna";
144
+ }
145
+
146
+ struct crypto_onetimeauth_poly1305_implementation
147
+ crypto_onetimeauth_poly1305_donna_implementation = {
148
+ _SODIUM_C99(.implementation_name =) crypto_onetimeauth_poly1305_implementation_name,
149
+ _SODIUM_C99(.onetimeauth =) crypto_onetimeauth,
150
+ _SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_verify
151
+ };
@@ -0,0 +1,772 @@
1
+ #ifndef PORTABLE_JANE_H
2
+ #define PORTABLE_JANE_H "+endian +uint128"
3
+ /* 0000-os-100-solaris.h */
4
+
5
+ #if defined(sun) || defined(__sun) || defined(__SVR4) || defined(__svr4__)
6
+ #include <sys/mman.h>
7
+ #include <sys/time.h>
8
+ #include <fcntl.h>
9
+
10
+ #define OS_SOLARIS
11
+ #endif
12
+
13
+ /* 0000-os-100-unix.h */
14
+
15
+ #if defined(__unix__) || defined(unix)
16
+ #include <sys/mman.h>
17
+ #include <sys/time.h>
18
+ #if !defined(USG)
19
+ #include <sys/param.h> /* need this to define BSD */
20
+ #endif
21
+ #include <unistd.h>
22
+ #include <fcntl.h>
23
+
24
+ #define OS_NIX
25
+ #if defined(__linux__)
26
+ #include <endian.h>
27
+ #define OS_LINUX
28
+ #elif defined(BSD)
29
+ #define OS_BSD
30
+
31
+ #if defined(MACOS_X) || (defined(__APPLE__) & defined(__MACH__))
32
+ #define OS_OSX
33
+ #elif defined(macintosh) || defined(Macintosh)
34
+ #define OS_MAC
35
+ #elif defined(__OpenBSD__)
36
+ #define OS_OPENBSD
37
+ #elif defined(__FreeBSD__)
38
+ #define OS_FREEBSD
39
+ #elif defined(__NetBSD__)
40
+ #define OS_NETBSD
41
+ #endif
42
+ #endif
43
+ #endif
44
+
45
+ /* 0000-os-100-windows.h */
46
+
47
+ #if defined(_WIN32) || defined(_WIN64) || defined(__TOS_WIN__) || defined(__WINDOWS__)
48
+ #include <windows.h>
49
+ #include <wincrypt.h>
50
+ #define OS_WINDOWS
51
+ #endif
52
+
53
+ /* 0100-compiler-000.h */
54
+
55
+ #undef NOINLINE
56
+ #undef INLINE
57
+ #undef FASTCALL
58
+ #undef CDECL
59
+ #undef STDCALL
60
+ #undef NAKED
61
+
62
+ /* 0100-compiler-100-clang.h */
63
+
64
+ #if defined(__clang__)
65
+ #define COMPILER_CLANG ((__clang_major__ * 10000) + (__clang_minor__ * 100) + (__clang_patchlevel__))
66
+ #endif
67
+
68
+ /* 0100-compiler-100-gcc.h */
69
+
70
+ #if defined(__GNUC__)
71
+ #if (__GNUC__ >= 3)
72
+ #define COMPILER_GCC_PATCHLEVEL __GNUC_PATCHLEVEL__
73
+ #else
74
+ #define COMPILER_GCC_PATCHLEVEL 0
75
+ #endif
76
+ #define COMPILER_GCC ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + (COMPILER_GCC_PATCHLEVEL))
77
+
78
+ #include <stdint.h>
79
+
80
+ typedef unsigned int fpu_control_t;
81
+
82
+ #define ROTL32(a,b) (((a) << (b)) | ((a) >> (32 - b)))
83
+ #define ROTR32(a,b) (((a) >> (b)) | ((a) << (32 - b)))
84
+ #define ROTL64(a,b) (((a) << (b)) | ((a) >> (64 - b)))
85
+ #define ROTR64(a,b) (((a) >> (b)) | ((a) << (64 - b)))
86
+
87
+ #if (COMPILER_GCC >= 30000)
88
+ #define NOINLINE __attribute__((noinline))
89
+ #else
90
+ #define NOINLINE
91
+ #endif
92
+ #if (COMPILER_GCC >= 30000)
93
+ #define INLINE inline __attribute__((always_inline))
94
+ #else
95
+ #define INLINE inline
96
+ #endif
97
+ #if (COMPILER_GCC >= 30400)
98
+ #define FASTCALL __attribute__((fastcall))
99
+ #else
100
+ #define FASTCALL
101
+ #endif
102
+ #define CDECL __attribute__((cdecl))
103
+ #define STDCALL __attribute__((stdcall))
104
+
105
+ #define mul32x32_64(a,b) ((uint64_t)(a) * (b))
106
+ #define mul32x32_64s(a,b) (((int64_t)(a))*(b))
107
+ #endif
108
+
109
+ /* 0100-compiler-100-icc.h */
110
+
111
+ #if defined(__ICC)
112
+ #define COMPILER_ICC __ICC
113
+ #endif
114
+
115
+ /* 0100-compiler-100-mingw.h */
116
+
117
+ #if defined(__MINGW32__) || defined(__MINGW64__)
118
+ #define COMPILER_MINGW
119
+ #endif
120
+
121
+ /* 0100-compiler-100-msvc.h */
122
+
123
+ #if defined(_MSC_VER)
124
+ #ifndef _CRT_SECURE_NO_WARNINGS
125
+ # define _CRT_SECURE_NO_WARNINGS
126
+ #endif
127
+
128
+ #pragma warning(disable : 4127) /* conditional expression is constant */
129
+ #pragma warning(disable : 4100) /* unreferenced formal parameter */
130
+
131
+ #include <float.h>
132
+ #include <stdlib.h> /* _rotl */
133
+ #include <intrin.h>
134
+
135
+ #define COMPILER_MSVC_VS6 120000000
136
+ #define COMPILER_MSVC_VS6PP 121000000
137
+ #define COMPILER_MSVC_VS2002 130000000
138
+ #define COMPILER_MSVC_VS2003 131000000
139
+ #define COMPILER_MSVC_VS2005 140050727
140
+ #define COMPILER_MSVC_VS2008 150000000
141
+ #define COMPILER_MSVC_VS2008SP1 150030729
142
+ #define COMPILER_MSVC_VS2010 160000000
143
+ #define COMPILER_MSVC_VS2010SP1 160040219
144
+ #define COMPILER_MSVC_VS2012RC 170000000
145
+ #define COMPILER_MSVC_VS2012 170050727
146
+
147
+ #if _MSC_FULL_VER > 100000000
148
+ #define COMPILER_MSVC (_MSC_FULL_VER)
149
+ #else
150
+ #define COMPILER_MSVC (_MSC_FULL_VER * 10)
151
+ #endif
152
+
153
+ #if ((_MSC_VER == 1200) && defined(_mm_free))
154
+ #undef COMPILER_MSVC
155
+ #define COMPILER_MSVC COMPILER_MSVC_VS6PP
156
+ #endif
157
+
158
+ typedef unsigned char uint8_t;
159
+ typedef unsigned short uint16_t;
160
+ typedef unsigned int uint32_t;
161
+ typedef signed int int32_t;
162
+ typedef unsigned __int64 uint64_t;
163
+ typedef signed __int64 int64_t;
164
+
165
+ typedef uint16_t fpu_control_t;
166
+
167
+ #define ROTL32(a,b) _rotl(a,b)
168
+ #define ROTR32(a,b) _rotr(a,b)
169
+ #define ROTL64(a,b) _rotl64(a,b)
170
+ #define ROTR64(a,b) _rotr64(a,b)
171
+
172
+ #define NOINLINE __declspec(noinline)
173
+ #define INLINE __forceinline
174
+ #define FASTCALL __fastcall
175
+ #define CDECL __cdecl
176
+ #define STDCALL __stdcall
177
+ #define NAKED __declspec(naked)
178
+
179
+ #if defined(_DEBUG)
180
+ #define mul32x32_64(a,b) (((uint64_t)(a))*(b))
181
+ #define mul32x32_64s(a,b) (((int64_t)(a))*(b))
182
+ #else
183
+ #define mul32x32_64(a,b) __emulu(a,b)
184
+ #define mul32x32_64s(a,b) __emul(a,b)
185
+ #endif
186
+ #endif
187
+ /* 0100-compiler-999.h */
188
+
189
+ #define OPTIONAL_INLINE /* config */
190
+ #if defined(OPTIONAL_INLINE)
191
+ #undef OPTIONAL_INLINE
192
+ #define OPTIONAL_INLINE INLINE
193
+ #else
194
+ #define OPTIONAL_INLINE
195
+ #endif
196
+
197
+ #define Preprocessor_ToString(s) #s
198
+ #define Stringify(s) Preprocessor_ToString(s)
199
+
200
+ #include <stdio.h>
201
+ #include <string.h>
202
+
203
+ /* 0200-cpu-100-alpha.h */
204
+
205
+ #if defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
206
+ #define CPU_ALPHA
207
+ #endif
208
+
209
+ /* 0200-cpu-100-hppa.h */
210
+
211
+ #if defined(__hppa__) || defined(__hppa)
212
+ #define CPU_HPPA
213
+ #endif
214
+
215
+ /* 0200-cpu-100-intel.h */
216
+
217
+ #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__ ) || defined(_M_X64)
218
+ #define CPU_X86_64
219
+ #elif defined(__i586__) || defined(__i686__) || (defined(_M_IX86) && (_M_IX86 >= 500))
220
+ #define CPU_X86 500
221
+ #elif defined(__i486__) || (defined(_M_IX86) && (_M_IX86 >= 400))
222
+ #define CPU_X86 400
223
+ #elif defined(__i386__) || (defined(_M_IX86) && (_M_IX86 >= 300)) || defined(__X86__) || defined(_X86_) || defined(__I86__)
224
+ #define CPU_X86 300
225
+ #elif defined(__ia64__) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64) || defined(__ia64)
226
+ #define CPU_IA64
227
+ #endif
228
+
229
+ /* 0200-cpu-100-ppc.h */
230
+
231
+ #if defined(powerpc) || defined(__PPC__) || defined(__ppc__) || defined(_ARCH_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(POWERPC) || defined(_M_PPC)
232
+ #define CPU_PPC
233
+ #if defined(_ARCH_PWR7)
234
+ #define CPU_POWER7
235
+ #elif defined(__64BIT__)
236
+ #define CPU_PPC64
237
+ #else
238
+ #define CPU_PPC32
239
+ #endif
240
+ #endif
241
+
242
+ /* 0200-cpu-100-sparc.h */
243
+
244
+ #if defined(__sparc__) || defined(__sparc) || defined(__sparcv9)
245
+ #define CPU_SPARC
246
+ #if defined(__sparcv9)
247
+ #define CPU_SPARC64
248
+ #else
249
+ #define CPU_SPARC32
250
+ #endif
251
+ #endif
252
+
253
+ /* 0200-cpu-200-bits.h */
254
+
255
+ #if defined(CPU_X86_64) || defined(CPU_IA64) || defined(CPU_SPARC64) || defined(__64BIT__) || defined(__LP64__) || defined(_LP64) || (defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64))
256
+ #define CPU_64BITS
257
+
258
+ #undef FASTCALL
259
+ #undef CDECL
260
+ #undef STDCALL
261
+
262
+ #define FASTCALL
263
+ #define CDECL
264
+ #define STDCALL
265
+ #endif
266
+
267
+ /* 0200-cpu-200-endian.h */
268
+
269
+ #if ((defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || \
270
+ (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN)) || \
271
+ (defined(CPU_X86) || defined(CPU_X86_64)) || \
272
+ (defined(vax) || defined(MIPSEL) || defined(_MIPSEL)))
273
+ #define CPU_LE
274
+ #elif ((defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
275
+ (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
276
+ (defined(CPU_SPARC) || defined(CPU_PPC) || defined(mc68000) || defined(sel)) || defined(_MIPSEB))
277
+ #define CPU_BE
278
+ #else
279
+ /* unknown endian! */
280
+ #endif
281
+
282
+ #if defined(__s390__) || defined(__zarch__) || defined(__SYSC_ZARCH__)
283
+ # define CPU_Z390
284
+ #endif
285
+
286
+ /* 0400-endian-100-be.h */
287
+
288
+ #if defined(CPU_BE) && !defined(CPU_ALIGNED_ACCESS_REQUIRED)
289
+ static INLINE uint16_t fU8TO16_BE_FAST(const uint8_t *p) { return *(const uint16_t *)p; }
290
+ static INLINE uint32_t fU8TO32_BE_FAST(const uint8_t *p) { return *(const uint32_t *)p; }
291
+ static INLINE uint64_t fU8TO64_BE_FAST(const uint8_t *p) { return *(const uint64_t *)p; }
292
+ static INLINE void fU16TO8_BE_FAST(uint8_t *p, const uint16_t v) { *(uint16_t *)p = v; }
293
+ static INLINE void fU32TO8_BE_FAST(uint8_t *p, const uint32_t v) { *(uint32_t *)p = v; }
294
+ static INLINE void fU64TO8_BE_FAST(uint8_t *p, const uint64_t v) { *(uint64_t *)p = v; }
295
+
296
+ #define U8TO16_BE(p) fU8TO16_BE_FAST(p)
297
+ #define U8TO32_BE(p) fU8TO32_BE_FAST(p)
298
+ #define U8TO64_BE(p) fU8TO64_BE_FAST(p)
299
+ #define U16TO8_BE(p, v) fU16TO8_BE_FAST(p, v)
300
+ #define U32TO8_BE(p, v) fU32TO8_BE_FAST(p, v)
301
+ #define U64TO8_BE(p, v) fU64TO8_BE_FAST(p, v)
302
+ #endif
303
+
304
+ /* 0400-endian-100-le.h */
305
+
306
+ #if defined(CPU_LE) && !defined(CPU_ALIGNED_ACCESS_REQUIRED)
307
+ static INLINE uint16_t fU8TO16_LE_FAST(const uint8_t *p) { return *(const uint16_t *)p; }
308
+ static INLINE uint32_t fU8TO32_LE_FAST(const uint8_t *p) { return *(const uint32_t *)p; }
309
+ static INLINE uint64_t fU8TO64_LE_FAST(const uint8_t *p) { return *(const uint64_t *)p; }
310
+ static INLINE void fU16TO8_LE_FAST(uint8_t *p, const uint16_t v) { *(uint16_t *)p = v; }
311
+ static INLINE void fU32TO8_LE_FAST(uint8_t *p, const uint32_t v) { *(uint32_t *)p = v; }
312
+ static INLINE void fU64TO8_LE_FAST(uint8_t *p, const uint64_t v) { *(uint64_t *)p = v; }
313
+
314
+ #define U8TO16_LE(p) fU8TO16_LE_FAST(p)
315
+ #define U8TO32_LE(p) fU8TO32_LE_FAST(p)
316
+ #define U8TO64_LE(p) fU8TO64_LE_FAST(p)
317
+ #define U16TO8_LE(p, v) fU16TO8_LE_FAST(p, v)
318
+ #define U32TO8_LE(p, v) fU32TO8_LE_FAST(p, v)
319
+ #define U64TO8_LE(p, v) fU64TO8_LE_FAST(p, v)
320
+ #endif
321
+
322
+ /* 0400-endian-100-ppc.h */
323
+
324
+ #if defined(CPU_PPC)
325
+ #if defined(CPU_POWER7)
326
+ static INLINE uint64_t fU8TO64_LE_FAST(const uint8_t *p) {
327
+ uint64_d d;
328
+ __asm__ ("ldbrx %0,0,%1" : "=r"(d) : "r"(p))
329
+ return d;
330
+ }
331
+
332
+ static INLINE void
333
+ fU64TO8_LE_FAST(uint8_t *p, const uint64_t v) {
334
+ __asm__ ("stdbrx %1,0,%0" : : "r"(p), "r"(v))
335
+ }
336
+ #elif defined(CPU_PPC64)
337
+ static INLINE uint64_t
338
+ fU8TO64_LE_FAST(const uint8_t *p) {
339
+ uint64_t *s4, h, d;
340
+ __asm__ ("addi %0,%3,4;lwbrx %1,0,%3;lwbrx %2,0,%0;rldimi %1,%2,32,0" : "+r"(s4), "=r"(d), "=r"(h) : "b"(p));
341
+ return d;
342
+ }
343
+
344
+ static INLINE void
345
+ fU64TO8_LE_FAST(uint8_t *p, const uint64_t v) {
346
+ uint64_t *s4, h = v >> 32;
347
+ __asm__ ("addi %0,%3,4;stwbrx %1,0,%3;stwbrx %2,0,%0" : "+r"(s4) : "r"(v), "r"(h), "b"(p));
348
+ }
349
+ #elif defined(CPU_PPC32)
350
+ static INLINE uint64_t
351
+ fU8TO64_LE_FAST(const uint8_t *p) {
352
+ uint32_t *s4, h, l;
353
+ __asm__ ("addi %0,%3,4;lwbrx %1,0,%3;lwbrx %2,0,%0" : "+r"(s4), "=r"(l), "=r"(h) : "b"(p));\
354
+ return ((uint64_t)h << 32) | l;
355
+ }
356
+
357
+ static INLINE void
358
+ fU64TO8_LE_FAST(uint8_t *p, const uint64_t v) {
359
+ uint32_t *s4, h = (uint32_t)(v >> 32), l = (uint32_t)(v & (uint32_t)0xffffffff);
360
+ __asm__ ("addi %0,%3,4;stwbrx %1,0,%3;stwbrx %2,0,%0" : "+r"(s4) : "r"(l), "r"(h), "b"(p));
361
+ }
362
+ #endif
363
+
364
+ static INLINE uint32_t
365
+ fU8TO32_LE_FAST(const uint8_t *p) {
366
+ uint32_t d;
367
+ __asm__ ("lwbrx %0,0,%1" : "=r"(d) : "r"(p));
368
+ return d;
369
+ }
370
+
371
+ static INLINE void
372
+ fU32TO8_LE_FAST(uint8_t *p, const uint32_t v) {
373
+ __asm__ __volatile__("stwbrx %1,0,%0" : : "r"(p), "r"(v));
374
+ }
375
+
376
+ #define U8TO32_LE(p) fU8TO32_LE_FAST(p)
377
+ #define U8TO64_LE(p) fU8TO64_LE_FAST(p)
378
+ #define U32TO8_LE(p, v) fU32TO8_LE_FAST(p, v)
379
+ #define U64TO8_LE(p, v) fU64TO8_LE_FAST(p, v)
380
+ #endif
381
+
382
+ /* 0400-endian-100-sparc.h */
383
+
384
+ #if defined(CPU_SPARC)
385
+ #if defined(CPU_SPARC64)
386
+ static INLINE uint64_t
387
+ fU8TO64_LE_FAST(const uint8_t *p) {
388
+ uint64_d d;
389
+ __asm__ ("ldxa [%1]0x88,%0" : "=r"(d) : "r"(p));
390
+ return d;
391
+ }
392
+
393
+ static INLINE void
394
+ fU64TO8_LE_FAST(uint8_t *p, const uint64_t v) {
395
+ __asm__ ("stxa %0,[%1]0x88" : : "r"(v), "r"(p));
396
+ }
397
+ #else
398
+ static INLINE uint64_t
399
+ fU8TO64_LE_FAST(const uint8_t *p) {
400
+ uint32_t *s4, h, l;
401
+ __asm__ ("add %3,4,%0\n\tlda [%3]0x88,%1\n\tlda [%0]0x88,%2" : "+r"(s4), "=r"(l), "=r"(h) : "r"(p));
402
+ return ((uint64_t)h << 32) | l;
403
+ }
404
+
405
+ static INLINE void
406
+ fU64TO8_LE_FAST(uint8_t *p, const uint64_t v) {
407
+ uint32_t *s4, h = (uint32_t)(v >> 32), l = (uint32_t)(v & (uint32_t)0xffffffff);
408
+ __asm__ ("add %3,4,%0\n\tsta %1,[%3]0x88\n\tsta %2,[%0]0x88" : "+r"(s4) : "r"(l), "r"(h), "r"(p));
409
+ }
410
+ #endif
411
+
412
+ static INLINE uint32_t
413
+ fU8TO32_LE_FAST(const uint8_t *p) {
414
+ uint32_t d;
415
+ __asm__ ("lda [%1]0x88,%0" : "=r"(d) : "r"(p));
416
+ return d;
417
+ }
418
+
419
+ static INLINE void
420
+ fU32TO8_LE_FAST(uint8_t *p, const uint32_t v) {
421
+ __asm__ ("sta %0,[%1]0x88" : : "r"(p), "r"(v));
422
+ }
423
+
424
+ #define U8TO32_LE(p) fU8TO32_LE_FAST(p)
425
+ #define U8TO64_LE(p) fU8TO64_LE_FAST(p)
426
+ #define U32TO8_LE(p, v) fU32TO8_LE_FAST(p, v)
427
+ #define U64TO8_LE(p, v) fU64TO8_LE_FAST(p, v)
428
+ #endif
429
+
430
+ /* 0400-endian-100-x86.h */
431
+
432
+ #if (((defined(CPU_X86) && (CPU_X86 >= 400)) || defined(CPU_X86_64)) && (defined(COMPILER_MSVC) || defined(COMPILER_GCC)))
433
+ #if defined(COMPILER_MSVC)
434
+ static INLINE uint16_t U16_SWAP_FAST(uint16_t v) { return _byteswap_ushort(v); }
435
+ static INLINE uint32_t U32_SWAP_FAST(uint32_t v) { return _byteswap_ulong(v); }
436
+ static INLINE uint64_t U64_SWAP_FAST(uint64_t v) { return _byteswap_uint64(v); }
437
+ #else
438
+ static INLINE uint16_t U16_SWAP_FAST(uint16_t v) { __asm__("rorw $8,%0" : "+r" (v)); return v; }
439
+ static INLINE uint32_t U32_SWAP_FAST(uint32_t v) { __asm__("bswap %0" : "+r" (v)); return v; }
440
+ #if defined(CPU_X86_64)
441
+ static INLINE uint64_t U64_SWAP_FAST(uint64_t v) { __asm__("bswap %0" : "+r" (v)); return v; }
442
+ #else
443
+ static INLINE uint64_t U64_SWAP_FAST(uint64_t v) {
444
+ uint32_t lo = U32_SWAP_FAST((uint32_t)(v)), hi = U32_SWAP_FAST((uint32_t)(v >> 32));
445
+ return ((uint64_t)lo << 32) | hi;
446
+ }
447
+ #endif
448
+ #endif
449
+
450
+
451
+ static INLINE uint16_t fU8TO16_BE_FAST(const uint8_t *p) { return U16_SWAP_FAST(*(const uint16_t *)p); }
452
+ static INLINE uint32_t fU8TO32_BE_FAST(const uint8_t *p) { return U32_SWAP_FAST(*(const uint32_t *)p); }
453
+ static INLINE uint64_t fU8TO64_BE_FAST(const uint8_t *p) { return U64_SWAP_FAST(*(const uint64_t *)p); }
454
+ static INLINE void fU16TO8_BE_FAST(uint8_t *p, const uint16_t v) { *(uint16_t *)p = U16_SWAP_FAST(v); }
455
+ static INLINE void fU32TO8_BE_FAST(uint8_t *p, const uint32_t v) { *(uint32_t *)p = U32_SWAP_FAST(v); }
456
+ static INLINE void fU64TO8_BE_FAST(uint8_t *p, const uint64_t v) { *(uint64_t *)p = U64_SWAP_FAST(v); }
457
+
458
+ #define U16_SWAP(p) U16_SWAP_FAST(p)
459
+ #define U32_SWAP(p) U32_SWAP_FAST(p)
460
+ #define U64_SWAP(p) U64_SWAP_FAST(p)
461
+ #define U8TO16_BE(p) fU8TO16_BE_FAST(p)
462
+ #define U8TO32_BE(p) fU8TO32_BE_FAST(p)
463
+ #define U8TO64_BE(p) fU8TO64_BE_FAST(p)
464
+ #define U16TO8_BE(p, v) fU16TO8_BE_FAST(p, v)
465
+ #define U32TO8_BE(p, v) fU32TO8_BE_FAST(p, v)
466
+ #define U64TO8_BE(p, v) fU64TO8_BE_FAST(p, v)
467
+ #endif
468
+
469
+ /* 0400-endian-999-generic-be.h */
470
+
471
+ #if !defined(U8TO16_BE)
472
+ static INLINE uint16_t
473
+ fU8TO16_BE_SLOW(const uint8_t *p) {
474
+ return
475
+ (((uint16_t)(p[0]) << 8) |
476
+ ((uint16_t)(p[1]) ));
477
+ }
478
+
479
+ #define U8TO16_BE(p) fU8TO16_BE_SLOW(p)
480
+ #endif
481
+
482
+
483
+ #if !defined(U8TO32_BE)
484
+ static INLINE uint32_t
485
+ fU8TO32_BE_SLOW(const uint8_t *p) {
486
+ return
487
+ (((uint32_t)(p[0]) << 24) |
488
+ ((uint32_t)(p[1]) << 16) |
489
+ ((uint32_t)(p[2]) << 8) |
490
+ ((uint32_t)(p[3]) ));
491
+ }
492
+
493
+ #define U8TO32_BE(p) fU8TO32_BE_SLOW(p)
494
+ #endif
495
+
496
+ #if !defined(U8TO64_BE)
497
+ static INLINE uint64_t
498
+ fU8TO64_BE_SLOW(const uint8_t *p) {
499
+ return
500
+ (((uint64_t)(p[0]) << 56) |
501
+ ((uint64_t)(p[1]) << 48) |
502
+ ((uint64_t)(p[2]) << 40) |
503
+ ((uint64_t)(p[3]) << 32) |
504
+ ((uint64_t)(p[4]) << 24) |
505
+ ((uint64_t)(p[5]) << 16) |
506
+ ((uint64_t)(p[6]) << 8) |
507
+ ((uint64_t)(p[7]) ));
508
+ }
509
+
510
+ #define U8TO64_BE(p) fU8TO64_BE_SLOW(p)
511
+ #endif
512
+
513
+ #if !defined(U16TO8_BE)
514
+ static INLINE void
515
+ fU16TO8_BE_SLOW(uint8_t *p, const uint16_t v) {
516
+ p[0] = (uint8_t)(v >> 8);
517
+ p[1] = (uint8_t)(v );
518
+ }
519
+
520
+ #define U16TO8_BE(p, v) fU16TO8_BE_SLOW(p, v)
521
+ #endif
522
+
523
+ #if !defined(U32TO8_BE)
524
+ static INLINE void
525
+ fU32TO8_BE_SLOW(uint8_t *p, const uint32_t v) {
526
+ p[0] = (uint8_t)(v >> 24);
527
+ p[1] = (uint8_t)(v >> 16);
528
+ p[2] = (uint8_t)(v >> 8);
529
+ p[3] = (uint8_t)(v );
530
+ }
531
+
532
+ #define U32TO8_BE(p, v) fU32TO8_BE_SLOW(p, v)
533
+ #endif
534
+
535
+ #if !defined(U64TO8_BE)
536
+ static INLINE void
537
+ fU64TO8_BE_SLOW(uint8_t *p, const uint64_t v) {
538
+ p[0] = (uint8_t)(v >> 56);
539
+ p[1] = (uint8_t)(v >> 48);
540
+ p[2] = (uint8_t)(v >> 40);
541
+ p[3] = (uint8_t)(v >> 32);
542
+ p[4] = (uint8_t)(v >> 24);
543
+ p[5] = (uint8_t)(v >> 16);
544
+ p[6] = (uint8_t)(v >> 8);
545
+ p[7] = (uint8_t)(v );
546
+ }
547
+
548
+ #define U64TO8_BE(p, v) fU64TO8_BE_SLOW(p, v)
549
+ #endif
550
+
551
+ /* 0400-endian-999-generic-le.h */
552
+
553
+ #if !defined(U8TO16_LE)
554
+ static INLINE uint16_t
555
+ fU8TO16_LE_SLOW(const uint8_t *p) {
556
+ return
557
+ (((uint16_t)(p[0]) ) |
558
+ ((uint16_t)(p[1]) << 8));
559
+ }
560
+
561
+ #define U8TO16_LE(p) fU8TO16_LE_SLOW(p)
562
+ #endif
563
+
564
+ #if !defined(U8TO32_LE)
565
+ static INLINE uint32_t
566
+ fU8TO32_LE_SLOW(const uint8_t *p) {
567
+ return
568
+ (((uint32_t)(p[0]) ) |
569
+ ((uint32_t)(p[1]) << 8) |
570
+ ((uint32_t)(p[2]) << 16) |
571
+ ((uint32_t)(p[3]) << 24));
572
+ }
573
+
574
+ #define U8TO32_LE(p) fU8TO32_LE_SLOW(p)
575
+ #endif
576
+
577
+
578
+ #if !defined(U8TO64_LE)
579
+ static INLINE uint64_t
580
+ fU8TO64_LE_SLOW(const uint8_t *p) {
581
+ return
582
+ (((uint64_t)(p[0]) ) |
583
+ ((uint64_t)(p[1]) << 8) |
584
+ ((uint64_t)(p[2]) << 16) |
585
+ ((uint64_t)(p[3]) << 24) |
586
+ ((uint64_t)(p[4]) << 32) |
587
+ ((uint64_t)(p[5]) << 40) |
588
+ ((uint64_t)(p[6]) << 48) |
589
+ ((uint64_t)(p[7]) << 56));
590
+ }
591
+
592
+ #define U8TO64_LE(p) fU8TO64_LE_SLOW(p)
593
+ #endif
594
+
595
+ #if !defined(U16TO8_LE)
596
+ static INLINE void
597
+ fU16TO8_LE_SLOW(uint8_t *p, const uint16_t v) {
598
+ p[0] = (uint8_t)(v );
599
+ p[1] = (uint8_t)(v >> 8);
600
+ }
601
+
602
+ #define U16TO8_LE(p, v) fU16TO8_LE_SLOW(p, v)
603
+ #endif
604
+
605
+ #if !defined(U32TO8_LE)
606
+ static INLINE void
607
+ fU32TO8_LE_SLOW(uint8_t *p, const uint32_t v) {
608
+ p[0] = (uint8_t)(v );
609
+ p[1] = (uint8_t)(v >> 8);
610
+ p[2] = (uint8_t)(v >> 16);
611
+ p[3] = (uint8_t)(v >> 24);
612
+ }
613
+
614
+ #define U32TO8_LE(p, v) fU32TO8_LE_SLOW(p, v)
615
+ #endif
616
+
617
+ #if !defined(U64TO8_LE)
618
+ static INLINE void
619
+ fU64TO8_LE_SLOW(uint8_t *p, const uint64_t v) {
620
+ p[0] = (uint8_t)(v );
621
+ p[1] = (uint8_t)(v >> 8);
622
+ p[2] = (uint8_t)(v >> 16);
623
+ p[3] = (uint8_t)(v >> 24);
624
+ p[4] = (uint8_t)(v >> 32);
625
+ p[5] = (uint8_t)(v >> 40);
626
+ p[6] = (uint8_t)(v >> 48);
627
+ p[7] = (uint8_t)(v >> 56);
628
+ }
629
+
630
+ #define U64TO8_LE(p, v) fU64TO8_LE_SLOW(p, v)
631
+ #endif
632
+
633
+ /* 0400-endian-999-generic-swap.h */
634
+
635
+ #if !defined(U16_SWAP)
636
+ static INLINE uint16_t
637
+ fU16_SWAP_SLOW(uint16_t v) {
638
+ v = (v << 8) | (v >> 8);
639
+ return v;
640
+ }
641
+
642
+ #define U16_SWAP(p) fU16_SWAP_SLOW(p)
643
+ #endif
644
+
645
+ #if !defined(U32_SWAP)
646
+ static INLINE uint32_t
647
+ fU32_SWAP_SLOW(uint32_t v) {
648
+ v = ((v << 8) & 0xFF00FF00) | ((v >> 8) & 0xFF00FF);
649
+ v = (v << 16) | (v >> 16);
650
+ return v;
651
+ }
652
+
653
+ #define U32_SWAP(p) fU32_SWAP_SLOW(p)
654
+ #endif
655
+
656
+ #if !defined(U64_SWAP)
657
+ static INLINE uint64_t
658
+ fU64_SWAP_SLOW(uint64_t v) {
659
+ v = ((v << 8) & 0xFF00FF00FF00FF00ull) | ((v >> 8) & 0x00FF00FF00FF00FFull);
660
+ v = ((v << 16) & 0xFFFF0000FFFF0000ull) | ((v >> 16) & 0x0000FFFF0000FFFFull);
661
+ v = (v << 32) | (v >> 32);
662
+ return v;
663
+ }
664
+
665
+ #define U64_SWAP(p) fU64_SWAP_SLOW(p)
666
+ #endif
667
+
668
+ /* 0400-uint128-000.h */
669
+
670
+ /* 0400-uint128-100-clang.h */
671
+
672
+ #ifdef HAVE_TI_MODE
673
+ # define HAVE_NATIVE_UINT128
674
+ typedef unsigned uint128_t __attribute__((mode(TI)));
675
+ #endif
676
+
677
+ /* 0400-uint128-100-msvc.h */
678
+
679
+ #if defined(CPU_64BITS) && defined(COMPILER_MSVC)
680
+ #define HAVE_UINT128
681
+
682
+ typedef struct uint128 {
683
+ uint64_t lo, hi;
684
+ } uint128_t;
685
+
686
+ static INLINE uint128_t
687
+ mul64x64_128(uint64_t a, uint64_t b) {
688
+ uint128_t v;
689
+ v.lo = _umul128(a, b, &v.hi);
690
+ return v;
691
+ }
692
+
693
+ static INLINE uint64_t
694
+ shr128_pair(uint64_t hi, uint64_t lo, const int shift) {
695
+ return __shiftright128(lo, hi, shift);
696
+ }
697
+
698
+ static INLINE uint64_t
699
+ shr128(uint128_t v, const int shift) {
700
+ return __shiftright128(v.lo, v.hi, shift);
701
+ }
702
+
703
+ static INLINE uint128_t
704
+ add128(uint128_t a, uint128_t b) {
705
+ uint64_t t = a.lo;
706
+ a.lo += b.lo;
707
+ a.hi += b.hi + (a.lo < t);
708
+ return a;
709
+ }
710
+
711
+ static INLINE uint128_t
712
+ add128_64(uint128_t a, uint64_t b) {
713
+ uint64_t t = a.lo;
714
+ a.lo += b;
715
+ a.hi += (a.lo < t);
716
+ return a;
717
+ }
718
+
719
+ static INLINE uint64_t
720
+ lo128(uint128_t a) {
721
+ return a.lo;
722
+ }
723
+
724
+ static INLINE uint64_t
725
+ hi128(uint128_t a) {
726
+ return a.hi;
727
+ }
728
+ #endif
729
+
730
+ /* 0400-uint128-999.h */
731
+
732
+ #if defined(HAVE_NATIVE_UINT128)
733
+ #define HAVE_UINT128
734
+
735
+ static INLINE uint128_t
736
+ mul64x64_128(uint64_t a, uint64_t b) {
737
+ return (uint128_t)a * b;
738
+ }
739
+
740
+ static INLINE uint64_t
741
+ shr128(uint128_t v, const int shift) {
742
+ return (uint64_t)(v >> shift);
743
+ }
744
+
745
+ static INLINE uint64_t
746
+ shr128_pair(uint64_t hi, uint64_t lo, const int shift) {
747
+ return (uint64_t)((((uint128_t)hi << 64) | lo) >> shift);
748
+ }
749
+
750
+ static INLINE uint128_t
751
+ add128(uint128_t a, uint128_t b) {
752
+ return a + b;
753
+ }
754
+
755
+ static INLINE uint128_t
756
+ add128_64(uint128_t a, uint64_t b) {
757
+ return a + b;
758
+ }
759
+
760
+ static INLINE uint64_t
761
+ lo128(uint128_t a) {
762
+ return (uint64_t)a;
763
+ }
764
+
765
+ static INLINE uint64_t
766
+ hi128(uint128_t a) {
767
+ return (uint64_t)(a >> 64);
768
+ }
769
+ #endif
770
+
771
+ #endif /* PORTABLE_JANE_H */
772
+