rbnacl-libsodium 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) 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 +0 -3
  5. data/vendor/libsodium/ChangeLog +24 -0
  6. data/vendor/libsodium/THANKS +2 -0
  7. data/vendor/libsodium/autom4te.cache/output.1 +35 -147
  8. data/vendor/libsodium/autom4te.cache/output.3 +35 -147
  9. data/vendor/libsodium/autom4te.cache/requests +127 -127
  10. data/vendor/libsodium/autom4te.cache/traces.1 +244 -254
  11. data/vendor/libsodium/autom4te.cache/traces.3 +111 -113
  12. data/vendor/libsodium/builds/msvc/properties/Common.props +3 -1
  13. data/vendor/libsodium/builds/msvc/properties/Release.props +1 -3
  14. data/vendor/libsodium/builds/msvc/version.h +3 -3
  15. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +1 -11
  16. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +1 -37
  17. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +10 -1
  18. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +10 -1
  19. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +1 -11
  20. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +1 -37
  21. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +10 -1
  22. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +10 -1
  23. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +1 -11
  24. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +1 -37
  25. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +10 -1
  26. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +10 -1
  27. data/vendor/libsodium/configure +33 -145
  28. data/vendor/libsodium/configure.ac +22 -23
  29. data/vendor/libsodium/dist-build/android-build.sh +1 -0
  30. data/vendor/libsodium/dist-build/emscripten.sh +2 -2
  31. data/vendor/libsodium/dist-build/ios.sh +1 -0
  32. data/vendor/libsodium/libsodium.pc.in +1 -1
  33. data/vendor/libsodium/libsodium.vcxproj +1 -5
  34. data/vendor/libsodium/libsodium.vcxproj.filters +1 -13
  35. data/vendor/libsodium/msvc-scripts/process.bat +3 -3
  36. data/vendor/libsodium/msvc-scripts/sodium.props +4 -1
  37. data/vendor/libsodium/src/libsodium/Makefile.am +1 -10
  38. data/vendor/libsodium/src/libsodium/Makefile.in +5 -79
  39. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +3 -1
  40. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +3 -1
  41. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +3 -1
  42. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +6 -0
  43. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/pow225521.h +2 -2
  44. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +46 -3
  45. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +2 -10
  46. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +7 -1
  47. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +18 -0
  48. data/vendor/libsodium/src/libsodium/include/Makefile.am +0 -1
  49. data/vendor/libsodium/src/libsodium/include/Makefile.in +0 -1
  50. data/vendor/libsodium/src/libsodium/include/sodium.h +0 -1
  51. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +1 -2
  52. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +5 -0
  53. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +15 -0
  54. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +54 -3
  55. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +22 -7
  56. data/vendor/libsodium/src/libsodium/sodium/core.c +2 -0
  57. data/vendor/libsodium/src/libsodium/sodium/utils.c +305 -31
  58. data/vendor/libsodium/test/default/Makefile.am +18 -16
  59. data/vendor/libsodium/test/default/Makefile.in +141 -76
  60. data/vendor/libsodium/test/default/ed25519_convert.c +48 -0
  61. data/vendor/libsodium/test/default/ed25519_convert.exp +3 -0
  62. data/vendor/libsodium/test/default/sign.c +15 -4
  63. data/vendor/libsodium/test/default/sodium_utils2.c +70 -0
  64. data/vendor/libsodium/test/default/sodium_utils2.exp +3 -0
  65. data/vendor/libsodium/test/default/sodium_utils3.c +55 -0
  66. data/vendor/libsodium/test/default/sodium_utils3.exp +2 -0
  67. metadata +8 -24
  68. data/vendor/libsodium/src/libsodium/crypto_auth/try.c +0 -119
  69. data/vendor/libsodium/src/libsodium/crypto_box/try.c +0 -195
  70. data/vendor/libsodium/src/libsodium/crypto_hash/try.c +0 -76
  71. data/vendor/libsodium/src/libsodium/crypto_scalarmult/try.c +0 -125
  72. data/vendor/libsodium/src/libsodium/crypto_secretbox/try.c +0 -129
  73. data/vendor/libsodium/src/libsodium/crypto_sign/try.c +0 -87
  74. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-be.h +0 -273
  75. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-le.h +0 -274
  76. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table.h +0 -62
  77. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +0 -239
  78. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256.h +0 -171
  79. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/api.h +0 -13
  80. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/ecrypt-sync.h +0 -27
  81. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/stream_aes256estream_api.c +0 -16
  82. data/vendor/libsodium/src/libsodium/crypto_stream/try.c +0 -122
  83. data/vendor/libsodium/src/libsodium/crypto_verify/try.c +0 -76
  84. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +0 -67
  85. data/vendor/libsodium/src/libsodium/sodium/compat.c +0 -361
  86. data/vendor/libsodium/test/default/stream5.c +0 -29
  87. data/vendor/libsodium/test/default/stream5.exp +0 -1
  88. data/vendor/libsodium/test/default/stream6.c +0 -54
  89. data/vendor/libsodium/test/default/stream6.exp +0 -17
