rbnacl-libsodium 0.5.0.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +4 -0
  3. data/lib/rbnacl/libsodium/version.rb +1 -1
  4. data/vendor/libsodium/AUTHORS +62 -81
  5. data/vendor/libsodium/ChangeLog +31 -1
  6. data/vendor/libsodium/README.markdown +15 -364
  7. data/vendor/libsodium/THANKS +6 -0
  8. data/vendor/libsodium/autom4te.cache/output.0 +67 -36
  9. data/vendor/libsodium/autom4te.cache/output.1 +67 -36
  10. data/vendor/libsodium/autom4te.cache/output.2 +67 -36
  11. data/vendor/libsodium/autom4te.cache/traces.0 +52 -51
  12. data/vendor/libsodium/autom4te.cache/traces.1 +137 -133
  13. data/vendor/libsodium/autom4te.cache/traces.2 +52 -51
  14. data/vendor/libsodium/builds/msvc/version.h +2 -2
  15. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +365 -345
  16. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +1114 -1037
  17. data/vendor/libsodium/builds/msvc/vs2010/test/test.props +8 -2
  18. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +364 -344
  19. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +1113 -1036
  20. data/vendor/libsodium/builds/msvc/vs2012/test/test.props +8 -2
  21. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +365 -345
  22. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +1114 -1037
  23. data/vendor/libsodium/builds/msvc/vs2013/test/test.props +8 -2
  24. data/vendor/libsodium/configure +66 -35
  25. data/vendor/libsodium/configure.ac +25 -14
  26. data/vendor/libsodium/dist-build/ios.sh +1 -1
  27. data/vendor/libsodium/dist-build/msys2-win64.sh +1 -1
  28. data/vendor/libsodium/libsodium.vcxproj +29 -14
  29. data/vendor/libsodium/libsodium.vcxproj.filters +77 -28
  30. data/vendor/libsodium/msvc-scripts/process.bat +3 -3
  31. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  32. data/vendor/libsodium/packaging/nuget/package.gsl +6 -1
  33. data/vendor/libsodium/packaging/nuget/package.nuspec +1 -1
  34. data/vendor/libsodium/src/libsodium/Makefile.am +31 -13
  35. data/vendor/libsodium/src/libsodium/Makefile.in +406 -155
  36. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +146 -0
  37. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +13 -0
  38. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +39 -73
  39. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +5 -0
  40. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +2 -0
  41. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +15 -0
  42. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +6 -5
  43. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +6 -5
  44. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +25 -0
  45. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +76 -47
  46. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +30 -7
  47. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +3 -16
  48. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +3 -10
  49. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/verify_poly1305_donna.c +11 -6
  50. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +23 -1
  51. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +1 -1
  52. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/crypto_scrypt-common.c +7 -7
  53. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/crypto_scrypt.h +6 -20
  54. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/nosse/pwhash_scryptxsalsa208sha256_nosse.c → scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c} +0 -0
  55. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/pbkdf2-sha256.c +1 -11
  56. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/pbkdf2-sha256.h +0 -0
  57. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c → scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c} +50 -25
  58. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/scrypt_platform.c +4 -0
  59. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/sse/pwhash_scryptxsalsa208sha256_sse.c → scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c} +0 -0
  60. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/sysendian.h +0 -0
  61. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +1 -1
  62. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/{ref → ref10}/api.h +0 -3
  63. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/base_curve25519_ref10.c +14 -0
  64. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe.h +44 -0
  65. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_0_curve25519_ref10.c +23 -0
  66. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_1_curve25519_ref10.c +23 -0
  67. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c +61 -0
  68. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c +33 -0
  69. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c +77 -0
  70. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +73 -0
  71. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c +18 -0
  72. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c +74 -0
  73. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c +257 -0
  74. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c +153 -0
  75. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c +61 -0
  76. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c +123 -0
  77. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/montgomery.h +140 -0
  78. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/pow225521.h +160 -0
  79. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c +54 -0
  80. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +92 -61
  81. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +3 -3
  82. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow22523.h +2 -2
  83. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow225521.h +2 -2
  84. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +8 -4
  85. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +3 -3
  86. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +6 -3
  87. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +23 -23
  88. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/api.h +12 -0
  89. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +275 -0
  90. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20_api.c +36 -0
  91. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +11 -10
  92. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +8 -3
  93. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +8 -0
  94. data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -2
  95. data/vendor/libsodium/src/libsodium/include/Makefile.in +3 -2
  96. data/vendor/libsodium/src/libsodium/include/sodium.h +3 -1
  97. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +55 -0
  98. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +21 -0
  99. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +11 -1
  100. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +7 -0
  101. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +7 -0
  102. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +7 -0
  103. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +15 -0
  104. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +25 -0
  105. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +80 -0
  106. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +2 -2
  107. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +14 -0
  108. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +11 -0
  109. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +11 -6
  110. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +49 -0
  111. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +6 -0
  112. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +7 -7
  113. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +10 -14
  114. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +10 -13
  115. data/vendor/libsodium/src/libsodium/sodium/compat.c +55 -4
  116. data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -0
  117. data/vendor/libsodium/test/default/Makefile.am +24 -12
  118. data/vendor/libsodium/test/default/Makefile.in +116 -73
  119. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +97 -0
  120. data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +8 -0
  121. data/vendor/libsodium/test/default/box_easy.c +1 -1
  122. data/vendor/libsodium/test/default/box_seed.c +28 -0
  123. data/vendor/libsodium/test/default/box_seed.exp +8 -0
  124. data/vendor/libsodium/test/default/chacha20.c +45 -0
  125. data/vendor/libsodium/test/default/chacha20.exp +5 -0
  126. data/vendor/libsodium/test/default/pwhash.c +83 -15
  127. data/vendor/libsodium/test/default/pwhash.exp +10 -1
  128. data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +67 -0
  129. data/vendor/libsodium/test/default/pwhash_scrypt_ll.exp +15 -0
  130. data/vendor/libsodium/test/default/secretbox_easy.c +13 -1
  131. data/vendor/libsodium/test/default/secretbox_easy.exp +19 -0
  132. data/vendor/libsodium/test/default/secretbox_easy2.c +5 -0
  133. data/vendor/libsodium/test/default/secretbox_easy2.exp +1 -0
  134. data/vendor/libsodium/test/default/sign.c +7 -3
  135. metadata +44 -21
  136. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/api.h +0 -8
  137. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/base_curve25519_ref.c +0 -20
  138. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/smult_curve25519_ref.c +0 -268
  139. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +0 -37
  140. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h +0 -48
  141. data/vendor/libsodium/test/default/scalarmult7.c +0 -32
  142. data/vendor/libsodium/test/default/scalarmult7.exp +0 -1
  143. data/vendor/libsodium/test/default/scalarmult8.c +0 -32
  144. data/vendor/libsodium/test/default/scalarmult8.exp +0 -1
