ring-native 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGES.md +7 -0
- data/Makefile +5 -0
- data/README.md +12 -5
- data/Rakefile +4 -0
- data/ext/ring/extconf.rb +4 -5
- data/lib/ring/native.rb +3 -1
- data/lib/ring/native/version.rb +5 -1
- data/ring-native.gemspec +6 -6
- data/vendor/ring-ffi/Cargo.lock +26 -0
- data/vendor/ring-ffi/Cargo.toml +45 -0
- data/vendor/ring-ffi/LICENSE +16 -0
- data/vendor/ring-ffi/README.md +59 -0
- data/vendor/ring-ffi/src/lib.rs +79 -0
- metadata +10 -255
- data/vendor/ring/BUILDING.md +0 -40
- data/vendor/ring/Cargo.toml +0 -43
- data/vendor/ring/LICENSE +0 -185
- data/vendor/ring/Makefile +0 -35
- data/vendor/ring/PORTING.md +0 -163
- data/vendor/ring/README.md +0 -113
- data/vendor/ring/STYLE.md +0 -197
- data/vendor/ring/appveyor.yml +0 -27
- data/vendor/ring/build.rs +0 -108
- data/vendor/ring/crypto/aes/aes.c +0 -1142
- data/vendor/ring/crypto/aes/aes_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/aes/aes_test.cc +0 -93
- data/vendor/ring/crypto/aes/asm/aes-586.pl +0 -2368
- data/vendor/ring/crypto/aes/asm/aes-armv4.pl +0 -1249
- data/vendor/ring/crypto/aes/asm/aes-x86_64.pl +0 -2246
- data/vendor/ring/crypto/aes/asm/aesni-x86.pl +0 -1318
- data/vendor/ring/crypto/aes/asm/aesni-x86_64.pl +0 -2084
- data/vendor/ring/crypto/aes/asm/aesv8-armx.pl +0 -675
- data/vendor/ring/crypto/aes/asm/bsaes-armv7.pl +0 -1364
- data/vendor/ring/crypto/aes/asm/bsaes-x86_64.pl +0 -1565
- data/vendor/ring/crypto/aes/asm/vpaes-x86.pl +0 -841
- data/vendor/ring/crypto/aes/asm/vpaes-x86_64.pl +0 -1116
- data/vendor/ring/crypto/aes/internal.h +0 -87
- data/vendor/ring/crypto/aes/mode_wrappers.c +0 -61
- data/vendor/ring/crypto/bn/add.c +0 -394
- data/vendor/ring/crypto/bn/asm/armv4-mont.pl +0 -694
- data/vendor/ring/crypto/bn/asm/armv8-mont.pl +0 -1503
- data/vendor/ring/crypto/bn/asm/bn-586.pl +0 -774
- data/vendor/ring/crypto/bn/asm/co-586.pl +0 -287
- data/vendor/ring/crypto/bn/asm/rsaz-avx2.pl +0 -1882
- data/vendor/ring/crypto/bn/asm/x86-mont.pl +0 -592
- data/vendor/ring/crypto/bn/asm/x86_64-gcc.c +0 -599
- data/vendor/ring/crypto/bn/asm/x86_64-mont.pl +0 -1393
- data/vendor/ring/crypto/bn/asm/x86_64-mont5.pl +0 -3507
- data/vendor/ring/crypto/bn/bn.c +0 -352
- data/vendor/ring/crypto/bn/bn_asn1.c +0 -74
- data/vendor/ring/crypto/bn/bn_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/bn/bn_test.cc +0 -1696
- data/vendor/ring/crypto/bn/cmp.c +0 -200
- data/vendor/ring/crypto/bn/convert.c +0 -433
- data/vendor/ring/crypto/bn/ctx.c +0 -311
- data/vendor/ring/crypto/bn/div.c +0 -594
- data/vendor/ring/crypto/bn/exponentiation.c +0 -1335
- data/vendor/ring/crypto/bn/gcd.c +0 -711
- data/vendor/ring/crypto/bn/generic.c +0 -1019
- data/vendor/ring/crypto/bn/internal.h +0 -316
- data/vendor/ring/crypto/bn/montgomery.c +0 -516
- data/vendor/ring/crypto/bn/mul.c +0 -888
- data/vendor/ring/crypto/bn/prime.c +0 -829
- data/vendor/ring/crypto/bn/random.c +0 -334
- data/vendor/ring/crypto/bn/rsaz_exp.c +0 -262
- data/vendor/ring/crypto/bn/rsaz_exp.h +0 -53
- data/vendor/ring/crypto/bn/shift.c +0 -276
- data/vendor/ring/crypto/bytestring/bytestring_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/bytestring/bytestring_test.cc +0 -421
- data/vendor/ring/crypto/bytestring/cbb.c +0 -399
- data/vendor/ring/crypto/bytestring/cbs.c +0 -227
- data/vendor/ring/crypto/bytestring/internal.h +0 -46
- data/vendor/ring/crypto/chacha/chacha_generic.c +0 -140
- data/vendor/ring/crypto/chacha/chacha_vec.c +0 -323
- data/vendor/ring/crypto/chacha/chacha_vec_arm.S +0 -1447
- data/vendor/ring/crypto/chacha/chacha_vec_arm_generate.go +0 -153
- data/vendor/ring/crypto/cipher/cipher_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/cipher/e_aes.c +0 -390
- data/vendor/ring/crypto/cipher/e_chacha20poly1305.c +0 -208
- data/vendor/ring/crypto/cipher/internal.h +0 -173
- data/vendor/ring/crypto/cipher/test/aes_128_gcm_tests.txt +0 -543
- data/vendor/ring/crypto/cipher/test/aes_128_key_wrap_tests.txt +0 -9
- data/vendor/ring/crypto/cipher/test/aes_256_gcm_tests.txt +0 -475
- data/vendor/ring/crypto/cipher/test/aes_256_key_wrap_tests.txt +0 -23
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_old_tests.txt +0 -422
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_tests.txt +0 -484
- data/vendor/ring/crypto/cipher/test/cipher_test.txt +0 -100
- data/vendor/ring/crypto/constant_time_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/constant_time_test.c +0 -304
- data/vendor/ring/crypto/cpu-arm-asm.S +0 -32
- data/vendor/ring/crypto/cpu-arm.c +0 -199
- data/vendor/ring/crypto/cpu-intel.c +0 -261
- data/vendor/ring/crypto/crypto.c +0 -151
- data/vendor/ring/crypto/curve25519/asm/x25519-arm.S +0 -2118
- data/vendor/ring/crypto/curve25519/curve25519.c +0 -4888
- data/vendor/ring/crypto/curve25519/x25519_test.cc +0 -128
- data/vendor/ring/crypto/digest/md32_common.h +0 -181
- data/vendor/ring/crypto/ec/asm/p256-x86_64-asm.pl +0 -2725
- data/vendor/ring/crypto/ec/ec.c +0 -193
- data/vendor/ring/crypto/ec/ec_curves.c +0 -61
- data/vendor/ring/crypto/ec/ec_key.c +0 -228
- data/vendor/ring/crypto/ec/ec_montgomery.c +0 -114
- data/vendor/ring/crypto/ec/example_mul.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/ec/internal.h +0 -243
- data/vendor/ring/crypto/ec/oct.c +0 -253
- data/vendor/ring/crypto/ec/p256-64.c +0 -1794
- data/vendor/ring/crypto/ec/p256-x86_64-table.h +0 -9548
- data/vendor/ring/crypto/ec/p256-x86_64.c +0 -509
- data/vendor/ring/crypto/ec/simple.c +0 -1007
- data/vendor/ring/crypto/ec/util-64.c +0 -183
- data/vendor/ring/crypto/ec/wnaf.c +0 -508
- data/vendor/ring/crypto/ecdh/ecdh.c +0 -155
- data/vendor/ring/crypto/ecdsa/ecdsa.c +0 -304
- data/vendor/ring/crypto/ecdsa/ecdsa_asn1.c +0 -193
- data/vendor/ring/crypto/ecdsa/ecdsa_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/ecdsa/ecdsa_test.cc +0 -327
- data/vendor/ring/crypto/header_removed.h +0 -17
- data/vendor/ring/crypto/internal.h +0 -495
- data/vendor/ring/crypto/libring.Windows.vcxproj +0 -101
- data/vendor/ring/crypto/mem.c +0 -98
- data/vendor/ring/crypto/modes/asm/aesni-gcm-x86_64.pl +0 -1045
- data/vendor/ring/crypto/modes/asm/ghash-armv4.pl +0 -517
- data/vendor/ring/crypto/modes/asm/ghash-x86.pl +0 -1393
- data/vendor/ring/crypto/modes/asm/ghash-x86_64.pl +0 -1741
- data/vendor/ring/crypto/modes/asm/ghashv8-armx.pl +0 -422
- data/vendor/ring/crypto/modes/ctr.c +0 -226
- data/vendor/ring/crypto/modes/gcm.c +0 -1206
- data/vendor/ring/crypto/modes/gcm_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/modes/gcm_test.c +0 -348
- data/vendor/ring/crypto/modes/internal.h +0 -299
- data/vendor/ring/crypto/perlasm/arm-xlate.pl +0 -170
- data/vendor/ring/crypto/perlasm/readme +0 -100
- data/vendor/ring/crypto/perlasm/x86_64-xlate.pl +0 -1164
- data/vendor/ring/crypto/perlasm/x86asm.pl +0 -292
- data/vendor/ring/crypto/perlasm/x86gas.pl +0 -263
- data/vendor/ring/crypto/perlasm/x86masm.pl +0 -200
- data/vendor/ring/crypto/perlasm/x86nasm.pl +0 -187
- data/vendor/ring/crypto/poly1305/poly1305.c +0 -331
- data/vendor/ring/crypto/poly1305/poly1305_arm.c +0 -301
- data/vendor/ring/crypto/poly1305/poly1305_arm_asm.S +0 -2015
- data/vendor/ring/crypto/poly1305/poly1305_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/poly1305/poly1305_test.cc +0 -80
- data/vendor/ring/crypto/poly1305/poly1305_test.txt +0 -52
- data/vendor/ring/crypto/poly1305/poly1305_vec.c +0 -892
- data/vendor/ring/crypto/rand/asm/rdrand-x86_64.pl +0 -75
- data/vendor/ring/crypto/rand/internal.h +0 -32
- data/vendor/ring/crypto/rand/rand.c +0 -189
- data/vendor/ring/crypto/rand/urandom.c +0 -219
- data/vendor/ring/crypto/rand/windows.c +0 -56
- data/vendor/ring/crypto/refcount_c11.c +0 -66
- data/vendor/ring/crypto/refcount_lock.c +0 -53
- data/vendor/ring/crypto/refcount_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/refcount_test.c +0 -58
- data/vendor/ring/crypto/rsa/blinding.c +0 -462
- data/vendor/ring/crypto/rsa/internal.h +0 -108
- data/vendor/ring/crypto/rsa/padding.c +0 -300
- data/vendor/ring/crypto/rsa/rsa.c +0 -450
- data/vendor/ring/crypto/rsa/rsa_asn1.c +0 -261
- data/vendor/ring/crypto/rsa/rsa_impl.c +0 -944
- data/vendor/ring/crypto/rsa/rsa_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/rsa/rsa_test.cc +0 -437
- data/vendor/ring/crypto/sha/asm/sha-armv8.pl +0 -436
- data/vendor/ring/crypto/sha/asm/sha-x86_64.pl +0 -2390
- data/vendor/ring/crypto/sha/asm/sha256-586.pl +0 -1275
- data/vendor/ring/crypto/sha/asm/sha256-armv4.pl +0 -735
- data/vendor/ring/crypto/sha/asm/sha256-armv8.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha256-x86_64.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha512-586.pl +0 -911
- data/vendor/ring/crypto/sha/asm/sha512-armv4.pl +0 -666
- data/vendor/ring/crypto/sha/asm/sha512-armv8.pl +0 -14
- data/vendor/ring/crypto/sha/asm/sha512-x86_64.pl +0 -14
- data/vendor/ring/crypto/sha/sha1.c +0 -271
- data/vendor/ring/crypto/sha/sha256.c +0 -204
- data/vendor/ring/crypto/sha/sha512.c +0 -355
- data/vendor/ring/crypto/test/file_test.cc +0 -326
- data/vendor/ring/crypto/test/file_test.h +0 -181
- data/vendor/ring/crypto/test/malloc.cc +0 -150
- data/vendor/ring/crypto/test/scoped_types.h +0 -95
- data/vendor/ring/crypto/test/test.Windows.vcxproj +0 -35
- data/vendor/ring/crypto/test/test_util.cc +0 -46
- data/vendor/ring/crypto/test/test_util.h +0 -41
- data/vendor/ring/crypto/thread_none.c +0 -55
- data/vendor/ring/crypto/thread_pthread.c +0 -165
- data/vendor/ring/crypto/thread_test.Windows.vcxproj +0 -25
- data/vendor/ring/crypto/thread_test.c +0 -200
- data/vendor/ring/crypto/thread_win.c +0 -282
- data/vendor/ring/examples/checkdigest.rs +0 -103
- data/vendor/ring/include/openssl/aes.h +0 -121
- data/vendor/ring/include/openssl/arm_arch.h +0 -129
- data/vendor/ring/include/openssl/base.h +0 -156
- data/vendor/ring/include/openssl/bn.h +0 -794
- data/vendor/ring/include/openssl/buffer.h +0 -18
- data/vendor/ring/include/openssl/bytestring.h +0 -235
- data/vendor/ring/include/openssl/chacha.h +0 -37
- data/vendor/ring/include/openssl/cmac.h +0 -76
- data/vendor/ring/include/openssl/cpu.h +0 -184
- data/vendor/ring/include/openssl/crypto.h +0 -43
- data/vendor/ring/include/openssl/curve25519.h +0 -88
- data/vendor/ring/include/openssl/ec.h +0 -225
- data/vendor/ring/include/openssl/ec_key.h +0 -129
- data/vendor/ring/include/openssl/ecdh.h +0 -110
- data/vendor/ring/include/openssl/ecdsa.h +0 -156
- data/vendor/ring/include/openssl/err.h +0 -201
- data/vendor/ring/include/openssl/mem.h +0 -101
- data/vendor/ring/include/openssl/obj_mac.h +0 -71
- data/vendor/ring/include/openssl/opensslfeatures.h +0 -68
- data/vendor/ring/include/openssl/opensslv.h +0 -18
- data/vendor/ring/include/openssl/ossl_typ.h +0 -18
- data/vendor/ring/include/openssl/poly1305.h +0 -51
- data/vendor/ring/include/openssl/rand.h +0 -70
- data/vendor/ring/include/openssl/rsa.h +0 -399
- data/vendor/ring/include/openssl/thread.h +0 -133
- data/vendor/ring/include/openssl/type_check.h +0 -71
- data/vendor/ring/mk/Common.props +0 -63
- data/vendor/ring/mk/Windows.props +0 -42
- data/vendor/ring/mk/WindowsTest.props +0 -18
- data/vendor/ring/mk/appveyor.bat +0 -62
- data/vendor/ring/mk/bottom_of_makefile.mk +0 -54
- data/vendor/ring/mk/ring.mk +0 -266
- data/vendor/ring/mk/top_of_makefile.mk +0 -214
- data/vendor/ring/mk/travis.sh +0 -40
- data/vendor/ring/mk/update-travis-yml.py +0 -229
- data/vendor/ring/ring.sln +0 -153
- data/vendor/ring/src/aead.rs +0 -682
- data/vendor/ring/src/agreement.rs +0 -248
- data/vendor/ring/src/c.rs +0 -129
- data/vendor/ring/src/constant_time.rs +0 -37
- data/vendor/ring/src/der.rs +0 -96
- data/vendor/ring/src/digest.rs +0 -690
- data/vendor/ring/src/digest_tests.txt +0 -57
- data/vendor/ring/src/ecc.rs +0 -28
- data/vendor/ring/src/ecc_build.rs +0 -279
- data/vendor/ring/src/ecc_curves.rs +0 -117
- data/vendor/ring/src/ed25519_tests.txt +0 -2579
- data/vendor/ring/src/exe_tests.rs +0 -46
- data/vendor/ring/src/ffi.rs +0 -29
- data/vendor/ring/src/file_test.rs +0 -187
- data/vendor/ring/src/hkdf.rs +0 -153
- data/vendor/ring/src/hkdf_tests.txt +0 -59
- data/vendor/ring/src/hmac.rs +0 -414
- data/vendor/ring/src/hmac_tests.txt +0 -97
- data/vendor/ring/src/input.rs +0 -312
- data/vendor/ring/src/lib.rs +0 -41
- data/vendor/ring/src/pbkdf2.rs +0 -265
- data/vendor/ring/src/pbkdf2_tests.txt +0 -113
- data/vendor/ring/src/polyfill.rs +0 -57
- data/vendor/ring/src/rand.rs +0 -28
- data/vendor/ring/src/signature.rs +0 -314
- data/vendor/ring/third-party/NIST/README.md +0 -9
- data/vendor/ring/third-party/NIST/SHAVS/SHA1LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA1Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA1ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA224LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA224Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA224ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA256LongMsg.rsp +0 -263
- data/vendor/ring/third-party/NIST/SHAVS/SHA256Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA256ShortMsg.rsp +0 -267
- data/vendor/ring/third-party/NIST/SHAVS/SHA384LongMsg.rsp +0 -519
- data/vendor/ring/third-party/NIST/SHAVS/SHA384Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA384ShortMsg.rsp +0 -523
- data/vendor/ring/third-party/NIST/SHAVS/SHA512LongMsg.rsp +0 -519
- data/vendor/ring/third-party/NIST/SHAVS/SHA512Monte.rsp +0 -309
- data/vendor/ring/third-party/NIST/SHAVS/SHA512ShortMsg.rsp +0 -523
- data/vendor/ring/third-party/NIST/sha256sums.txt +0 -1
@@ -1,46 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2015, Google Inc.
|
2
|
-
*
|
3
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
* purpose with or without fee is hereby granted, provided that the above
|
5
|
-
* copyright notice and this permission notice appear in all copies.
|
6
|
-
*
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
-
|
15
|
-
#include "test_util.h"
|
16
|
-
|
17
|
-
#include <stdint.h>
|
18
|
-
#include <stdio.h>
|
19
|
-
|
20
|
-
#include "openssl/rand.h"
|
21
|
-
|
22
|
-
|
23
|
-
void hexdump(FILE *fp, const char *msg, const void *in, size_t len) {
|
24
|
-
const uint8_t *data = reinterpret_cast<const uint8_t*>(in);
|
25
|
-
size_t i;
|
26
|
-
|
27
|
-
fputs(msg, fp);
|
28
|
-
for (i = 0; i < len; i++) {
|
29
|
-
fprintf(fp, "%02x", data[i]);
|
30
|
-
}
|
31
|
-
fputs("\n", fp);
|
32
|
-
}
|
33
|
-
|
34
|
-
// XXX: In *ring*, we implement |BN_generate_dsa_nonce_digest| in Rust so that
|
35
|
-
// we can use |ring::digest|. But, the tests don't link against any Rust code.
|
36
|
-
// Fortunately, we don't need secure nonces in the tests, so we can do the
|
37
|
-
// thing you're not supposed to do in this implementation. This will likely
|
38
|
-
// throw off the ECDSA_sign performance measurements in |bssl speed| though.
|
39
|
-
extern "C" int BN_generate_dsa_nonce_digest(uint8_t *out, size_t out_len,
|
40
|
-
const uint8_t *, size_t,
|
41
|
-
const uint8_t *, size_t,
|
42
|
-
const uint8_t *, size_t,
|
43
|
-
const uint8_t *, size_t,
|
44
|
-
const uint8_t *, size_t) {
|
45
|
-
return RAND_bytes(out, out_len);
|
46
|
-
}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2015, Google Inc.
|
2
|
-
*
|
3
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
* purpose with or without fee is hereby granted, provided that the above
|
5
|
-
* copyright notice and this permission notice appear in all copies.
|
6
|
-
*
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
-
|
15
|
-
#ifndef OPENSSL_HEADER_CRYPTO_TEST_TEST_UTIL_H
|
16
|
-
#define OPENSSL_HEADER_CRYPTO_TEST_TEST_UTIL_H
|
17
|
-
|
18
|
-
#include <stddef.h>
|
19
|
-
#include <stdio.h>
|
20
|
-
|
21
|
-
#if defined(_MSC_VER) && _MSC_VER < 1900
|
22
|
-
#define OPENSSL_PR_SIZE_T "Iu" /* MSVC doesn't support %zu until MSVC 2015. */
|
23
|
-
#else
|
24
|
-
#define OPENSSL_PR_SIZE_T "zu" /* "%zu" is the C99 standard format specifier. */
|
25
|
-
#endif
|
26
|
-
|
27
|
-
#if defined(__cplusplus)
|
28
|
-
extern "C" {
|
29
|
-
#endif
|
30
|
-
|
31
|
-
|
32
|
-
/* hexdump writes |msg| to |fp| followed by the hex encoding of |len| bytes
|
33
|
-
* from |in|. */
|
34
|
-
void hexdump(FILE *fp, const char *msg, const void *in, size_t len);
|
35
|
-
|
36
|
-
|
37
|
-
#if defined(__cplusplus)
|
38
|
-
}
|
39
|
-
#endif
|
40
|
-
|
41
|
-
#endif /* OPENSSL_HEADER_CRYPTO_TEST_TEST_UTIL_H */
|
@@ -1,55 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2015, Google Inc.
|
2
|
-
*
|
3
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
* purpose with or without fee is hereby granted, provided that the above
|
5
|
-
* copyright notice and this permission notice appear in all copies.
|
6
|
-
*
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
-
|
15
|
-
#include "internal.h"
|
16
|
-
|
17
|
-
#if defined(OPENSSL_NO_THREADS)
|
18
|
-
|
19
|
-
void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) {}
|
20
|
-
|
21
|
-
void CRYPTO_MUTEX_lock_read(CRYPTO_MUTEX *lock) {}
|
22
|
-
|
23
|
-
void CRYPTO_MUTEX_lock_write(CRYPTO_MUTEX *lock) {}
|
24
|
-
|
25
|
-
void CRYPTO_MUTEX_unlock(CRYPTO_MUTEX *lock) {}
|
26
|
-
|
27
|
-
void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock) {}
|
28
|
-
|
29
|
-
void CRYPTO_STATIC_MUTEX_lock_read(struct CRYPTO_STATIC_MUTEX *lock) {}
|
30
|
-
|
31
|
-
void CRYPTO_STATIC_MUTEX_lock_write(struct CRYPTO_STATIC_MUTEX *lock) {}
|
32
|
-
|
33
|
-
void CRYPTO_STATIC_MUTEX_unlock(struct CRYPTO_STATIC_MUTEX *lock) {}
|
34
|
-
|
35
|
-
void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) {
|
36
|
-
if (*once) {
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
*once = 1;
|
40
|
-
init();
|
41
|
-
}
|
42
|
-
|
43
|
-
static void *g_thread_locals[NUM_OPENSSL_THREAD_LOCALS];
|
44
|
-
|
45
|
-
void *CRYPTO_get_thread_local(thread_local_data_t index) {
|
46
|
-
return g_thread_locals[index];
|
47
|
-
}
|
48
|
-
|
49
|
-
int CRYPTO_set_thread_local(thread_local_data_t index, void *value,
|
50
|
-
thread_local_destructor_t destructor) {
|
51
|
-
g_thread_locals[index] = value;
|
52
|
-
return 1;
|
53
|
-
}
|
54
|
-
|
55
|
-
#endif /* OPENSSL_NO_THREADS */
|
@@ -1,165 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2015, Google Inc.
|
2
|
-
*
|
3
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
* purpose with or without fee is hereby granted, provided that the above
|
5
|
-
* copyright notice and this permission notice appear in all copies.
|
6
|
-
*
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
-
|
15
|
-
#include "internal.h"
|
16
|
-
|
17
|
-
#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_NO_THREADS)
|
18
|
-
|
19
|
-
#include <pthread.h>
|
20
|
-
#include <stdio.h>
|
21
|
-
#include <stdlib.h>
|
22
|
-
#include <string.h>
|
23
|
-
|
24
|
-
#include <openssl/mem.h>
|
25
|
-
#include <openssl/type_check.h>
|
26
|
-
|
27
|
-
|
28
|
-
OPENSSL_COMPILE_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(pthread_rwlock_t),
|
29
|
-
CRYPTO_MUTEX_too_small);
|
30
|
-
|
31
|
-
void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) {
|
32
|
-
if (pthread_rwlock_init((pthread_rwlock_t *) lock, NULL) != 0) {
|
33
|
-
abort();
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
void CRYPTO_MUTEX_lock_read(CRYPTO_MUTEX *lock) {
|
38
|
-
if (pthread_rwlock_rdlock((pthread_rwlock_t *) lock) != 0) {
|
39
|
-
abort();
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
void CRYPTO_MUTEX_lock_write(CRYPTO_MUTEX *lock) {
|
44
|
-
if (pthread_rwlock_wrlock((pthread_rwlock_t *) lock) != 0) {
|
45
|
-
abort();
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
void CRYPTO_MUTEX_unlock(CRYPTO_MUTEX *lock) {
|
50
|
-
if (pthread_rwlock_unlock((pthread_rwlock_t *) lock) != 0) {
|
51
|
-
abort();
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock) {
|
56
|
-
pthread_rwlock_destroy((pthread_rwlock_t *) lock);
|
57
|
-
}
|
58
|
-
|
59
|
-
void CRYPTO_STATIC_MUTEX_lock_read(struct CRYPTO_STATIC_MUTEX *lock) {
|
60
|
-
if (pthread_rwlock_rdlock(&lock->lock) != 0) {
|
61
|
-
abort();
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
void CRYPTO_STATIC_MUTEX_lock_write(struct CRYPTO_STATIC_MUTEX *lock) {
|
66
|
-
if (pthread_rwlock_wrlock(&lock->lock) != 0) {
|
67
|
-
abort();
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
void CRYPTO_STATIC_MUTEX_unlock(struct CRYPTO_STATIC_MUTEX *lock) {
|
72
|
-
if (pthread_rwlock_unlock(&lock->lock) != 0) {
|
73
|
-
abort();
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) {
|
78
|
-
if (pthread_once(once, init) != 0) {
|
79
|
-
abort();
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
static pthread_mutex_t g_destructors_lock = PTHREAD_MUTEX_INITIALIZER;
|
84
|
-
static thread_local_destructor_t g_destructors[NUM_OPENSSL_THREAD_LOCALS];
|
85
|
-
|
86
|
-
static void thread_local_destructor(void *arg) {
|
87
|
-
if (arg == NULL) {
|
88
|
-
return;
|
89
|
-
}
|
90
|
-
|
91
|
-
thread_local_destructor_t destructors[NUM_OPENSSL_THREAD_LOCALS];
|
92
|
-
if (pthread_mutex_lock(&g_destructors_lock) != 0) {
|
93
|
-
return;
|
94
|
-
}
|
95
|
-
memcpy(destructors, g_destructors, sizeof(destructors));
|
96
|
-
pthread_mutex_unlock(&g_destructors_lock);
|
97
|
-
|
98
|
-
unsigned i;
|
99
|
-
void **pointers = arg;
|
100
|
-
for (i = 0; i < NUM_OPENSSL_THREAD_LOCALS; i++) {
|
101
|
-
if (destructors[i] != NULL) {
|
102
|
-
destructors[i](pointers[i]);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
OPENSSL_free(pointers);
|
107
|
-
}
|
108
|
-
|
109
|
-
static pthread_once_t g_thread_local_init_once = PTHREAD_ONCE_INIT;
|
110
|
-
static pthread_key_t g_thread_local_key;
|
111
|
-
static int g_thread_local_failed = 0;
|
112
|
-
|
113
|
-
static void thread_local_init(void) {
|
114
|
-
g_thread_local_failed =
|
115
|
-
pthread_key_create(&g_thread_local_key, thread_local_destructor) != 0;
|
116
|
-
}
|
117
|
-
|
118
|
-
void *CRYPTO_get_thread_local(thread_local_data_t index) {
|
119
|
-
CRYPTO_once(&g_thread_local_init_once, thread_local_init);
|
120
|
-
if (g_thread_local_failed) {
|
121
|
-
return NULL;
|
122
|
-
}
|
123
|
-
|
124
|
-
void **pointers = pthread_getspecific(g_thread_local_key);
|
125
|
-
if (pointers == NULL) {
|
126
|
-
return NULL;
|
127
|
-
}
|
128
|
-
return pointers[index];
|
129
|
-
}
|
130
|
-
|
131
|
-
int CRYPTO_set_thread_local(thread_local_data_t index, void *value,
|
132
|
-
thread_local_destructor_t destructor) {
|
133
|
-
CRYPTO_once(&g_thread_local_init_once, thread_local_init);
|
134
|
-
if (g_thread_local_failed) {
|
135
|
-
destructor(value);
|
136
|
-
return 0;
|
137
|
-
}
|
138
|
-
|
139
|
-
void **pointers = pthread_getspecific(g_thread_local_key);
|
140
|
-
if (pointers == NULL) {
|
141
|
-
pointers = OPENSSL_malloc(sizeof(void *) * NUM_OPENSSL_THREAD_LOCALS);
|
142
|
-
if (pointers == NULL) {
|
143
|
-
destructor(value);
|
144
|
-
return 0;
|
145
|
-
}
|
146
|
-
memset(pointers, 0, sizeof(void *) * NUM_OPENSSL_THREAD_LOCALS);
|
147
|
-
if (pthread_setspecific(g_thread_local_key, pointers) != 0) {
|
148
|
-
OPENSSL_free(pointers);
|
149
|
-
destructor(value);
|
150
|
-
return 0;
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
if (pthread_mutex_lock(&g_destructors_lock) != 0) {
|
155
|
-
destructor(value);
|
156
|
-
return 0;
|
157
|
-
}
|
158
|
-
g_destructors[index] = destructor;
|
159
|
-
pthread_mutex_unlock(&g_destructors_lock);
|
160
|
-
|
161
|
-
pointers[index] = value;
|
162
|
-
return 1;
|
163
|
-
}
|
164
|
-
|
165
|
-
#endif /* !OPENSSL_WINDOWS && !OPENSSL_NO_THREADS */
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3
|
-
<PropertyGroup Label="Globals">
|
4
|
-
<ProjectGuid>{52C6E909-4E56-4329-8B99-E1B5C2E1FB19}</ProjectGuid>
|
5
|
-
<TargetName>thread_test</TargetName>
|
6
|
-
</PropertyGroup>
|
7
|
-
<ImportGroup Label="PropertySheets">
|
8
|
-
<Import Project="..\mk\WindowsTest.props" />
|
9
|
-
</ImportGroup>
|
10
|
-
<PropertyGroup Label="Configuration">
|
11
|
-
<OutDir>$(OutRootDir)\test\ring\crypto\</OutDir>
|
12
|
-
</PropertyGroup>
|
13
|
-
<ItemGroup>
|
14
|
-
<ClCompile Include="thread_test.c" />
|
15
|
-
</ItemGroup>
|
16
|
-
<ItemGroup>
|
17
|
-
<ProjectReference Include="libring.Windows.vcxproj">
|
18
|
-
<Project>{f4c0a1b6-5e09-41c8-8242-3e1f6762fb18}</Project>
|
19
|
-
</ProjectReference>
|
20
|
-
<ProjectReference Include="test\test.Windows.vcxproj">
|
21
|
-
<Project>{1dace503-6498-492d-b1ff-f9ee18624443}</Project>
|
22
|
-
</ProjectReference>
|
23
|
-
</ItemGroup>
|
24
|
-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
25
|
-
</Project>
|
@@ -1,200 +0,0 @@
|
|
1
|
-
/* Copyright (c) 2015, Google Inc.
|
2
|
-
*
|
3
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
-
* purpose with or without fee is hereby granted, provided that the above
|
5
|
-
* copyright notice and this permission notice appear in all copies.
|
6
|
-
*
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
-
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
-
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
-
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
-
|
15
|
-
#include "internal.h"
|
16
|
-
|
17
|
-
#include <stdio.h>
|
18
|
-
|
19
|
-
|
20
|
-
#if !defined(OPENSSL_NO_THREADS)
|
21
|
-
|
22
|
-
#if defined(OPENSSL_WINDOWS)
|
23
|
-
|
24
|
-
#pragma warning(push, 3)
|
25
|
-
#include <windows.h>
|
26
|
-
#pragma warning(pop)
|
27
|
-
|
28
|
-
typedef HANDLE thread_t;
|
29
|
-
|
30
|
-
static DWORD WINAPI thread_run(LPVOID arg) {
|
31
|
-
void (*thread_func)(void);
|
32
|
-
/* VC really doesn't like casting between data and function pointers. */
|
33
|
-
memcpy(&thread_func, &arg, sizeof(thread_func));
|
34
|
-
thread_func();
|
35
|
-
return 0;
|
36
|
-
}
|
37
|
-
|
38
|
-
static int run_thread(thread_t *out_thread, void (*thread_func)(void)) {
|
39
|
-
void *arg;
|
40
|
-
/* VC really doesn't like casting between data and function pointers. */
|
41
|
-
memcpy(&arg, &thread_func, sizeof(arg));
|
42
|
-
|
43
|
-
*out_thread = CreateThread(NULL /* security attributes */,
|
44
|
-
0 /* default stack size */, thread_run, arg,
|
45
|
-
0 /* run immediately */, NULL /* ignore id */);
|
46
|
-
return *out_thread != NULL;
|
47
|
-
}
|
48
|
-
|
49
|
-
static int wait_for_thread(thread_t thread) {
|
50
|
-
return WaitForSingleObject(thread, INFINITE) == 0;
|
51
|
-
}
|
52
|
-
|
53
|
-
#else
|
54
|
-
|
55
|
-
#include <pthread.h>
|
56
|
-
|
57
|
-
typedef pthread_t thread_t;
|
58
|
-
|
59
|
-
static void *thread_run(void *arg) {
|
60
|
-
void (*thread_func)(void) = arg;
|
61
|
-
thread_func();
|
62
|
-
return NULL;
|
63
|
-
}
|
64
|
-
|
65
|
-
static int run_thread(thread_t *out_thread, void (*thread_func)(void)) {
|
66
|
-
return pthread_create(out_thread, NULL /* default attributes */, thread_run,
|
67
|
-
thread_func) == 0;
|
68
|
-
}
|
69
|
-
|
70
|
-
static int wait_for_thread(thread_t thread) {
|
71
|
-
return pthread_join(thread, NULL) == 0;
|
72
|
-
}
|
73
|
-
|
74
|
-
#endif /* OPENSSL_WINDOWS */
|
75
|
-
|
76
|
-
static unsigned g_once_init_called = 0;
|
77
|
-
|
78
|
-
static void once_init(void) {
|
79
|
-
g_once_init_called++;
|
80
|
-
}
|
81
|
-
|
82
|
-
static CRYPTO_once_t g_test_once = CRYPTO_ONCE_INIT;
|
83
|
-
|
84
|
-
static void call_once_thread(void) {
|
85
|
-
CRYPTO_once(&g_test_once, once_init);
|
86
|
-
}
|
87
|
-
|
88
|
-
static int test_once(void) {
|
89
|
-
if (g_once_init_called != 0) {
|
90
|
-
fprintf(stderr, "g_once_init_called was non-zero at start.\n");
|
91
|
-
return 0;
|
92
|
-
}
|
93
|
-
|
94
|
-
thread_t thread;
|
95
|
-
if (!run_thread(&thread, call_once_thread) ||
|
96
|
-
!wait_for_thread(thread)) {
|
97
|
-
fprintf(stderr, "thread failed.\n");
|
98
|
-
return 0;
|
99
|
-
}
|
100
|
-
|
101
|
-
CRYPTO_once(&g_test_once, once_init);
|
102
|
-
|
103
|
-
if (g_once_init_called != 1) {
|
104
|
-
fprintf(stderr, "Expected init function to be called once, but found %u.\n",
|
105
|
-
g_once_init_called);
|
106
|
-
return 0;
|
107
|
-
}
|
108
|
-
|
109
|
-
return 1;
|
110
|
-
}
|
111
|
-
|
112
|
-
|
113
|
-
static int g_test_thread_ok = 0;
|
114
|
-
static unsigned g_destructor_called_count = 0;
|
115
|
-
|
116
|
-
static void thread_local_destructor(void *arg) {
|
117
|
-
if (arg == NULL) {
|
118
|
-
return;
|
119
|
-
}
|
120
|
-
|
121
|
-
unsigned *count = arg;
|
122
|
-
(*count)++;
|
123
|
-
}
|
124
|
-
|
125
|
-
static void thread_local_test_thread(void) {
|
126
|
-
void *ptr = CRYPTO_get_thread_local(OPENSSL_THREAD_LOCAL_TEST);
|
127
|
-
if (ptr != NULL) {
|
128
|
-
return;
|
129
|
-
}
|
130
|
-
|
131
|
-
if (!CRYPTO_set_thread_local(OPENSSL_THREAD_LOCAL_TEST,
|
132
|
-
&g_destructor_called_count,
|
133
|
-
thread_local_destructor)) {
|
134
|
-
return;
|
135
|
-
}
|
136
|
-
|
137
|
-
if (CRYPTO_get_thread_local(OPENSSL_THREAD_LOCAL_TEST) !=
|
138
|
-
&g_destructor_called_count) {
|
139
|
-
return;
|
140
|
-
}
|
141
|
-
|
142
|
-
g_test_thread_ok = 1;
|
143
|
-
}
|
144
|
-
|
145
|
-
static void thread_local_test2_thread(void) {}
|
146
|
-
|
147
|
-
static int test_thread_local(void) {
|
148
|
-
void *ptr = CRYPTO_get_thread_local(OPENSSL_THREAD_LOCAL_TEST);
|
149
|
-
if (ptr != NULL) {
|
150
|
-
fprintf(stderr, "Thread-local data was non-NULL at start.\n");
|
151
|
-
}
|
152
|
-
|
153
|
-
thread_t thread;
|
154
|
-
if (!run_thread(&thread, thread_local_test_thread) ||
|
155
|
-
!wait_for_thread(thread)) {
|
156
|
-
fprintf(stderr, "thread failed.\n");
|
157
|
-
return 0;
|
158
|
-
}
|
159
|
-
|
160
|
-
if (!g_test_thread_ok) {
|
161
|
-
fprintf(stderr, "Thread-local data didn't work in thread.\n");
|
162
|
-
return 0;
|
163
|
-
}
|
164
|
-
|
165
|
-
if (g_destructor_called_count != 1) {
|
166
|
-
fprintf(stderr,
|
167
|
-
"Destructor should have been called once, but actually called %u "
|
168
|
-
"times.\n",
|
169
|
-
g_destructor_called_count);
|
170
|
-
return 0;
|
171
|
-
}
|
172
|
-
|
173
|
-
/* thread_local_test2_thread doesn't do anything, but it tests that the
|
174
|
-
* thread destructor function works even if thread-local storage wasn't used
|
175
|
-
* for a thread. */
|
176
|
-
if (!run_thread(&thread, thread_local_test2_thread) ||
|
177
|
-
!wait_for_thread(thread)) {
|
178
|
-
fprintf(stderr, "thread failed.\n");
|
179
|
-
return 0;
|
180
|
-
}
|
181
|
-
|
182
|
-
return 1;
|
183
|
-
}
|
184
|
-
|
185
|
-
int main(int argc, char **argv) {
|
186
|
-
if (!test_once() ||
|
187
|
-
!test_thread_local()) {
|
188
|
-
return 1;
|
189
|
-
}
|
190
|
-
|
191
|
-
return 0;
|
192
|
-
}
|
193
|
-
|
194
|
-
#else /* OPENSSL_NO_THREADS */
|
195
|
-
|
196
|
-
int main(int argc, char **argv) {
|
197
|
-
return 0;
|
198
|
-
}
|
199
|
-
|
200
|
-
#endif
|