rbnacl-libsodium 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +6 -2
  3. data/lib/rbnacl/libsodium/version.rb +1 -1
  4. data/vendor/libsodium/ChangeLog +24 -0
  5. data/vendor/libsodium/LICENSE +2 -0
  6. data/vendor/libsodium/Makefile.in +6 -1
  7. data/vendor/libsodium/aclocal.m4 +1 -0
  8. data/vendor/libsodium/autom4te.cache/output.1 +1896 -1136
  9. data/vendor/libsodium/autom4te.cache/output.7 +19837 -0
  10. data/vendor/libsodium/autom4te.cache/requests +1271 -1031
  11. data/vendor/libsodium/autom4te.cache/traces.1 +532 -491
  12. data/vendor/libsodium/autom4te.cache/traces.7 +3614 -0
  13. data/vendor/libsodium/builds/msvc/version.h +2 -2
  14. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +22 -1
  15. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +23 -20
  16. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +13 -2
  17. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +12 -9
  18. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +12 -1
  19. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +3 -0
  20. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +2 -1
  21. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +14 -11
  22. data/vendor/libsodium/configure +1887 -1127
  23. data/vendor/libsodium/configure.ac +44 -11
  24. data/vendor/libsodium/dist-build/Makefile.am +4 -2
  25. data/vendor/libsodium/dist-build/Makefile.in +9 -2
  26. data/vendor/libsodium/dist-build/android-armv8-a.sh +1 -1
  27. data/vendor/libsodium/dist-build/android-build.sh +40 -3
  28. data/vendor/libsodium/dist-build/android-mips64.sh +1 -1
  29. data/vendor/libsodium/dist-build/android-x86_64.sh +4 -0
  30. data/vendor/libsodium/dist-build/emscripten-symbols.def +25 -25
  31. data/vendor/libsodium/dist-build/emscripten.sh +69 -35
  32. data/vendor/libsodium/dist-build/msys2-win32.sh +8 -2
  33. data/vendor/libsodium/dist-build/msys2-win64.sh +8 -2
  34. data/vendor/libsodium/dist-build/{nativeclient.sh → nativeclient-pnacl.sh} +3 -4
  35. data/vendor/libsodium/dist-build/nativeclient-x86.sh +19 -0
  36. data/vendor/libsodium/dist-build/nativeclient-x86_64.sh +19 -0
  37. data/vendor/libsodium/logo.png +0 -0
  38. data/vendor/libsodium/m4/ax_pthread.m4 +485 -0
  39. data/vendor/libsodium/msvc-scripts/Makefile.in +5 -0
  40. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  41. data/vendor/libsodium/packaging/nuget/package.bat +3 -3
  42. data/vendor/libsodium/src/Makefile.in +5 -0
  43. data/vendor/libsodium/src/libsodium/Makefile.am +2 -1
  44. data/vendor/libsodium/src/libsodium/Makefile.in +13 -8
  45. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +70 -87
  46. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +6 -0
  47. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +1 -1
  48. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +9 -1
  49. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +11 -4
  50. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +14 -8
  51. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +0 -1
  52. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +10 -6
  53. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +2 -1
  54. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +1 -1
  55. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +11 -11
  56. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.h +2 -2
  57. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +3 -0
  58. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +3 -0
  59. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +830 -826
  60. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +732 -728
  61. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +3 -0
  62. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +1 -1
  63. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +8 -0
  64. data/vendor/libsodium/src/libsodium/include/Makefile.in +5 -0
  65. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +1 -1
  66. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +1 -1
  67. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +1 -1
  68. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +1 -1
  69. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +1 -1
  70. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +1 -1
  71. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +3 -3
  72. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +1 -1
  73. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +1 -1
  74. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +1 -1
  75. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +1 -1
  76. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +1 -1
  77. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +1 -1
  78. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +1 -1
  79. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +1 -1
  80. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +1 -1
  81. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +1 -1
  82. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +1 -1
  83. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +1 -1
  84. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +1 -1
  85. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +1 -1
  86. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +1 -1
  87. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +3 -3
  88. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +1 -1
  89. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +1 -1
  90. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +1 -1
  91. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +1 -1
  92. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +1 -1
  93. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +1 -1
  94. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +1 -1
  95. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +1 -1
  96. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +1 -1
  97. data/vendor/libsodium/src/libsodium/include/sodium/private/curve25519_ref10.h +2 -2
  98. data/vendor/libsodium/src/libsodium/include/sodium/private/mutex.h +7 -0
  99. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +1 -1
  100. data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +15 -4
  101. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +25 -15
  102. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +72 -15
  103. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +43 -4
  104. data/vendor/libsodium/src/libsodium/sodium/core.c +131 -2
  105. data/vendor/libsodium/src/libsodium/sodium/runtime.c +5 -2
  106. data/vendor/libsodium/src/libsodium/sodium/utils.c +16 -8
  107. data/vendor/libsodium/test/Makefile.in +5 -0
  108. data/vendor/libsodium/test/default/Makefile.in +5 -0
  109. data/vendor/libsodium/test/default/generichash2.c +8 -2
  110. data/vendor/libsodium/test/default/nacl-test-wrapper.sh +19 -17
  111. data/vendor/libsodium/test/default/randombytes.c +4 -2
  112. data/vendor/libsodium/test/quirks/quirks.h +23 -2
  113. metadata +11 -15
  114. data/vendor/libsodium/README +0 -1
  115. data/vendor/libsodium/dist-build/android-x86-64.sh +0 -4
  116. data/vendor/libsodium/examples/Makefile +0 -21
  117. data/vendor/libsodium/examples/auth.c +0 -68
  118. data/vendor/libsodium/examples/box.c +0 -135
  119. data/vendor/libsodium/examples/box_detached.c +0 -134
  120. data/vendor/libsodium/examples/generichash.c +0 -80
  121. data/vendor/libsodium/examples/generichash_stream.c +0 -58
  122. data/vendor/libsodium/examples/shorthash.c +0 -58
  123. data/vendor/libsodium/examples/sign.c +0 -78
  124. data/vendor/libsodium/examples/utils.h +0 -110