@@ -0,0 +1,70 @@
1
+
2
+ #include <sys/types.h>
3
+
4
+ #include <limits.h>
5
+ #include <signal.h>
6
+ #include <string.h>
7
+ #include <stdio.h>
8
+ #include <string.h>
9
+
10
+ #define TEST_NAME "sodium_utils2"
11
+ #include "cmptest.h"
12
+
13
+ static void
14
+ segv_handler(int sig)
15
+ {
16
+ printf("Intentional segfault / bus error caught\n");
17
+ printf("OK\n");
18
+ #ifdef SIGSEGV
19
+ signal(SIGSEGV, SIG_DFL);
20
+ #endif
21
+ #ifdef SIGBUS
22
+ signal(SIGBUS, SIG_DFL);
23
+ #endif
24
+ #ifdef SIGABRT
25
+ signal(SIGABRT, SIG_DFL);
26
+ #endif
27
+ exit(0);
28
+ }
29
+
30
+ int
31
+ main(void)
32
+ {
33
+ void *buf;
34
+ size_t size;
35
+ unsigned int i;
36
+
37
+ if (sodium_allocarray(SIZE_MAX / 2U + 1U, SIZE_MAX / 2U) != NULL) {
38
+ return 1;
39
+ }
40
+ sodium_free(sodium_malloc(0U));
41
+ sodium_free(NULL);
42
+ for (i = 0U; i < 10000U; i++) {
43
+ size = randombytes_uniform(100000U);
44
+ buf = sodium_malloc(size);
45
+ memset(buf, i, size);
46
+ sodium_mprotect_readonly(buf);
47
+ sodium_free(buf);
48
+ }
49
+ printf("OK\n");
50
+
51
+ #ifdef SIGSEGV
52
+ signal(SIGSEGV, segv_handler);
53
+ #endif
54
+ #ifdef SIGBUS
55
+ signal(SIGBUS, segv_handler);
56
+ #endif
57
+ #ifdef SIGABRT
58
+ signal(SIGABRT, segv_handler);
59
+ #endif
60
+ size = randombytes_uniform(100000U);
61
+ buf = sodium_malloc(size);
62
+ sodium_mprotect_readonly(buf);
63
+ sodium_mprotect_readwrite(buf);
64
+ sodium_memzero(((unsigned char *) buf) + size, 1U);
65
+ sodium_mprotect_noaccess(buf);
66
+ sodium_free(buf);
67
+ printf("Overflow not caught\n");
68
+
69
+ return 0;
70
+ }
@@ -0,0 +1,3 @@
1
+ OK
2
+ Intentional segfault / bus error caught
3
+ OK
@@ -0,0 +1,55 @@
1
+
2
+ #include <sys/types.h>
3
+
4
+ #include <limits.h>
5
+ #include <signal.h>
6
+ #include <string.h>
7
+ #include <stdio.h>
8
+ #include <string.h>
9
+
10
+ #define TEST_NAME "sodium_utils3"
11
+ #include "cmptest.h"
12
+
13
+ static void
14
+ segv_handler(int sig)
15
+ {
16
+ printf("Intentional segfault / bus error caught\n");
17
+ printf("OK\n");
18
+ #ifdef SIGSEGV
19
+ signal(SIGSEGV, SIG_DFL);
20
+ #endif
21
+ #ifdef SIGBUS
22
+ signal(SIGBUS, SIG_DFL);
23
+ #endif
24
+ #ifdef SIGABRT
25
+ signal(SIGABRT, SIG_DFL);
26
+ #endif
27
+ exit(0);
28
+ }
29
+
30
+ int
31
+ main(void)
32
+ {
33
+ void *buf;
34
+ size_t size;
35
+
36
+ #ifdef SIGSEGV
37
+ signal(SIGSEGV, segv_handler);
38
+ #endif
39
+ #ifdef SIGBUS
40
+ signal(SIGBUS, segv_handler);
41
+ #endif
42
+ #ifdef SIGABRT
43
+ signal(SIGABRT, segv_handler);
44
+ #endif
45
+ size = randombytes_uniform(100000U);
46
+ buf = sodium_malloc(size);
47
+ sodium_mprotect_noaccess(buf);
48
+ sodium_mprotect_readwrite(buf);
49
+ sodium_memzero(((unsigned char *) buf) - 8, 8U);
50
+ sodium_mprotect_readonly(buf);
51
+ sodium_free(buf);
52
+ printf("Underflow not caught\n");
53
+
54
+ return 0;
55
+ }
@@ -0,0 +1,2 @@
1
+ Intentional segfault / bus error caught
2
+ OK
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbnacl-libsodium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artiom Di
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-19 00:00:00.000000000 Z
11
+ date: 2014-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbnacl
@@ -224,7 +224,6 @@ files:
224
224
  - vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/api.h