@@ -32,3 +32,28 @@ crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in,
32
32
  {
33
33
  return crypto_onetimeauth_poly1305_verify(h, in, inlen, k);
34
34
  }
35
+
36
+ int
37
+ crypto_onetimeauth_init(crypto_onetimeauth_state *state,
38
+ const unsigned char *key)
39
+ {
40
+ return crypto_onetimeauth_poly1305_init
41
+ ((crypto_onetimeauth_poly1305_state *) state, key);
42
+ }
43
+
44
+ int
45
+ crypto_onetimeauth_update(crypto_onetimeauth_state *state,
46
+ const unsigned char *in,
47
+ unsigned long long inlen)
48
+ {
49
+ return crypto_onetimeauth_poly1305_update
50
+ ((crypto_onetimeauth_poly1305_state *) state, in, inlen);
51
+ }
52
+
53
+ int
54
+ crypto_onetimeauth_final(crypto_onetimeauth_state *state,
55
+ unsigned char *out)
56
+ {
57
+ return crypto_onetimeauth_poly1305_final
58
+ ((crypto_onetimeauth_poly1305_state *) state, out);
59
+ }
@@ -1,10 +1,6 @@
1
1
 
2
- #include "api.h"
3
2
  #include "utils.h"
4
-
5
- #include "crypto_onetimeauth_poly1305_donna.h"
6
3
  #include "poly1305_donna.h"
7
-
8
4
  #ifdef HAVE_TI_MODE
9
5
  # include "poly1305_donna64.h"
10
6
  #else
