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
@@ -5,7 +5,7 @@
5
5
  #include <stdint.h>
6
6
  #include <string.h>
7
7
 
8
- #include "crypto_pwhash_scryptxsalsa208sha256.h"
8
+ #include "crypto_pwhash_scryptsalsa208sha256.h"
9
9
  #include "crypto_scrypt.h"
10
10
  #include "randombytes.h"
11
11
  #include "utils.h"
@@ -50,19 +50,43 @@ pickparams(unsigned long long opslimit, const size_t memlimit,
50
50
  }
51
51
 
52
52
  size_t
53
- crypto_pwhash_scryptxsalsa208sha256_saltbytes(void)
53
+ crypto_pwhash_scryptsalsa208sha256_saltbytes(void)
54
54
  {
55
- return crypto_pwhash_scryptxsalsa208sha256_SALTBYTES;
55
+ return crypto_pwhash_scryptsalsa208sha256_SALTBYTES;
56
56
  }
57
57
 
58
58
  size_t
59
- crypto_pwhash_scryptxsalsa208sha256_strbytes(void)
59
+ crypto_pwhash_scryptsalsa208sha256_strbytes(void)
60
60
  {
61
- return crypto_pwhash_scryptxsalsa208sha256_STRBYTES;
61
+ return crypto_pwhash_scryptsalsa208sha256_STRBYTES;
62
+ }
63
+
64
+ size_t
65
+ crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void)
66
+ {
67
+ return crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE;
68
+ }
69
+
70
+ size_t
71
+ crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void)
72
+ {
73
+ return crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE;
74
+ }
75
+
76
+ size_t
77
+ crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void)
78
+ {
79
+ return crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE;
80
+ }
81
+
82
+ size_t
83
+ crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive(void)
84
+ {
85
+ return crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE;
62
86
  }
63
87
 
64
88
  int