225
225
  - vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c
226
226
  - vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c
227
- - vendor/libsodium/src/libsodium/crypto_auth/try.c
228
227
  - vendor/libsodium/src/libsodium/crypto_box/crypto_box.c
229
228
  - vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c
230
229
  - vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c
@@ -234,7 +233,6 @@ files:
234
233
  - vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c
235
234
  - vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c
236
235
  - vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c
237
- - vendor/libsodium/src/libsodium/crypto_box/try.c
238
236
  - vendor/libsodium/src/libsodium/crypto_core/hsalsa20/checksum
239
237
  - vendor/libsodium/src/libsodium/crypto_core/hsalsa20/core_hsalsa20_api.c
240
238
  - vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h
@@ -268,7 +266,6 @@ files:
268
266
  - vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/api.h
269
267
  - vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c
270
268
  - vendor/libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c
271
- - vendor/libsodium/src/libsodium/crypto_hash/try.c
272
269
  - vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c
273
270
  - vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c
274
271
  - vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h
@@ -311,10 +308,8 @@ files:
311
308
  - vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/pow225521.h
312
309
  - vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c
313
310
  - vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519_api.c
314
- - vendor/libsodium/src/libsodium/crypto_scalarmult/try.c
315
311
  - vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c
316
312
  - vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c
317
- - vendor/libsodium/src/libsodium/crypto_secretbox/try.c
318
313
  - vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/checksum
319
314
  - vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h
320
315
  - vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c
@@ -390,7 +385,6 @@ files:
390
385
  - vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c
391
386
  - vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c
392
387
  - vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c
393
- - vendor/libsodium/src/libsodium/crypto_sign/try.c
394
388
  - vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/checksum
395
389
  - vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c
396
390
  - vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h
@@ -405,14 +399,6 @@ files:
405
399
  - vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h
406
400
  - vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c
407
401
  - vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr_api.c
408
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-be.h
409
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-le.h
410
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table.h
411
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c
412
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256.h
413
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/api.h
414
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/ecrypt-sync.h
415
- - vendor/libsodium/src/libsodium/crypto_stream/aes256estream/stream_aes256estream_api.c
416
402
  - vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/api.h
417
403
  - vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c
418
404
  - vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20_api.c
@@ -434,7 +420,6 @@ files:
434
420
  - vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c
435
421
  - vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c
436
422
  - vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c
437
- - vendor/libsodium/src/libsodium/crypto_stream/try.c
438
423
  - vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/checksum
439
424
  - vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h
440
425
  - vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c
@@ -451,7 +436,6 @@ files:
451
436
  - vendor/libsodium/src/libsodium/crypto_verify/64/ref/api.h
452
437
  - vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c
453
438
  - vendor/libsodium/src/libsodium/crypto_verify/64/verify_64_api.c
454
- - vendor/libsodium/src/libsodium/crypto_verify/try.c
455
439
  - vendor/libsodium/src/libsodium/include/Makefile.am