@@ -14,62 +10,95 @@
14
10
  static void
15
11
  poly1305_update(poly1305_context *ctx, const unsigned char *m,
16
12
  unsigned long long bytes) {
17
- poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
18
- unsigned long long i;
19
-
20
- /* handle leftover */
21
- if (st->leftover) {
22
- unsigned long long want = (poly1305_block_size - st->leftover);
23
- if (want > bytes)
24
- want = bytes;
25
- for (i = 0; i < want; i++)
26
- st->buffer[st->leftover + i] = m[i];
27
- bytes -= want;
28
- m += want;
29
- st->leftover += want;
30
- if (st->leftover < poly1305_block_size)
31
- return;
32
- poly1305_blocks(st, st->buffer, poly1305_block_size);
33
- st->leftover = 0;
34
- }
35
-
36
- /* process full blocks */
37
- if (bytes >= poly1305_block_size) {
38
- unsigned long long want = (bytes & ~(poly1305_block_size - 1));
39
- poly1305_blocks(st, m, want);
40
- m += want;
41
- bytes -= want;
42
- }
43
-
44
- /* store leftover */
45
- if (bytes) {
46
- for (i = 0; i < bytes; i++)
47
- st->buffer[st->leftover + i] = m[i];
48
- st->leftover += bytes;
49
- }
13
+ poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
14
+ unsigned long long i;
15
+
16
+ /* handle leftover */
17
+ if (st->leftover) {
18
+ unsigned long long want = (poly1305_block_size - st->leftover);
19
+ if (want > bytes)
20
+ want = bytes;
21
+ for (i = 0; i < want; i++)
22
+ st->buffer[st->leftover + i] = m[i];
23
+ bytes -= want;
24
+ m += want;
25
+ st->leftover += want;
26
+ if (st->leftover < poly1305_block_size)
27
+ return;
28
+ poly1305_blocks(st, st->buffer, poly1305_block_size);
29
+ st->leftover = 0;
30
+ }
31
+
32
+ /* process full blocks */
33
+ if (bytes >= poly1305_block_size) {
34
+ unsigned long long want = (bytes & ~(poly1305_block_size - 1));
35
+ poly1305_blocks(st, m, want);
36
+ m += want;
37
+ bytes -= want;
38
+ }
39
+
40
+ /* store leftover */
41
+ if (bytes) {
42
+ for (i = 0; i < bytes; i++)
43
+ st->buffer[st->leftover + i] = m[i];
44
+ st->leftover += bytes;
45
+ }
46
+ }
47
+
48
+ int
49
+ crypto_onetimeauth_poly1305_donna(unsigned char *out, const unsigned char *m,
50
+ unsigned long long inlen,
51
+ const unsigned char *key)
52
+ {
53
+ poly1305_context ctx;
54
+ poly1305_init(&ctx, key);
55
+ poly1305_update(&ctx, m, inlen);
56
+ poly1305_finish(&ctx, out);
57
+
58
+ return 0;
59
+ }
60
+
61
+ int
62
+ crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
63
+ const unsigned char *key)
64
+ {
65
+ poly1305_init((poly1305_context *) state, key);
66
+
67
+ return 0;
68
+ }
69
+
70
+ int
71
+ crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state,
72
+ const unsigned char *in,
73
+ unsigned long long inlen)
74
+ {
75
+ poly1305_update((poly1305_context *) state, in, inlen);
76
+
77
+ return 0;
50
78
  }
51
79
 
52
80
  int
53
- crypto_onetimeauth(unsigned char *out, const unsigned char *m,
54
- unsigned long long inlen, const unsigned char *key)
81
+ crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
82
+ unsigned char *out)
55
83
  {
56
- poly1305_context ctx;
57
- poly1305_init(&ctx, key);
58
- poly1305_update(&ctx, m, inlen);
59
- poly1305_finish(&ctx, out);
84
+ poly1305_finish((poly1305_context *) state, out);
60
85
 
61
86
  return 0;
62
87
  }
63
88
 
89
+
64
90
  const char *
65
- crypto_onetimeauth_poly1305_implementation_name(void)
91
+ crypto_onetimeauth_poly1305_donna_implementation_name(void)
66
92
  {
67
93
  return POLY1305_IMPLEMENTATION_NAME;
68
94
  }