@@ -168,12 +168,15 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
168
168
  #if defined(HAVE_AVX2INTRIN_H) || \
169
169
  (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
170
170
  if (cpu_features->has_avx) {
171
- cpu_features->has_avx2 = ((cpu_info[1] & CPUID_EBX_AVX2) != 0x0);
171
+ unsigned int cpu_info7[4];
172
+
173
+ _cpuid(cpu_info7, 0x00000007);
174
+ cpu_features->has_avx2 = ((cpu_info7[1] & CPUID_EBX_AVX2) != 0x0);
172
175
  }
173
176
  #endif
174
177
 
175
178
  #if defined(HAVE_WMMINTRIN_H) || \
176
- (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
179
+ (defined(_MSC_VER) && _MSC_VER >= 1600 && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
177
180
  cpu_features->has_pclmul = ((cpu_info[2] & CPUID_ECX_PCLMUL) != 0x0);
178
181
  cpu_features->has_aesni = ((cpu_info[2] & CPUID_ECX_AESNI) != 0x0);
179
182
  #else
@@ -14,8 +14,6 @@
14
14
  # include <sys/mman.h>
15
15
  #endif
16
16
 
17
- #include "utils.h"
18
- #include "randombytes.h"
19
17
  #ifdef _WIN32
20
18
  # include <windows.h>
21
19
  # include <wincrypt.h>
@@ -23,6 +21,9 @@
23
21
  # include <unistd.h>
24
22
  #endif
25
23
 
24
+ #include "utils.h"
25
+ #include "randombytes.h"
26
+
26
27
  #ifndef ENOSYS
27
28
  # define ENOSYS ENXIO
28
29
  #endif
@@ -49,16 +50,24 @@
49
50
  #if defined(HAVE_ALIGNED_MALLOC) && (defined(WINAPI_DESKTOP) || defined(HAVE_MPROTECT))
50
51
  # define HAVE_PAGE_PROTECTION
51
52
  #endif
53
+ #if !defined(MADV_DODUMP) && defined(MADV_CORE)
54
+ # define MADV_DODUMP MADV_CORE
55
+ # define MADV_DONTDUMP MADV_NOCORE
56
+ #endif
52
57
 
53
58
  static size_t page_size;
54
59
  static unsigned char canary[CANARY_SIZE];
55
60
 
56
61
  #ifdef HAVE_WEAK_SYMBOLS
57
62
  __attribute__ ((weak)) void
58
- _sodium_dummy_symbol_to_prevent_memzero_lto(void * const pnt, const size_t len)
63
+ _sodium_memzero_as_a_weak_symbol_to_prevent_lto(void * const pnt, const size_t len)
59
64
  {
60
- (void) pnt;
61
- (void) len;
65
+ unsigned char *pnt_ = (unsigned char *) pnt;;
66
+ size_t i = (size_t) 0U;
67
+
68
+ while (i < len) {
69
+ pnt_[i++] = 0U;
70
+ }
62
71
  }
63
72
  #endif
64
73
 
@@ -68,14 +77,13 @@ sodium_memzero(void * const pnt, const size_t len)
68
77
  #ifdef _WIN32
69
78
  SecureZeroMemory(pnt, len);
70
79
  #elif defined(HAVE_MEMSET_S)
71
- if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {
80
+ if (len > 0U && memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {
72
81
  abort(); /* LCOV_EXCL_LINE */
73
82
  }
74
83
  #elif defined(HAVE_EXPLICIT_BZERO)
75
84
  explicit_bzero(pnt, len);
76
85
  #elif HAVE_WEAK_SYMBOLS
77
- memset(pnt, 0, len);
78
- _sodium_dummy_symbol_to_prevent_memzero_lto(pnt, len);
86
+ _sodium_memzero_as_a_weak_symbol_to_prevent_lto(pnt, len);
79
87
  #else
80
88
  volatile unsigned char *volatile pnt_ =
81
89
  (volatile unsigned char * volatile) pnt;
@@ -92,6 +92,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
92
92
  am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
93
93
  $(top_srcdir)/m4/ax_check_define.m4 \
94
94
  $(top_srcdir)/m4/ax_check_link_flag.m4 \
95
+ $(top_srcdir)/m4/ax_pthread.m4 \
95
96
  $(top_srcdir)/m4/ax_valgrind_check.m4 \
96
97
  $(top_srcdir)/m4/ld-output-def.m4 $(top_srcdir)/m4/libtool.m4 \
97
98
  $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -265,6 +266,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
265
266
  PACKAGE_URL = @PACKAGE_URL@
266
267
  PACKAGE_VERSION = @PACKAGE_VERSION@
267
268
  PATH_SEPARATOR = @PATH_SEPARATOR@
269
+ PTHREAD_CC = @PTHREAD_CC@
270
+ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
271
+ PTHREAD_LIBS = @PTHREAD_LIBS@
268
272
  RANLIB = @RANLIB@
269
273
  SAFECODE_HOME = @SAFECODE_HOME@
270
274
  SED = @SED@
@@ -294,6 +298,7 @@ am__leading_dot = @am__leading_dot@
294
298
  am__quote = @am__quote@
295
299
  am__tar = @am__tar@
296
300
  am__untar = @am__untar@
301
+ ax_pthread_config = @ax_pthread_config@
297
302
  bindir = @bindir@
298
303
  build = @build@
299
304
  build_alias = @build_alias@
@@ -98,6 +98,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
98
98
  am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
99
99
  $(top_srcdir)/m4/ax_check_define.m4 \
100
100
  $(top_srcdir)/m4/ax_check_link_flag.m4 \
101
+ $(top_srcdir)/m4/ax_pthread.m4 \
101
102
  $(top_srcdir)/m4/ax_valgrind_check.m4 \
102
103
  $(top_srcdir)/m4/ld-output-def.m4 $(top_srcdir)/m4/libtool.m4 \
103
104
  $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -685,6 +686,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
685
686
  PACKAGE_URL = @PACKAGE_URL@
686
687
  PACKAGE_VERSION = @PACKAGE_VERSION@
687
688
  PATH_SEPARATOR = @PATH_SEPARATOR@
689
+ PTHREAD_CC = @PTHREAD_CC@
690
+ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
691
+ PTHREAD_LIBS = @PTHREAD_LIBS@
688
692
  RANLIB = @RANLIB@
689
693
  SAFECODE_HOME = @SAFECODE_HOME@
690
694
  SED = @SED@
@@ -714,6 +718,7 @@ am__leading_dot = @am__leading_dot@
714
718
  am__quote = @am__quote@
715
719
  am__tar = @am__tar@
716
720
  am__untar = @am__untar@
721
+ ax_pthread_config = @ax_pthread_config@
717
722
  bindir = @bindir@
718
723
  build = @build@
719
724
  build_alias = @build_alias@
@@ -26,12 +26,18 @@ main(void)
26
26
  crypto_generichash_update(&st, in, i);
27
27
  crypto_generichash_update(&st, in, i);
28
28
  crypto_generichash_update(&st, in, i);
29
- crypto_generichash_final(&st, out,
30
- 1 + i % crypto_generichash_BYTES_MAX);
29
+ if (crypto_generichash_final(&st, out,
30
+ 1 + i % crypto_generichash_BYTES_MAX) != 0) {
31
+ printf("crypto_generichash_final() should have returned 0\n");
32
+ }
31
33
  for (j = 0; j < 1 + i % crypto_generichash_BYTES_MAX; ++j) {
32
34
  printf("%02x", (unsigned int)out[j]);
33
35
  }
34
36
  printf("\n");
37
+ if (crypto_generichash_final(&st, out,
38
+ 1 + i % crypto_generichash_BYTES_MAX) != -1) {
39
+ printf("crypto_generichash_final() should have returned -1\n");
40
+ }
35
41
  }
36
42
 
37
43
  assert(crypto_generichash_init(&st, k, sizeof k, 0U) == -1);
@@ -1,26 +1,28 @@
1
1
  #! /bin/sh
2
2
 
3
- if [ -z "$NACL_SDK_ROOT" -o -z "$PNACL_TRANSLATE" -o -z "$PNACL_FINALIZE" ]
4
- then
5
- echo "One or more variables need to be set:
6
- \$NACL_SDK_ROOT=$NACL_SDK_ROOT
7
- \$PNACL_TRANSLATE=$PNACL_TRANSLATE
8
- \$PNACL_FINALIZE=$PNACL_FINALIZE"
9
- exit 1
3
+ if [ -z "$NACL_SDK_ROOT" ]; then
4
+ echo "The following variable needs to be set:
5
+ \$NACL_SDK_ROOT=$NACL_SDK_ROOT" >&2
6
+ exit 1
10
7
  fi
11
8
 
12
- if [ ! -f "$1.nexe" ]
13
- then
14
- $PNACL_FINALIZE "$1" -o "$1.final"
15
- $PNACL_TRANSLATE -arch $(uname -m) "$1.final" -o "$1.nexe"
9
+ if [ -z "$PNACL_FINALIZE" -o -z "$PNACL_TRANSLATE" ]; then
10
+ exe="$1"
11
+ else
12
+ exe="$1.nexe"
13
+ if [ ! -f "$exe" ]; then
14
+ $PNACL_FINALIZE "$1" -o "$1.final"
15
+ $PNACL_TRANSLATE -arch $(uname -m) "$1.final" -o "$exe"
16
+ fi
16
17
  fi
17
18
 
18
- command -v python >/dev/null 2>&1 || { echo >&2 "I require python but it's not installed. Aborting."; exit 1; }
19
+ which python >/dev/null 2>&1 || \
20
+ { echo >&2 "Python not found. Aborting."; exit 1; }
21
+
19
22
  SEL_LDR=$(find "$NACL_SDK_ROOT" -name sel_ldr.py | head -n 1)
20
- if [ -z "$SEL_LDR" ]
21
- then
22
- echo "Couldn't find a sel_ldr.py under $NACL_SDK_ROOT"
23
- exit 1
23
+ if [ -z "$SEL_LDR" ]; then
24
+ echo "Couldn't find sel_ldr.py under $NACL_SDK_ROOT" >&2
25
+ exit 1
24
26
  fi
25
27
 
26
- exec python "$SEL_LDR" "$1.nexe"
28
+ exec python "$SEL_LDR" "$exe"
@@ -32,9 +32,11 @@ static int randombytes_tests(void)
32
32
  uint32_t n;
33
33
 
34
34
  #ifdef __EMSCRIPTEN__
35
- assert(strcmp(randombytes_implementation_name(), "sysrandom"));
35
+ assert(strcmp(randombytes_implementation_name(), "js") == 0);
36
+ #elif defined(__native_client__)
37
+ assert(strcmp(randombytes_implementation_name(), "nativeclient") == 0);
36
38
  #else
37
- assert(strcmp(randombytes_implementation_name(), "js"));
39
+ assert(strcmp(randombytes_implementation_name(), "sysrandom") == 0);
38
40
  #endif
39
41
  randombytes(x, 1U);
40
42
  do {
@@ -4,12 +4,33 @@
4
4
  /* C++Builder defines a "random" macro */
5
5
  #undef random
6
6
 
7
+ #ifdef __native_client__
8
+ # define memset(dst, c, n) xmemset(dst, c, n)
9
+
10
+ static void *
11
+ xmemset(void *dst, int c, size_t n)
12
+ {
13
+ unsigned char *dst_ = (unsigned char *) dst;
14
+ const unsigned char c_ = (unsigned char) c;
15
+ size_t i;
16
+
17
+ for (i = 0; i < n; i++) {
18
+ dst_[i] = c_;
19
+ }
20
+ return dst;
21
+ }
22
+ #endif
23
+
7
24
  #ifdef __EMSCRIPTEN__
8
25
  # define strcmp(s1, s2) xstrcmp(s1, s2)
9
26
 
10
- int
27
+ static int
11
28
  strcmp(const char *s1, const char *s2) {
12
- while (*s1 == *s2++) { if (*s1++ == 0) return 0; }
29
+ while (*s1 == *s2++) {
30
+ if (*s1++ == 0) {
31
+ return 0;
32
+ }
33
+ }
13
34
  return *(unsigned char *) s1 - *(unsigned char *) --s2;
14
35
  }
15
36
  #endif
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbnacl-libsodium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artiom Di
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-16 00:00:00.000000000 Z
12
+ date: 2016-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rbnacl
@@ -79,7 +79,6 @@ files:
79
79
  - vendor/libsodium/LICENSE
80
80
  - vendor/libsodium/Makefile.am
81
81
  - vendor/libsodium/Makefile.in
82
- - vendor/libsodium/README
83
82
  - vendor/libsodium/README.markdown
84
83
  - vendor/libsodium/THANKS
85
84
  - vendor/libsodium/aclocal.m4
@@ -92,6 +91,7 @@ files:
92
91
  - vendor/libsodium/autom4te.cache/output.4
93
92
  - vendor/libsodium/autom4te.cache/output.5
94
93
  - vendor/libsodium/autom4te.cache/output.6
94
+ - vendor/libsodium/autom4te.cache/output.7
95
95
  - vendor/libsodium/autom4te.cache/requests
96
96
  - vendor/libsodium/autom4te.cache/traces.0
97
97
  - vendor/libsodium/autom4te.cache/traces.1
@@ -100,6 +100,7 @@ files:
100
100
  - vendor/libsodium/autom4te.cache/traces.4
101
101
  - vendor/libsodium/autom4te.cache/traces.5
102
102
  - vendor/libsodium/autom4te.cache/traces.6
103
+ - vendor/libsodium/autom4te.cache/traces.7
103
104
  - vendor/libsodium/build-aux/compile
104
105
  - vendor/libsodium/build-aux/config.guess
105
106
  - vendor/libsodium/build-aux/config.sub
@@ -178,25 +179,18 @@ files:
178
179
  - vendor/libsodium/dist-build/android-build.sh
179
180
  - vendor/libsodium/dist-build/android-mips32.sh
180
181
  - vendor/libsodium/dist-build/android-mips64.sh
181
- - vendor/libsodium/dist-build/android-x86-64.sh
182
182
  - vendor/libsodium/dist-build/android-x86.sh
183
+ - vendor/libsodium/dist-build/android-x86_64.sh
183
184
  - vendor/libsodium/dist-build/emscripten-symbols.def
184
185
  - vendor/libsodium/dist-build/emscripten.sh
185
186
  - vendor/libsodium/dist-build/generate-emscripten-symbols.sh
186
187
  - vendor/libsodium/dist-build/ios.sh
187
188
  - vendor/libsodium/dist-build/msys2-win32.sh
188
189
  - vendor/libsodium/dist-build/msys2-win64.sh
189
- - vendor/libsodium/dist-build/nativeclient.sh
190
+ - vendor/libsodium/dist-build/nativeclient-pnacl.sh
191
+ - vendor/libsodium/dist-build/nativeclient-x86.sh
192
+ - vendor/libsodium/dist-build/nativeclient-x86_64.sh
190
193
  - vendor/libsodium/dist-build/osx.sh
191
- - vendor/libsodium/examples/Makefile
192
- - vendor/libsodium/examples/auth.c
193
- - vendor/libsodium/examples/box.c
194
- - vendor/libsodium/examples/box_detached.c
195
- - vendor/libsodium/examples/generichash.c
196
- - vendor/libsodium/examples/generichash_stream.c
197
- - vendor/libsodium/examples/shorthash.c
198
- - vendor/libsodium/examples/sign.c
199
- - vendor/libsodium/examples/utils.h
200
194
  - vendor/libsodium/install-sh
201
195
  - vendor/libsodium/libsodium-uninstalled.pc.in
202
196
  - vendor/libsodium/libsodium.pc.in
@@ -209,6 +203,7 @@ files:
209
203
  - vendor/libsodium/m4/ax_check_define.m4
210
204
  - vendor/libsodium/m4/ax_check_gnu_make.m4
211
205
  - vendor/libsodium/m4/ax_check_link_flag.m4
206
+ - vendor/libsodium/m4/ax_pthread.m4
212
207
  - vendor/libsodium/m4/ax_valgrind_check.m4
213
208
  - vendor/libsodium/m4/ld-output-def.m4
214
209
  - vendor/libsodium/m4/libtool.m4
@@ -448,6 +443,7 @@ files:
448
443
  - vendor/libsodium/src/libsodium/include/sodium/export.h
449
444
  - vendor/libsodium/src/libsodium/include/sodium/private/common.h
450
445
  - vendor/libsodium/src/libsodium/include/sodium/private/curve25519_ref10.h
446
+ - vendor/libsodium/src/libsodium/include/sodium/private/mutex.h
451
447
  - vendor/libsodium/src/libsodium/include/sodium/randombytes.h
452
448
  - vendor/libsodium/src/libsodium/include/sodium/randombytes_nativeclient.h
453
449
  - vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h
@@ -613,7 +609,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
613
609
  version: '0'
614
610
  requirements: []
615
611
  rubyforge_project:
616
- rubygems_version: 2.5.1
612
+ rubygems_version: 2.4.8
617
613
  signing_key:
618
614
  specification_version: 4
619
615
  summary: rbnacl with bundled libsodium
@@ -1 +0,0 @@
1
- See README.markdown
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- export TARGET_ARCH=x86-64
3
- export CFLAGS="-Os -march=${TARGET_ARCH}"
4
- ARCH=x86_64 HOST_COMPILER=x86_64-linux-android "$(dirname "$0")/android-build.sh"
@@ -1,21 +0,0 @@
1
-
2
- TARGETS = \
3
- auth \
4
- box \
5
- box_detached \
6
- generichash \
7
- generichash_stream \
8
- shorthash \
9
- sign
10
-
11
- SODIUM_CFLAGS != pkg-config --cflags libsodium
12
- SODIUM_LIBS != pkg-config --libs libsodium
13
- CFLAGS += $(SODIUM_CFLAGS)
14
- LDFLAGS += $(SODIUM_LIBS)
15
-
16
- all: $(TARGETS)
17
-
18
- clean:
19
- rm -f $(TARGETS)
20
-
21
- distclean: clean
@@ -1,68 +0,0 @@
1
- /*
2
- * GraxRabble
3
- * example programs for libsodium.
4
- */
5
-
6
- #include <sodium.h> /* library header */
7
-
8
- #include "utils.h" /* utility functions shared by examples */
9
-
10
- /*
11
- * This operation computes an authentication tag for a message and a
12
- * secret key, and provides a way to verify that a given tag is valid
13
- * for a given message and a key.
14
- *
15
- * The function computing the tag deterministic: the same (message,
16
- * key) tuple will always produce the same output.
17
- *
18
- * However, even if the message is public, knowing the key is
19
- * required in order to be able to compute a valid tag. Therefore,
20
- * the key should remain confidential. The tag, however, can be
21
- * public.
22
- *
23
- * A typical use case is:
24
- *
25
- * - A prepares a message, add an authentication tag, sends it to B
26
- * - A doesn't store the message
27
- * - Later on, B sends the message and the authentication tag to A
28
- * - A uses the authentication tag to verify that it created this message.
29
- *
30
- * This operation does not encrypt the message. It only computes and
31
- * verifies an authentication tag.
32
- */
33
- static int
34
- auth(void)
35
- {
36
- unsigned char key[crypto_auth_KEYBYTES];
37
- unsigned char mac[crypto_auth_BYTES];
38
- unsigned char message[MAX_INPUT_LEN];
39
- size_t message_len;
40
- int ret;
41
-
42
- puts("Example: crypto_auth\n");
43
-
44
- prompt_input("a key", (char*)key, sizeof key, 0);
45
- message_len = prompt_input("a message", (char*)message, sizeof message, 1);
46
-
47
- printf("Generating %s authentication...\n", crypto_auth_primitive());
48
- crypto_auth(mac, message, message_len, key);
49
-
50
- printf("Authentication tag: ");
51
- print_hex(mac, sizeof mac);
52
-
53
- puts("Verifying authentication tag...");
54
- ret = crypto_auth_verify(mac, message, message_len, key);
55
- print_verification(ret);
56
-
57
- sodium_memzero(key, sizeof key); /* wipe sensitive data */
58
-
59
- return ret;
60
- }
61
-
62
- int
63
- main(void)
64
- {
65
- init();
66
-
67
- return auth() != 0;
68
- }
@@ -1,135 +0,0 @@
1
- /*
2
- * GraxRabble
3
- * example programs for libsodium.
4
- */
5
-
6
- #include <sodium.h> /* library header */
7
-
8
- #include "utils.h" /* utility functions shared by examples */
9
-
10
- /*
11
- * Using public-key authenticated encryption, Bob can encrypt a
12
- * confidential message specifically for Alice, using Alice's public
13
- * key.
14
- *
15
- * Using Bob's public key, Alice can verify that the encrypted
16
- * message was actually created by Bob and was not tampered with,
17
- * before eventually decrypting it.
18
- *
19
- * Alice only needs Bob's public key, the nonce and the ciphertext.
20
- * Bob should never ever share his secret key, even with Alice.
21
- *
22
- * And in order to send messages to Alice, Bob only needs Alice's
23
- * public key. Alice should never ever share her secret key either,
24
- * even with Bob.
25
- *
26
- * Alice can reply to Bob using the same system, without having to
27
- * generate a distinct key pair.
28
- *
29
- * The nonce doesn't have to be confidential, but it should be used
30
- * with just one invokation of crypto_box_open_easy() for a
31
- * particular pair of public and secret keys.
32
- *
33
- * One easy way to generate a nonce is to use randombytes_buf(),
34
- * considering the size of nonces the risk of any random collisions
35
- * is negligible. For some applications, if you wish to use nonces to
36
- * detect missing messages or to ignore replayed messages, it is also
37
- * ok to use a simple incrementing counter as a nonce.
38
- *
39
- * When doing so you must ensure that the same value can never be
40
- * re-used (for example you may have multiple threads or even hosts
41
- * generating messages using the same key pairs).
42
- *
43
- * This system provides mutual authentication. However, a typical use
44
- * case is to secure communications between a server, whose public
45
- * key is known in advance, and clients connecting anonymously.
46
- */
47
- static int
48
- box(void)
49
- {
50
- unsigned char bob_pk[crypto_box_PUBLICKEYBYTES]; /* Bob's public key */
51
- unsigned char bob_sk[crypto_box_SECRETKEYBYTES]; /* Bob's secret key */
52
-
53
- unsigned char alice_pk[crypto_box_PUBLICKEYBYTES]; /* Alice's public key */
54
- unsigned char alice_sk[crypto_box_SECRETKEYBYTES]; /* Alice's secret key */
55
-
56
- unsigned char nonce[crypto_box_NONCEBYTES];
57
- unsigned char message[MAX_INPUT_LEN];
58
- unsigned char ciphertext[crypto_box_MACBYTES + MAX_INPUT_LEN];
59
- size_t message_len;
60
- size_t ciphertext_len;
61
- int ret;
62
-
63
- puts("Example: crypto_box_easy\n");
64
-
65
- puts("Generating keypairs...\n");
66
- crypto_box_keypair(bob_pk, bob_sk); /* generate Bob's keys */
67
- crypto_box_keypair(alice_pk, alice_sk); /* generate Alice's keys */
68
-
69
- puts("Bob");
70
- printf("Public key: ");
71
- print_hex(bob_pk, sizeof bob_pk);
72
- printf("Secret key: ");
73
- print_hex(bob_sk, sizeof bob_sk);
74
-
75
- puts("Alice");
76
- printf("Public key: ");
77
- print_hex(alice_pk, sizeof alice_pk);
78
- printf("Secret key: ");
79
- print_hex(alice_sk, sizeof alice_sk);
80
-
81
- /* nonce must be unique per (key, message) - it can be public and deterministic */
82
- puts("Generating nonce...");
83
- randombytes_buf(nonce, sizeof nonce);
84
- printf("Nonce: ");
85
- print_hex(nonce, sizeof nonce);
86
-
87
- /* read input */
88
- message_len = prompt_input("a message", (char*)message, sizeof message, 1);
89
-
90
- print_hex(message, message_len);
91
-
92
- /* encrypt and authenticate the message */
93
- printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive());
94
- if (crypto_box_easy(ciphertext, message, message_len, nonce, alice_pk, bob_sk) != 0) {
95
- abort();
96
- }
97
- ciphertext_len = crypto_box_MACBYTES + message_len;
98
-
99
- /* send the nonce and the ciphertext */
100
- puts("Bob sends the nonce and the ciphertext...\n");
101
- printf("Ciphertext len: %zu bytes - Original message length: %zu bytes\n",
102
- ciphertext_len, message_len);
103
- puts("Notice the prepended 16 byte authentication token\n");
104
- printf("Nonce: ");
105
- print_hex(nonce, sizeof nonce);
106
- printf("Ciphertext: ");
107
- print_hex(ciphertext, ciphertext_len);
108
-
109
- /* decrypt the message */
110
- puts("Alice verifies and decrypts the ciphertext...");
111
- ret = crypto_box_open_easy(message, ciphertext, ciphertext_len, nonce, bob_pk,
112
- alice_sk);
113
- print_hex(message, message_len);
114
-
115
- print_verification(ret);
116
- if (ret == 0) {
117
- printf("Plaintext: ");
118
- fwrite(message, 1U, message_len, stdout);
119
- putchar('\n');
120
- }
121
- sodium_memzero(bob_sk, sizeof bob_sk); /* wipe sensitive data */
122
- sodium_memzero(alice_sk, sizeof alice_sk);
123
- sodium_memzero(message, sizeof message);
124
- sodium_memzero(ciphertext, sizeof ciphertext);
125
-
126
- return ret;
127
- }
128
-
129
- int
130
- main(void)
131
- {
132
- init();
133
-
134
- return box() != 0;
135
- }