456
440
  - vendor/libsodium/src/libsodium/include/Makefile.in
457
441
  - vendor/libsodium/src/libsodium/include/sodium.h
@@ -488,7 +472,6 @@ files:
488
472
  - vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h
489
473
  - vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h
490
474
  - vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h
491
- - vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h
492
475
  - vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h
493
476
  - vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h
494
477
  - vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h
@@ -511,7 +494,6 @@ files:
511
494
  - vendor/libsodium/src/libsodium/randombytes/randombytes.c
512
495
  - vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c
513
496
  - vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c
514
- - vendor/libsodium/src/libsodium/sodium/compat.c
515
497
  - vendor/libsodium/src/libsodium/sodium/core.c
516
498
  - vendor/libsodium/src/libsodium/sodium/runtime.c
517
499
  - vendor/libsodium/src/libsodium/sodium/utils.c
@@ -564,6 +546,8 @@ files:
564
546
  - vendor/libsodium/test/default/core5.exp
565
547
  - vendor/libsodium/test/default/core6.c
566
548
  - vendor/libsodium/test/default/core6.exp
549
+ - vendor/libsodium/test/default/ed25519_convert.c
550
+ - vendor/libsodium/test/default/ed25519_convert.exp
567
551
  - vendor/libsodium/test/default/generichash.c
568
552
  - vendor/libsodium/test/default/generichash.exp
569
553
  - vendor/libsodium/test/default/generichash2.c
@@ -615,6 +599,10 @@ files:
615
599
  - vendor/libsodium/test/default/sodium_core.exp
616
600
  - vendor/libsodium/test/default/sodium_utils.c
617
601
  - vendor/libsodium/test/default/sodium_utils.exp
602
+ - vendor/libsodium/test/default/sodium_utils2.c
603
+ - vendor/libsodium/test/default/sodium_utils2.exp
604
+ - vendor/libsodium/test/default/sodium_utils3.c
605
+ - vendor/libsodium/test/default/sodium_utils3.exp
618
606
  - vendor/libsodium/test/default/sodium_version.c
619
607
  - vendor/libsodium/test/default/sodium_version.exp
620
608
  - vendor/libsodium/test/default/stream.c
@@ -625,10 +613,6 @@ files:
625
613
  - vendor/libsodium/test/default/stream3.exp
626
614
  - vendor/libsodium/test/default/stream4.c
627
615
  - vendor/libsodium/test/default/stream4.exp
628
- - vendor/libsodium/test/default/stream5.c
629
- - vendor/libsodium/test/default/stream5.exp
630
- - vendor/libsodium/test/default/stream6.c
631
- - vendor/libsodium/test/default/stream6.exp
632
616
  - vendor/libsodium/test/default/verify1.c
633
617
  - vendor/libsodium/test/default/verify1.exp
634
618
  - vendor/libsodium/test/default/wintest.bat