69
95
 
70
96
  struct crypto_onetimeauth_poly1305_implementation
71
97
  crypto_onetimeauth_poly1305_donna_implementation = {
72
- _SODIUM_C99(.implementation_name =) crypto_onetimeauth_poly1305_implementation_name,
73
- _SODIUM_C99(.onetimeauth =) crypto_onetimeauth,
74
- _SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_verify
98
+ _SODIUM_C99(.implementation_name =) crypto_onetimeauth_poly1305_donna_implementation_name,
99
+ _SODIUM_C99(.onetimeauth =) crypto_onetimeauth_poly1305_donna,
100
+ _SODIUM_C99(.onetimeauth_verify =) crypto_onetimeauth_poly1305_donna_verify,
101
+ _SODIUM_C99(.onetimeauth_init =) crypto_onetimeauth_poly1305_donna_init,
102
+ _SODIUM_C99(.onetimeauth_update =) crypto_onetimeauth_poly1305_donna_update,
103
+ _SODIUM_C99(.onetimeauth_final =) crypto_onetimeauth_poly1305_donna_final
75
104
  };
@@ -1,12 +1,35 @@
1
- #ifndef POLY1305_DONNA_H
2
- #define POLY1305_DONNA_H
1
+ #ifndef __POLY1305_DONNA_H__
2
+ #define __POLY1305_DONNA_H__
3
3
 
4
4
  #include <stddef.h>
5
5
 
6
- typedef struct poly1305_context {
7
- unsigned long long aligner;
8
- unsigned char opaque[136];
9
- } poly1305_context;
6
+ #include "crypto_onetimeauth_poly1305.h"
10
7
 
11
- #endif /* POLY1305_DONNA_H */
8
+ typedef crypto_onetimeauth_poly1305_state poly1305_context;
12
9
 
10
+ extern struct crypto_onetimeauth_poly1305_implementation
11
+ crypto_onetimeauth_poly1305_donna_implementation;
12
+
13
+ const char *crypto_onetimeauth_poly1305_donna_implementation_name(void);
14
+
15
+ int crypto_onetimeauth_poly1305_donna(unsigned char *out,
16
+ const unsigned char *in,
17
+ unsigned long long inlen,
18
+ const unsigned char *k);
19
+
20
+ int crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h,
21
+ const unsigned char *in,
22
+ unsigned long long inlen,
23
+ const unsigned char *k);
24
+
25
+ int crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state,
26
+ const unsigned char *key);
27
+
28
+ int crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state,
29
+ const unsigned char *in,
30
+ unsigned long long inlen);
31
+
32
+ int crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state,
33
+ unsigned char *out);
34
+
35
+ #endif /* __POLY1305_DONNA_H__ */
@@ -45,7 +45,7 @@ U32TO8(unsigned char *p, unsigned long v) {
45
45
 
46
46
  static void
47
47
  poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
48
- poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
48
+ poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
49
49
 
50
50
  /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
51
51
  st->r[0] = (U8TO32(&key[ 0]) ) & 0x3ffffff;
@@ -134,7 +134,7 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned
134
134
 
135
135
  static POLY1305_NOINLINE void
136
136
  poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
137
- poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
137
+ poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
138
138
  unsigned long h0,h1,h2,h3,h4,c;
139
139
  unsigned long g0,g1,g2,g3,g4;
140
140
  unsigned long long f;
@@ -203,19 +203,6 @@ poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
203
203
  U32TO8(mac + 12, h3);
204
204
 
205
205
  /* zero out the state */
206
- st->h[0] = 0;
207
- st->h[1] = 0;
208
- st->h[2] = 0;
209
- st->h[3] = 0;
210
- st->h[4] = 0;
211
- st->r[0] = 0;
212
- st->r[1] = 0;
213
- st->r[2] = 0;
214
- st->r[3] = 0;
215
- st->r[4] = 0;
216
- st->pad[0] = 0;
217
- st->pad[1] = 0;
218
- st->pad[2] = 0;
219
- st->pad[3] = 0;
206
+ sodium_memzero((void *)st, sizeof *st);
220
207
  }
221
208
 