65
- crypto_pwhash_scryptxsalsa208sha256(unsigned char * const out,
89
+ crypto_pwhash_scryptsalsa208sha256(unsigned char * const out,
66
90
  unsigned long long outlen,
67
91
  const char * const passwd,
68
92
  unsigned long long passwdlen,
@@ -83,28 +107,29 @@ crypto_pwhash_scryptxsalsa208sha256(unsigned char * const out,
83
107
  errno = EINVAL;
84
108
  return -1;
85
109
  }
86
- return crypto_scrypt_compat((const uint8_t *) passwd, (size_t) passwdlen,
87
- (const uint8_t *) salt,
88
- crypto_pwhash_scryptxsalsa208sha256_SALTBYTES,
89
- (uint64_t) (1) << N_log2, r, p,
90
- out, (size_t) outlen);
110
+ return crypto_pwhash_scryptsalsa208sha256_ll((const uint8_t *) passwd,
111
+ (size_t) passwdlen,
112
+ (const uint8_t *) salt,
113
+ crypto_pwhash_scryptsalsa208sha256_SALTBYTES,
114
+ (uint64_t) (1) << N_log2, r, p,
115
+ out, (size_t) outlen);
91
116
  }
92
117
 
93
118
  int
94
- crypto_pwhash_scryptxsalsa208sha256_str(char out[crypto_pwhash_scryptxsalsa208sha256_STRBYTES],
119
+ crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
95
120
  const char * const passwd,
96
121
  unsigned long long passwdlen,
97
122
  unsigned long long opslimit,
98
123
  size_t memlimit)
99
124
  {
100
- uint8_t salt[crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES];
101
- char setting[crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES + 1U];
125
+ uint8_t salt[crypto_pwhash_scryptsalsa208sha256_STRSALTBYTES];
126
+ char setting[crypto_pwhash_scryptsalsa208sha256_STRSETTINGBYTES + 1U];
102
127
  escrypt_local_t escrypt_local;
103
128
  uint32_t N_log2;
104
129
  uint32_t p;
105
130
  uint32_t r;
106
131
 
107
- memset(out, 0, crypto_pwhash_scryptxsalsa208sha256_STRBYTES);
132
+ memset(out, 0, crypto_pwhash_scryptsalsa208sha256_STRBYTES);
108
133
  if (passwdlen > SIZE_MAX) {
109
134
  errno = EFBIG;
110
135
  return -1;
@@ -124,7 +149,7 @@ crypto_pwhash_scryptxsalsa208sha256_str(char out[crypto_pwhash_scryptxsalsa208sh
124
149
  }
125
150
  if (escrypt_r(&escrypt_local, (const uint8_t *) passwd, (size_t) passwdlen,
126
151
  (const uint8_t *) setting, (uint8_t *) out,
127
- crypto_pwhash_scryptxsalsa208sha256_STRBYTES) == NULL) {
152
+ crypto_pwhash_scryptsalsa208sha256_STRBYTES) == NULL) {
128
153
  escrypt_free_local(&escrypt_local);
129
154
  errno = EINVAL;
130
155
  return -1;
@@ -132,27 +157,27 @@ crypto_pwhash_scryptxsalsa208sha256_str(char out[crypto_pwhash_scryptxsalsa208sh
132
157
  escrypt_free_local(&escrypt_local);
133
158
 
134
159
  (void) sizeof
135
- (int[SETTING_SIZE(crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES)
136
- == crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES ? 1 : -1]);
160
+ (int[SETTING_SIZE(crypto_pwhash_scryptsalsa208sha256_STRSALTBYTES)
161
+ == crypto_pwhash_scryptsalsa208sha256_STRSETTINGBYTES ? 1 : -1]);
137
162
  (void) sizeof
138
- (int[crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES + 1U +
139
- crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED + 1U
140
- == crypto_pwhash_scryptxsalsa208sha256_STRBYTES ? 1 : -1]);
163
+ (int[crypto_pwhash_scryptsalsa208sha256_STRSETTINGBYTES + 1U +
164
+ crypto_pwhash_scryptsalsa208sha256_STRHASHBYTES_ENCODED + 1U
165
+ == crypto_pwhash_scryptsalsa208sha256_STRBYTES ? 1 : -1]);
141
166
 
142
167
  return 0;
143
168
  }
144
169
 
145
170
  int
146
- crypto_pwhash_scryptxsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptxsalsa208sha256_STRBYTES],
171
+ crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
147
172
  const char * const passwd,
148
173
  unsigned long long passwdlen)
149
174
  {
150
- char wanted[crypto_pwhash_scryptxsalsa208sha256_STRBYTES];
175
+ char wanted[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
151
176
  escrypt_local_t escrypt_local;
152
177
  int ret = -1;
153
178
 
154
- if (memchr(str, 0, crypto_pwhash_scryptxsalsa208sha256_STRBYTES) !=
155
- &str[crypto_pwhash_scryptxsalsa208sha256_STRBYTES - 1U]) {
179
+ if (memchr(str, 0, crypto_pwhash_scryptsalsa208sha256_STRBYTES) !=
180
+ &str[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U]) {
156
181
  return -1;
157
182
  }
158
183
  if (escrypt_init_local(&escrypt_local) != 0) {
@@ -27,6 +27,10 @@
27
27
  #include "crypto_scrypt.h"
28
28
  #include "runtime.h"
29
29
 
30
+ #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
31
+ # define MAP_ANON MAP_ANONYMOUS
32
+ #endif
33
+
30
34
  void *
31
35
  alloc_region(escrypt_region_t * region, size_t size)
32
36
  {
@@ -226,7 +226,7 @@ fexpand(limb *output, const u8 *in) {
226
226
  output[1] = (U8TO64(in+6) >> 3) & 0x7ffffffffffff;
227
227
  output[2] = (U8TO64(in+12) >> 6) & 0x7ffffffffffff;
228
228
  output[3] = (U8TO64(in+19) >> 1) & 0x7ffffffffffff;
229
- output[4] = (U8TO64(in+25) >> 4) & 0xfffffffffffff;
229
+ output[4] = (U8TO64(in+25) >> 4) & 0x7ffffffffffff;
230
230
  }
231
231
 
232
232
  /* Take a fully reduced polynomial form number and contract it into a
@@ -1,8 +1,5 @@
1
1
 
2
2
  #include "crypto_scalarmult_curve25519.h"
3
3
 
4
- #define crypto_scalarmult_curve25519_implementation_name \
5
- crypto_scalarmult_curve25519_ref_implementation_name
6
-
7
4
  #define crypto_scalarmult crypto_scalarmult_curve25519
8
5
  #define crypto_scalarmult_base crypto_scalarmult_curve25519_base
@@ -0,0 +1,14 @@
1
+
2
+ #include "api.h"
3
+ #include "crypto_scalarmult.h"
4
+
5
+ #ifndef HAVE_TI_MODE
6
+
7
+ static const unsigned char basepoint[32] = {9};
8
+
9
+ int crypto_scalarmult_base(unsigned char *q,const unsigned char *n)
10
+ {
11
+ return crypto_scalarmult(q,n,basepoint);
12
+ }
13
+
14
+ #endif
@@ -0,0 +1,44 @@
1
+ #ifndef FE_H
2
+ #define FE_H
3
+
4
+ #include "crypto_int32.h"
5
+
6
+ typedef crypto_int32 fe[10];
7
+
8
+ /*
9
+ fe means field element.
10
+ Here the field is \Z/(2^255-19).
11
+ An element t, entries t[0]...t[9], represents the integer
12
+ t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
13
+ Bounds on each t[i] vary depending on context.
14
+ */
15
+
16
+ #define fe_frombytes crypto_scalarmult_curve25519_ref10_fe_frombytes
17
+ #define fe_tobytes crypto_scalarmult_curve25519_ref10_fe_tobytes
18
+ #define fe_copy crypto_scalarmult_curve25519_ref10_fe_copy
19
+ #define fe_0 crypto_scalarmult_curve25519_ref10_fe_0
20
+ #define fe_1 crypto_scalarmult_curve25519_ref10_fe_1
21
+ #define fe_cswap crypto_scalarmult_curve25519_ref10_fe_cswap
22
+ #define fe_add crypto_scalarmult_curve25519_ref10_fe_add
23
+ #define fe_sub crypto_scalarmult_curve25519_ref10_fe_sub
24
+ #define fe_mul crypto_scalarmult_curve25519_ref10_fe_mul
25
+ #define fe_sq crypto_scalarmult_curve25519_ref10_fe_sq
26
+ #define fe_mul121666 crypto_scalarmult_curve25519_ref10_fe_mul121666
27
+ #define fe_invert crypto_scalarmult_curve25519_ref10_fe_invert
28
+
29
+ extern void fe_frombytes(fe,const unsigned char *);
30
+ extern void fe_tobytes(unsigned char *,fe);
31
+
32
+ extern void fe_copy(fe,fe);
33
+ extern void fe_0(fe);
34
+ extern void fe_1(fe);
35
+ extern void fe_cswap(fe,fe,unsigned int);
36
+
37
+ extern void fe_add(fe,fe,fe);
38
+ extern void fe_sub(fe,fe,fe);
39
+ extern void fe_mul(fe,fe,fe);
40
+ extern void fe_sq(fe,fe);
41
+ extern void fe_mul121666(fe,fe);
42
+ extern void fe_invert(fe,fe);
43
+
44
+ #endif
@@ -0,0 +1,23 @@
1
+ #include "fe.h"
2
+
3
+ #ifndef HAVE_TI_MODE
4
+
5
+ /*
6
+ h = 0
7
+ */
8
+
9
+ void fe_0(fe h)
10
+ {
11
+ h[0] = 0;
12
+ h[1] = 0;
13
+ h[2] = 0;
14
+ h[3] = 0;
15
+ h[4] = 0;
16
+ h[5] = 0;
17
+ h[6] = 0;
18
+ h[7] = 0;
19
+ h[8] = 0;
20
+ h[9] = 0;
21
+ }
22
+
23
+ #endif
@@ -0,0 +1,23 @@
1
+ #include "fe.h"
2
+
3
+ #ifndef HAVE_TI_MODE
4
+
5
+ /*
6
+ h = 1
7
+ */
8
+
9
+ void fe_1(fe h)
10
+ {
11
+ h[0] = 1;
12
+ h[1] = 0;
13
+ h[2] = 0;
14
+ h[3] = 0;
15
+ h[4] = 0;
16
+ h[5] = 0;
17
+ h[6] = 0;
18
+ h[7] = 0;
19
+ h[8] = 0;
20
+ h[9] = 0;
21
+ }
22
+
23
+ #endif
@@ -0,0 +1,61 @@
1
+ #include "fe.h"
2
+
3
+ #ifndef HAVE_TI_MODE
4
+
5
+ /*
6
+ h = f + g
7
+ Can overlap h with f or g.
8
+
9
+ Preconditions:
10
+ |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
11
+ |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
12
+
13
+ Postconditions:
14
+ |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
15
+ */
16
+
17
+ void fe_add(fe h,fe f,fe g)
18
+ {
19
+ crypto_int32 f0 = f[0];
20
+ crypto_int32 f1 = f[1];
21
+ crypto_int32 f2 = f[2];
22
+ crypto_int32 f3 = f[3];
23
+ crypto_int32 f4 = f[4];
24
+ crypto_int32 f5 = f[5];
25
+ crypto_int32 f6 = f[6];
26
+ crypto_int32 f7 = f[7];
27
+ crypto_int32 f8 = f[8];
28
+ crypto_int32 f9 = f[9];
29
+ crypto_int32 g0 = g[0];
30
+ crypto_int32 g1 = g[1];
31
+ crypto_int32 g2 = g[2];
32
+ crypto_int32 g3 = g[3];
33
+ crypto_int32 g4 = g[4];
34
+ crypto_int32 g5 = g[5];
35
+ crypto_int32 g6 = g[6];
36
+ crypto_int32 g7 = g[7];
37
+ crypto_int32 g8 = g[8];
38
+ crypto_int32 g9 = g[9];
39
+ crypto_int32 h0 = f0 + g0;
40
+ crypto_int32 h1 = f1 + g1;
41
+ crypto_int32 h2 = f2 + g2;
42
+ crypto_int32 h3 = f3 + g3;
43
+ crypto_int32 h4 = f4 + g4;
44
+ crypto_int32 h5 = f5 + g5;
45
+ crypto_int32 h6 = f6 + g6;
46
+ crypto_int32 h7 = f7 + g7;
47
+ crypto_int32 h8 = f8 + g8;
48
+ crypto_int32 h9 = f9 + g9;
49
+ h[0] = h0;
50
+ h[1] = h1;
51
+ h[2] = h2;
52
+ h[3] = h3;
53
+ h[4] = h4;
54
+ h[5] = h5;
55
+ h[6] = h6;
56
+ h[7] = h7;
57
+ h[8] = h8;
58
+ h[9] = h9;
59
+ }
60
+
61
+ #endif
@@ -0,0 +1,33 @@
1
+ #include "fe.h"
2
+
3
+ #ifndef HAVE_TI_MODE
4
+
5
+ /*
6
+ h = f
7
+ */
8
+
9
+ void fe_copy(fe h,fe f)
10
+ {
11
+ crypto_int32 f0 = f[0];
12
+ crypto_int32 f1 = f[1];
13
+ crypto_int32 f2 = f[2];
14
+ crypto_int32 f3 = f[3];
15
+ crypto_int32 f4 = f[4];
16
+ crypto_int32 f5 = f[5];
17
+ crypto_int32 f6 = f[6];
18
+ crypto_int32 f7 = f[7];
19
+ crypto_int32 f8 = f[8];
20
+ crypto_int32 f9 = f[9];
21
+ h[0] = f0;
22
+ h[1] = f1;
23
+ h[2] = f2;
24
+ h[3] = f3;
25
+ h[4] = f4;
26
+ h[5] = f5;
27
+ h[6] = f6;
28
+ h[7] = f7;
29
+ h[8] = f8;
30
+ h[9] = f9;
31
+ }
32
+
33
+ #endif
@@ -0,0 +1,77 @@
1
+ #include "fe.h"
2
+
3
+ #ifndef HAVE_TI_MODE
4
+
5
+ /*
6
+ Replace (f,g) with (g,f) if b == 1;
7
+ replace (f,g) with (f,g) if b == 0.
8
+
9
+ Preconditions: b in {0,1}.
10
+ */
11
+
12
+ void fe_cswap(fe f,fe g,unsigned int b)
13
+ {
14
+ crypto_int32 f0 = f[0];
15
+ crypto_int32 f1 = f[1];
16
+ crypto_int32 f2 = f[2];
17
+ crypto_int32 f3 = f[3];
18
+ crypto_int32 f4 = f[4];
19
+ crypto_int32 f5 = f[5];
20
+ crypto_int32 f6 = f[6];
21
+ crypto_int32 f7 = f[7];
22
+ crypto_int32 f8 = f[8];
23
+ crypto_int32 f9 = f[9];
24
+ crypto_int32 g0 = g[0];
25
+ crypto_int32 g1 = g[1];
26
+ crypto_int32 g2 = g[2];
27
+ crypto_int32 g3 = g[3];
28
+ crypto_int32 g4 = g[4];
29
+ crypto_int32 g5 = g[5];
30
+ crypto_int32 g6 = g[6];
31
+ crypto_int32 g7 = g[7];
32
+ crypto_int32 g8 = g[8];
33
+ crypto_int32 g9 = g[9];
34
+ crypto_int32 x0 = f0 ^ g0;
35
+ crypto_int32 x1 = f1 ^ g1;
36
+ crypto_int32 x2 = f2 ^ g2;
37
+ crypto_int32 x3 = f3 ^ g3;
38
+ crypto_int32 x4 = f4 ^ g4;
39
+ crypto_int32 x5 = f5 ^ g5;
40
+ crypto_int32 x6 = f6 ^ g6;
41
+ crypto_int32 x7 = f7 ^ g7;
42
+ crypto_int32 x8 = f8 ^ g8;
43
+ crypto_int32 x9 = f9 ^ g9;
44
+ b = -b;
45
+ x0 &= b;
46
+ x1 &= b;
47
+ x2 &= b;
48
+ x3 &= b;
49
+ x4 &= b;
50
+ x5 &= b;
51
+ x6 &= b;
52
+ x7 &= b;
53
+ x8 &= b;
54
+ x9 &= b;
55
+ f[0] = f0 ^ x0;
56
+ f[1] = f1 ^ x1;
57
+ f[2] = f2 ^ x2;
58
+ f[3] = f3 ^ x3;
59
+ f[4] = f4 ^ x4;
60
+ f[5] = f5 ^ x5;
61
+ f[6] = f6 ^ x6;
62
+ f[7] = f7 ^ x7;
63
+ f[8] = f8 ^ x8;
64
+ f[9] = f9 ^ x9;
65
+ g[0] = g0 ^ x0;
66
+ g[1] = g1 ^ x1;
67
+ g[2] = g2 ^ x2;
68
+ g[3] = g3 ^ x3;
69
+ g[4] = g4 ^ x4;
70
+ g[5] = g5 ^ x5;
71
+ g[6] = g6 ^ x6;
72
+ g[7] = g7 ^ x7;
73
+ g[8] = g8 ^ x8;
74
+ g[9] = g9 ^ x9;
75
+ }
76
+
77
+ #endif