@@ -1,119 +0,0 @@
1
- /*
2
- * crypto_auth/try.c version 20090118
3
- * D. J. Bernstein
4
- * Public domain.
5
- */
6
-
7
- #include <stdlib.h>
8
- #include "crypto_hash_sha256.h"
9
- #include "crypto_auth.h"
10
- #include "utils.h"
11
- #include "windows/windows-quirks.h"
12
-
13
- extern unsigned char *alignedcalloc(unsigned long long);
14
-
15
- const char *primitiveimplementation = crypto_auth_IMPLEMENTATION;
16
-
17
- #define MAXTEST_BYTES 10000
18
- #define CHECKSUM_BYTES 4096
19
- #define TUNE_BYTES 1536
20
-
21
- static unsigned char *h;
22
- static unsigned char *m;
23
- static unsigned char *k;
24
- static unsigned char *h2;
25
- static unsigned char *m2;
26
- static unsigned char *k2;
27
-
28
- void preallocate(void)
29
- {
30
- }
31
-
32
- void allocate(void)
33
- {
34
- h = alignedcalloc(crypto_auth_BYTES);
35
- m = alignedcalloc(MAXTEST_BYTES);
36
- k = alignedcalloc(crypto_auth_KEYBYTES);
37
- h2 = alignedcalloc(crypto_auth_BYTES);
38
- m2 = alignedcalloc(MAXTEST_BYTES + crypto_auth_BYTES);
39
- k2 = alignedcalloc(crypto_auth_KEYBYTES + crypto_auth_BYTES);
40
- }
41
-
42
- void predoit(void)
43
- {
44
- }
45
-
46
- void doit(void)
47
- {
48
- crypto_auth(h,m,TUNE_BYTES,k);
49
- crypto_auth_verify(h,m,TUNE_BYTES,k);
50
- }
51
-
52
- char checksum[crypto_auth_BYTES * 2 + 1];
53
-
54
- const char *checksum_compute(void)
55
- {
56
- long long i;
57
- long long j;
58
-
59
- for (i = 0;i < CHECKSUM_BYTES;++i) {
60
- long long mlen = i;
61
- long long klen = crypto_auth_KEYBYTES;
62
- long long hlen = crypto_auth_BYTES;
63
-
64
- for (j = -16;j < 0;++j) h[j] = rand();
65
- for (j = -16;j < 0;++j) k[j] = rand();
66
- for (j = -16;j < 0;++j) m[j] = rand();
67
- for (j = hlen;j < hlen + 16;++j) h[j] = rand();
68
- for (j = klen;j < klen + 16;++j) k[j] = rand();
69
- for (j = mlen;j < mlen + 16;++j) m[j] = rand();
70
- for (j = -16;j < hlen + 16;++j) h2[j] = h[j];
71
- for (j = -16;j < klen + 16;++j) k2[j] = k[j];
72
- for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
73
-
74
- if (crypto_auth(h,m,mlen,k) != 0) return "crypto_auth returns nonzero";
75
-
76
- for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_auth overwrites k";
77
- for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_auth overwrites m";
78
- for (j = -16;j < 0;++j) if (h[j] != h2[j]) return "crypto_auth writes before output";
79
- for (j = hlen;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_auth writes after output";
80
-
81
- for (j = -16;j < 0;++j) h[j] = rand();
82
- for (j = -16;j < 0;++j) k[j] = rand();
83
- for (j = -16;j < 0;++j) m[j] = rand();
84
- for (j = hlen;j < hlen + 16;++j) h[j] = rand();
85
- for (j = klen;j < klen + 16;++j) k[j] = rand();
86
- for (j = mlen;j < mlen + 16;++j) m[j] = rand();
87
- for (j = -16;j < hlen + 16;++j) h2[j] = h[j];
88
- for (j = -16;j < klen + 16;++j) k2[j] = k[j];
89
- for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
90
-
91
- if (crypto_auth(m2,m2,mlen,k) != 0) return "crypto_auth returns nonzero";
92
- for (j = 0;j < hlen;++j) if (m2[j] != h[j]) return "crypto_auth does not handle m overlap";
93
- for (j = 0;j < hlen;++j) m2[j] = m[j];
94
- if (crypto_auth(k2,m2,mlen,k2) != 0) return "crypto_auth returns nonzero";
95
- for (j = 0;j < hlen;++j) if (k2[j] != h[j]) return "crypto_auth does not handle k overlap";
96
- for (j = 0;j < hlen;++j) k2[j] = k[j];
97
-
98
- if (crypto_auth_verify(h,m,mlen,k) != 0) return "crypto_auth_verify returns nonzero";
99
-
100
- for (j = -16;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_auth overwrites h";
101
- for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_auth overwrites k";
102
- for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_auth overwrites m";
103
-
104
- crypto_hash_sha256(h2,h,hlen);
105
- for (j = 0;j < klen;++j) k[j] ^= h2[j % 32];
106
- if (crypto_auth(h,m,mlen,k) != 0) return "crypto_auth returns nonzero";
107
- if (crypto_auth_verify(h,m,mlen,k) != 0) return "crypto_auth_verify returns nonzero";
108
-
109
- crypto_hash_sha256(h2,h,hlen);
110
- for (j = 0;j < mlen;++j) m[j] ^= h2[j % 32];
111
- m[mlen] = h2[0];
112
- }
113
- if (crypto_auth(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_auth returns nonzero";
114
- if (crypto_auth_verify(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_auth_verify returns nonzero";
115
-
116
- sodium_bin2hex(checksum, sizeof checksum, h, crypto_auth_BYTES);
117
-
118
- return 0;
119
- }
@@ -1,195 +0,0 @@
1
- /*
2
- * crypto_box/try.c version 20090118
3
- * D. J. Bernstein
4
- * Public domain.
5
- */
6
-
7
- #include <stdlib.h>
8
- #include "crypto_box.h"
9
- #include "utils.h"
10
- #include "windows/windows-quirks.h"
11
-
12
- extern unsigned char *alignedcalloc(unsigned long long);
13
-
14
- const char *primitiveimplementation = crypto_box_IMPLEMENTATION;
15
-
16
- #define MAXTEST_BYTES 10000
17
- #define CHECKSUM_BYTES 4096
18
- #define TUNE_BYTES 1536
19
-
20
- static unsigned char *ska;
21
- static unsigned char *pka;
22
- static unsigned char *skb;
23
- static unsigned char *pkb;
24
- static unsigned char *s;
25
- static unsigned char *n;
26
- static unsigned char *m;
27
- static unsigned char *c;
28
- static unsigned char *t;
29
- static unsigned char *ska2;
30
- static unsigned char *pka2;
31
- static unsigned char *skb2;
32
- static unsigned char *pkb2;
33
- static unsigned char *s2;
34
- static unsigned char *n2;
35
- static unsigned char *m2;
36
- static unsigned char *c2;
37
- static unsigned char *t2;
38
-
39
- #define sklen crypto_box_SECRETKEYBYTES
40
- #define pklen crypto_box_PUBLICKEYBYTES
41
- #define nlen crypto_box_NONCEBYTES
42
- #define slen crypto_box_BEFORENMBYTES
43
-
44
- void preallocate(void)
45
- {
46
- }
47
-
48
- void allocate(void)
49
- {
50
- ska = alignedcalloc(sklen);
51
- pka = alignedcalloc(pklen);
52
- skb = alignedcalloc(sklen);
53
- pkb = alignedcalloc(pklen);
54
- n = alignedcalloc(nlen);
55
- m = alignedcalloc(MAXTEST_BYTES + crypto_box_ZEROBYTES);
56
- c = alignedcalloc(MAXTEST_BYTES + crypto_box_ZEROBYTES);
57
- t = alignedcalloc(MAXTEST_BYTES + crypto_box_ZEROBYTES);
58
- s = alignedcalloc(slen);
59
- ska2 = alignedcalloc(sklen);
60
- pka2 = alignedcalloc(pklen);
61
- skb2 = alignedcalloc(sklen);
62
- pkb2 = alignedcalloc(pklen);
63
- n2 = alignedcalloc(nlen);
64
- m2 = alignedcalloc(MAXTEST_BYTES + crypto_box_ZEROBYTES);
65
- c2 = alignedcalloc(MAXTEST_BYTES + crypto_box_ZEROBYTES);
66
- t2 = alignedcalloc(MAXTEST_BYTES + crypto_box_ZEROBYTES);
67
- s2 = alignedcalloc(slen);
68
- }
69
-
70
- void predoit(void)
71
- {
72
- }
73
-
74
- void doit(void)
75
- {
76
- crypto_box(c,m,TUNE_BYTES + crypto_box_ZEROBYTES,n,pka,skb);
77
- crypto_box_open(t,c,TUNE_BYTES + crypto_box_ZEROBYTES,n,pkb,ska);
78
- }
79
-
80
- char checksum[nlen * 2 + 1];
81
-
82
- const char *checksum_compute(void)
83
- {
84
- long long i;
85
- long long j;
86
-
87
- if (crypto_box_keypair(pka,ska) != 0) return "crypto_box_keypair returns nonzero";
88
- if (crypto_box_keypair(pkb,skb) != 0) return "crypto_box_keypair returns nonzero";
89
-
90
- for (j = 0;j < crypto_box_ZEROBYTES;++j) m[j] = 0;
91
-
92
- for (i = 0;i < CHECKSUM_BYTES;++i) {
93
- long long mlen = i + crypto_box_ZEROBYTES;
94
- long long tlen = i + crypto_box_ZEROBYTES;
95
- long long clen = i + crypto_box_ZEROBYTES;
96
-
97
- for (j = -16;j < 0;++j) ska[j] = rand();
98
- for (j = -16;j < 0;++j) skb[j] = rand();
99
- for (j = -16;j < 0;++j) pka[j] = rand();
100
- for (j = -16;j < 0;++j) pkb[j] = rand();
101
- for (j = -16;j < 0;++j) m[j] = rand();
102
- for (j = -16;j < 0;++j) n[j] = rand();
103
-
104
- for (j = sklen;j < sklen + 16;++j) ska[j] = rand();
105
- for (j = sklen;j < sklen + 16;++j) skb[j] = rand();
106
- for (j = pklen;j < pklen + 16;++j) pka[j] = rand();
107
- for (j = pklen;j < pklen + 16;++j) pkb[j] = rand();
108
- for (j = mlen;j < mlen + 16;++j) m[j] = rand();
109
- for (j = nlen;j < nlen + 16;++j) n[j] = rand();
110
-
111
- for (j = -16;j < sklen + 16;++j) ska2[j] = ska[j];
112
- for (j = -16;j < sklen + 16;++j) skb2[j] = skb[j];
113
- for (j = -16;j < pklen + 16;++j) pka2[j] = pka[j];
114
- for (j = -16;j < pklen + 16;++j) pkb2[j] = pkb[j];
115
- for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
116
- for (j = -16;j < nlen + 16;++j) n2[j] = n[j];
117
- for (j = -16;j < clen + 16;++j) c2[j] = c[j] = rand();
118
-
119
- if (crypto_box(c,m,mlen,n,pkb,ska) != 0) return "crypto_box returns nonzero";
120
-
121
- for (j = -16;j < mlen + 16;++j) if (m2[j] != m[j]) return "crypto_box overwrites m";
122
- for (j = -16;j < nlen + 16;++j) if (n2[j] != n[j]) return "crypto_box overwrites n";
123
- for (j = -16;j < 0;++j) if (c2[j] != c[j]) return "crypto_box writes before output";
124
- for (j = clen;j < clen + 16;++j) if (c2[j] != c[j]) return "crypto_box writes after output";
125
- for (j = 0;j < crypto_box_BOXZEROBYTES;++j)
126
- if (c[j] != 0) return "crypto_box does not clear extra bytes";
127
-
128
- for (j = -16;j < sklen + 16;++j) if (ska2[j] != ska[j]) return "crypto_box overwrites ska";
129
- for (j = -16;j < sklen + 16;++j) if (skb2[j] != skb[j]) return "crypto_box overwrites skb";
130
- for (j = -16;j < pklen + 16;++j) if (pka2[j] != pka[j]) return "crypto_box overwrites pka";
131
- for (j = -16;j < pklen + 16;++j) if (pkb2[j] != pkb[j]) return "crypto_box overwrites pkb";
132
-
133
- for (j = -16;j < 0;++j) c[j] = rand();
134
- for (j = clen;j < clen + 16;++j) c[j] = rand();
135
- for (j = -16;j < clen + 16;++j) c2[j] = c[j];
136
- for (j = -16;j < tlen + 16;++j) t2[j] = t[j] = rand();
137
-
138
- if (crypto_box_open(t,c,clen,n,pka,skb) != 0) return "crypto_box_open returns nonzero";
139
-
140
- for (j = -16;j < clen + 16;++j) if (c2[j] != c[j]) return "crypto_box_open overwrites c";
141
- for (j = -16;j < nlen + 16;++j) if (n2[j] != n[j]) return "crypto_box_open overwrites n";
142
- for (j = -16;j < 0;++j) if (t2[j] != t[j]) return "crypto_box_open writes before output";
143
- for (j = tlen;j < tlen + 16;++j) if (t2[j] != t[j]) return "crypto_box_open writes after output";
144
- for (j = 0;j < crypto_box_ZEROBYTES;++j)
145
- if (t[j] != 0) return "crypto_box_open does not clear extra bytes";
146
-
147
- for (j = -16;j < sklen + 16;++j) if (ska2[j] != ska[j]) return "crypto_box_open overwrites ska";
148
- for (j = -16;j < sklen + 16;++j) if (skb2[j] != skb[j]) return "crypto_box_open overwrites skb";
149
- for (j = -16;j < pklen + 16;++j) if (pka2[j] != pka[j]) return "crypto_box_open overwrites pka";
150
- for (j = -16;j < pklen + 16;++j) if (pkb2[j] != pkb[j]) return "crypto_box_open overwrites pkb";
151
-
152
- for (j = 0;j < mlen;++j) if (t[j] != m[j]) return "plaintext does not match";
153
-
154
- for (j = -16;j < slen + 16;++j) s2[j] = s[j] = rand();
155
- if (crypto_box_beforenm(s,pkb,ska) != 0) return "crypto_box_beforenm returns nonzero";
156
- for (j = -16;j < pklen + 16;++j) if (pka2[j] != pka[j]) return "crypto_box_open overwrites pk";
157
- for (j = -16;j < sklen + 16;++j) if (skb2[j] != skb[j]) return "crypto_box_open overwrites sk";
158
- for (j = -16;j < 0;++j) if (s2[j] != s[j]) return "crypto_box_beforenm writes before output";
159
- for (j = slen;j < slen + 16;++j) if (s2[j] != s[j]) return "crypto_box_beforenm writes after output";
160
-
161
- for (j = -16;j < slen + 16;++j) s2[j] = s[j];
162
- for (j = -16;j < tlen + 16;++j) t2[j] = t[j] = rand();
163
- if (crypto_box_afternm(t,m,mlen,n,s) != 0) return "crypto_box_afternm returns nonzero";
164
- for (j = -16;j < slen + 16;++j) if (s2[j] != s[j]) return "crypto_box_afternm overwrites s";
165
- for (j = -16;j < mlen + 16;++j) if (m2[j] != m[j]) return "crypto_box_afternm overwrites m";
166
- for (j = -16;j < nlen + 16;++j) if (n2[j] != n[j]) return "crypto_box_afternm overwrites n";
167
- for (j = -16;j < 0;++j) if (t2[j] != t[j]) return "crypto_box_afternm writes before output";
168
- for (j = tlen;j < tlen + 16;++j) if (t2[j] != t[j]) return "crypto_box_afternm writes after output";
169
- for (j = 0;j < crypto_box_BOXZEROBYTES;++j)
170
- if (t[j] != 0) return "crypto_box_afternm does not clear extra bytes";
171
- for (j = 0;j < mlen;++j) if (t[j] != c[j]) return "crypto_box_afternm does not match crypto_box";
172
-
173
- if (crypto_box_beforenm(s,pka,skb) != 0) return "crypto_box_beforenm returns nonzero";
174
-
175
- for (j = -16;j < tlen + 16;++j) t2[j] = t[j] = rand();
176
- if (crypto_box_open_afternm(t,c,clen,n,s) != 0) return "crypto_box_open_afternm returns nonzero";
177
- for (j = -16;j < slen + 16;++j) if (s2[j] != s[j]) return "crypto_box_open_afternm overwrites s";
178
- for (j = -16;j < mlen + 16;++j) if (m2[j] != m[j]) return "crypto_box_open_afternm overwrites m";
179
- for (j = -16;j < nlen + 16;++j) if (n2[j] != n[j]) return "crypto_box_open_afternm overwrites n";
180
- for (j = -16;j < 0;++j) if (t2[j] != t[j]) return "crypto_box_open_afternm writes before output";
181
- for (j = tlen;j < tlen + 16;++j) if (t2[j] != t[j]) return "crypto_box_open_afternm writes after output";
182
- for (j = 0;j < crypto_box_ZEROBYTES;++j)
183
- if (t[j] != 0) return "crypto_box_open_afternm does not clear extra bytes";
184
- for (j = 0;j < mlen;++j) if (t[j] != m[j]) return "crypto_box_open_afternm does not match crypto_box_open";
185
-
186
- for (j = 0;j < i;++j) n[j % nlen] ^= c[j + crypto_box_BOXZEROBYTES];
187
- if (i == 0) m[crypto_box_ZEROBYTES] = 0;
188
- m[i + crypto_box_ZEROBYTES] = m[crypto_box_ZEROBYTES];
189
- for (j = 0;j < i;++j) m[j + crypto_box_ZEROBYTES] ^= c[j + crypto_box_BOXZEROBYTES];
190
- }
191
-
192
- sodium_bin2hex(checksum, sizeof checksum, n, nlen);
193
-
194
- return 0;
195
- }