@@ -59,7 +59,7 @@ U64TO8(unsigned char *p, unsigned long long v) {
59
59
 
60
60
  static void
61
61
  poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
62
- poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
62
+ poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
63
63
  unsigned long long t0,t1;
64
64
 
65
65
  /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
@@ -138,7 +138,7 @@ poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned
138
138
 
139
139
  static POLY1305_NOINLINE void
140
140
  poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
141
- poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
141
+ poly1305_state_internal_t *st = (poly1305_state_internal_t *)(void *)ctx;
142
142
  unsigned long long h0,h1,h2,c;
143
143
  unsigned long long g0,g1,g2;
144
144
  unsigned long long t0,t1;
@@ -197,13 +197,6 @@ poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
197
197
  U64TO8(&mac[8], h1);
198
198
 
199
199
  /* zero out the state */
200
- st->h[0] = 0;
201
- st->h[1] = 0;
202
- st->h[2] = 0;
203
- st->r[0] = 0;
204
- st->r[1] = 0;
205
- st->r[2] = 0;
206
- st->pad[0] = 0;
207
- st->pad[1] = 0;
200
+ sodium_memzero((void *)st, sizeof *st);
208
201
  }
209
202
 
@@ -1,10 +1,15 @@
1
- #include "api.h"
2
- #include "crypto_onetimeauth_poly1305_donna.h"
1
+ #include "crypto_onetimeauth_poly1305.h"
3
2
  #include "crypto_verify_16.h"
3
+ #include "poly1305_donna.h"
4
4
 
5
- int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
5
+ int
6
+ crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h,
7
+ const unsigned char *in,
8
+ unsigned long long inlen,
9
+ const unsigned char *k)
6
10
  {
7
- unsigned char correct[16];
8
- crypto_onetimeauth(correct,in,inlen,k);
9
- return crypto_verify_16(h,correct);
11
+ unsigned char correct[16];
12
+
13
+ crypto_onetimeauth_poly1305_donna(correct,in,inlen,k);
14
+ return crypto_verify_16(h,correct);
10
15
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  #include "crypto_onetimeauth_poly1305.h"
3
- #include "crypto_onetimeauth_poly1305_donna.h"
3
+ #include "donna/poly1305_donna.h"
4
4
 
5
5
  static const crypto_onetimeauth_poly1305_implementation *implementation =
6
6
  &crypto_onetimeauth_poly1305_donna_implementation;
@@ -34,3 +34,25 @@ crypto_onetimeauth_poly1305_verify(const unsigned char *h,
34
34
  {
35
35
  return implementation->onetimeauth_verify(h, in, inlen, k);
36
36
  }
37
+
38
+ int
39
+ crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state,
40
+ const unsigned char *key)
41
+ {
42
+ return implementation->onetimeauth_init(state, key);
43
+ }
44
+
45
+ int
46
+ crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state,
47
+ const unsigned char *in,
48
+ unsigned long long inlen)
49
+ {
50
+ return implementation->onetimeauth_update(state, in, inlen);
51
+ }
52
+
53
+ int
54
+ crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state,
55
+ unsigned char *out)
56
+ {
57
+ return implementation->onetimeauth_final(state, out);
58
+ }
@@ -3,8 +3,8 @@
3
3
  #include <string.h>
4
4
  #include "crypto_onetimeauth.h"
5
5
  #include "crypto_onetimeauth_poly1305.h"
6
- #include "crypto_onetimeauth_poly1305_donna.h"
7
6
  #include "utils.h"
7
+ #include "donna/poly1305_donna.h"
8
8
 
9
9
  crypto_onetimeauth_poly1305_implementation *
10
10
  crypto_onetimeauth_pick_best_implementation(void)
@@ -21,7 +21,7 @@
21
21
  #include <stdint.h>
22
22
  #include <string.h>
23
23
 
24
- #include "crypto_pwhash_scryptxsalsa208sha256.h"
24
+ #include "crypto_pwhash_scryptsalsa208sha256.h"
25
25
  #include "crypto_scrypt.h"
26
26
  #include "runtime.h"
27
27
  #include "utils.h"
@@ -107,7 +107,7 @@ uint8_t *
107
107
  escrypt_r(escrypt_local_t * local, const uint8_t * passwd, size_t passwdlen,
108
108
  const uint8_t * setting, uint8_t * buf, size_t buflen)
109
109
  {
110
- uint8_t hash[crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES];
110
+ uint8_t hash[crypto_pwhash_scryptsalsa208sha256_STRHASHBYTES];
111
111
  escrypt_kdf_t escrypt_kdf;
112
112
  const uint8_t *src;
113
113
  const uint8_t *salt;
@@ -149,7 +149,7 @@ escrypt_r(escrypt_local_t * local, const uint8_t * passwd, size_t passwdlen,
149
149
  saltlen = strlen((char *)salt);
150
150
  }
151
151
  need = prefixlen + saltlen + 1 +
152
- crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED + 1;
152
+ crypto_pwhash_scryptsalsa208sha256_STRHASHBYTES_ENCODED + 1;
153
153
  if (need > buflen || need < saltlen) {
154
154
  return NULL;
155
155
  }
@@ -222,10 +222,10 @@ escrypt_gensalt_r(uint32_t N_log2, uint32_t r, uint32_t p,
222
222
  }
223
223
 
224
224
  int
225
- crypto_scrypt_compat(const uint8_t * passwd, size_t passwdlen,
226
- const uint8_t * salt, size_t saltlen,
227
- uint64_t N, uint32_t r, uint32_t p,
228
- uint8_t * buf, size_t buflen)
225
+ crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen,
226
+ const uint8_t * salt, size_t saltlen,
227
+ uint64_t N, uint32_t r, uint32_t p,
228
+ uint8_t * buf, size_t buflen)
229
229
  {
230
230
  escrypt_kdf_t escrypt_kdf;
231
231
  escrypt_local_t local;
@@ -32,29 +32,15 @@
32
32
 
33
33
  #include <stdint.h>
34
34
 
35
- #define crypto_pwhash_scryptxsalsa208sha256_STRPREFIXBYTES 14
36
- #define crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES 57
37
- #define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES 32
38
- #define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES_ENCODED 43
39
- #define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES 32
40
- #define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED 43
35
+ #define crypto_pwhash_scryptsalsa208sha256_STRPREFIXBYTES 14
36
+ #define crypto_pwhash_scryptsalsa208sha256_STRSETTINGBYTES 57
37
+ #define crypto_pwhash_scryptsalsa208sha256_STRSALTBYTES 32
38
+ #define crypto_pwhash_scryptsalsa208sha256_STRSALTBYTES_ENCODED 43
39
+ #define crypto_pwhash_scryptsalsa208sha256_STRHASHBYTES 32
40
+ #define crypto_pwhash_scryptsalsa208sha256_STRHASHBYTES_ENCODED 43
41
41
 
42
42
  #define BYTES2CHARS(bytes) ((((bytes) * 8) + 5) / 6)
43
43
 
44
- /**
45
- * crypto_scrypt_compat(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
46
- * Compute scrypt(passwd[0 .. passwdlen - 1], salt[0 .. saltlen - 1], N, r,
47
- * p, buflen) and write the result into buf. The parameters r, p, and buflen
48
- * must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32. The parameter N
49
- * must be a power of 2 greater than 1.
50
- *
51
- * Return 0 on success; or -1 on error.
52
- */
53
- extern int crypto_scrypt_compat(const uint8_t * __passwd, size_t __passwdlen,
54
- const uint8_t * __salt, size_t __saltlen,
55
- uint64_t __N, uint32_t __r, uint32_t __p,
56
- uint8_t * __buf, size_t __buflen);
57
-
58
44
  typedef struct {
59
45
  void * base, * aligned;
60
46
  size_t size;
@@ -32,19 +32,9 @@
32
32
 
33
33
  #include "crypto_auth_hmacsha256.h"
34
34
  #include "pbkdf2-sha256.h"
35
+ #include "sysendian.h"
35
36
  #include "utils.h"
36
37
 
37
- static inline void
38
- be32enc(void *pp, uint32_t x)
39
- {
40
- uint8_t * p = (uint8_t *)pp;
41
-
42
- p[3] = x & 0xff;
43
- p[2] = (x >> 8) & 0xff;
44
- p[1] = (x >> 16) & 0xff;
45
- p[0] = (x >> 24) & 0xff;
46
- }
47
-
48
38
  /**
49
39
  * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
50
40
  * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and