ring-native 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/README.md +22 -0
- data/Rakefile +1 -0
- data/ext/ring/extconf.rb +29 -0
- data/lib/ring/native.rb +8 -0
- data/lib/ring/native/version.rb +5 -0
- data/ring-native.gemspec +25 -0
- data/vendor/ring/BUILDING.md +40 -0
- data/vendor/ring/Cargo.toml +43 -0
- data/vendor/ring/LICENSE +185 -0
- data/vendor/ring/Makefile +35 -0
- data/vendor/ring/PORTING.md +163 -0
- data/vendor/ring/README.md +113 -0
- data/vendor/ring/STYLE.md +197 -0
- data/vendor/ring/appveyor.yml +27 -0
- data/vendor/ring/build.rs +108 -0
- data/vendor/ring/crypto/aes/aes.c +1142 -0
- data/vendor/ring/crypto/aes/aes_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/aes/aes_test.cc +93 -0
- data/vendor/ring/crypto/aes/asm/aes-586.pl +2368 -0
- data/vendor/ring/crypto/aes/asm/aes-armv4.pl +1249 -0
- data/vendor/ring/crypto/aes/asm/aes-x86_64.pl +2246 -0
- data/vendor/ring/crypto/aes/asm/aesni-x86.pl +1318 -0
- data/vendor/ring/crypto/aes/asm/aesni-x86_64.pl +2084 -0
- data/vendor/ring/crypto/aes/asm/aesv8-armx.pl +675 -0
- data/vendor/ring/crypto/aes/asm/bsaes-armv7.pl +1364 -0
- data/vendor/ring/crypto/aes/asm/bsaes-x86_64.pl +1565 -0
- data/vendor/ring/crypto/aes/asm/vpaes-x86.pl +841 -0
- data/vendor/ring/crypto/aes/asm/vpaes-x86_64.pl +1116 -0
- data/vendor/ring/crypto/aes/internal.h +87 -0
- data/vendor/ring/crypto/aes/mode_wrappers.c +61 -0
- data/vendor/ring/crypto/bn/add.c +394 -0
- data/vendor/ring/crypto/bn/asm/armv4-mont.pl +694 -0
- data/vendor/ring/crypto/bn/asm/armv8-mont.pl +1503 -0
- data/vendor/ring/crypto/bn/asm/bn-586.pl +774 -0
- data/vendor/ring/crypto/bn/asm/co-586.pl +287 -0
- data/vendor/ring/crypto/bn/asm/rsaz-avx2.pl +1882 -0
- data/vendor/ring/crypto/bn/asm/x86-mont.pl +592 -0
- data/vendor/ring/crypto/bn/asm/x86_64-gcc.c +599 -0
- data/vendor/ring/crypto/bn/asm/x86_64-mont.pl +1393 -0
- data/vendor/ring/crypto/bn/asm/x86_64-mont5.pl +3507 -0
- data/vendor/ring/crypto/bn/bn.c +352 -0
- data/vendor/ring/crypto/bn/bn_asn1.c +74 -0
- data/vendor/ring/crypto/bn/bn_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/bn/bn_test.cc +1696 -0
- data/vendor/ring/crypto/bn/cmp.c +200 -0
- data/vendor/ring/crypto/bn/convert.c +433 -0
- data/vendor/ring/crypto/bn/ctx.c +311 -0
- data/vendor/ring/crypto/bn/div.c +594 -0
- data/vendor/ring/crypto/bn/exponentiation.c +1335 -0
- data/vendor/ring/crypto/bn/gcd.c +711 -0
- data/vendor/ring/crypto/bn/generic.c +1019 -0
- data/vendor/ring/crypto/bn/internal.h +316 -0
- data/vendor/ring/crypto/bn/montgomery.c +516 -0
- data/vendor/ring/crypto/bn/mul.c +888 -0
- data/vendor/ring/crypto/bn/prime.c +829 -0
- data/vendor/ring/crypto/bn/random.c +334 -0
- data/vendor/ring/crypto/bn/rsaz_exp.c +262 -0
- data/vendor/ring/crypto/bn/rsaz_exp.h +53 -0
- data/vendor/ring/crypto/bn/shift.c +276 -0
- data/vendor/ring/crypto/bytestring/bytestring_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/bytestring/bytestring_test.cc +421 -0
- data/vendor/ring/crypto/bytestring/cbb.c +399 -0
- data/vendor/ring/crypto/bytestring/cbs.c +227 -0
- data/vendor/ring/crypto/bytestring/internal.h +46 -0
- data/vendor/ring/crypto/chacha/chacha_generic.c +140 -0
- data/vendor/ring/crypto/chacha/chacha_vec.c +323 -0
- data/vendor/ring/crypto/chacha/chacha_vec_arm.S +1447 -0
- data/vendor/ring/crypto/chacha/chacha_vec_arm_generate.go +153 -0
- data/vendor/ring/crypto/cipher/cipher_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/cipher/e_aes.c +390 -0
- data/vendor/ring/crypto/cipher/e_chacha20poly1305.c +208 -0
- data/vendor/ring/crypto/cipher/internal.h +173 -0
- data/vendor/ring/crypto/cipher/test/aes_128_gcm_tests.txt +543 -0
- data/vendor/ring/crypto/cipher/test/aes_128_key_wrap_tests.txt +9 -0
- data/vendor/ring/crypto/cipher/test/aes_256_gcm_tests.txt +475 -0
- data/vendor/ring/crypto/cipher/test/aes_256_key_wrap_tests.txt +23 -0
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_old_tests.txt +422 -0
- data/vendor/ring/crypto/cipher/test/chacha20_poly1305_tests.txt +484 -0
- data/vendor/ring/crypto/cipher/test/cipher_test.txt +100 -0
- data/vendor/ring/crypto/constant_time_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/constant_time_test.c +304 -0
- data/vendor/ring/crypto/cpu-arm-asm.S +32 -0
- data/vendor/ring/crypto/cpu-arm.c +199 -0
- data/vendor/ring/crypto/cpu-intel.c +261 -0
- data/vendor/ring/crypto/crypto.c +151 -0
- data/vendor/ring/crypto/curve25519/asm/x25519-arm.S +2118 -0
- data/vendor/ring/crypto/curve25519/curve25519.c +4888 -0
- data/vendor/ring/crypto/curve25519/x25519_test.cc +128 -0
- data/vendor/ring/crypto/digest/md32_common.h +181 -0
- data/vendor/ring/crypto/ec/asm/p256-x86_64-asm.pl +2725 -0
- data/vendor/ring/crypto/ec/ec.c +193 -0
- data/vendor/ring/crypto/ec/ec_curves.c +61 -0
- data/vendor/ring/crypto/ec/ec_key.c +228 -0
- data/vendor/ring/crypto/ec/ec_montgomery.c +114 -0
- data/vendor/ring/crypto/ec/example_mul.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/ec/internal.h +243 -0
- data/vendor/ring/crypto/ec/oct.c +253 -0
- data/vendor/ring/crypto/ec/p256-64.c +1794 -0
- data/vendor/ring/crypto/ec/p256-x86_64-table.h +9548 -0
- data/vendor/ring/crypto/ec/p256-x86_64.c +509 -0
- data/vendor/ring/crypto/ec/simple.c +1007 -0
- data/vendor/ring/crypto/ec/util-64.c +183 -0
- data/vendor/ring/crypto/ec/wnaf.c +508 -0
- data/vendor/ring/crypto/ecdh/ecdh.c +155 -0
- data/vendor/ring/crypto/ecdsa/ecdsa.c +304 -0
- data/vendor/ring/crypto/ecdsa/ecdsa_asn1.c +193 -0
- data/vendor/ring/crypto/ecdsa/ecdsa_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/ecdsa/ecdsa_test.cc +327 -0
- data/vendor/ring/crypto/header_removed.h +17 -0
- data/vendor/ring/crypto/internal.h +495 -0
- data/vendor/ring/crypto/libring.Windows.vcxproj +101 -0
- data/vendor/ring/crypto/mem.c +98 -0
- data/vendor/ring/crypto/modes/asm/aesni-gcm-x86_64.pl +1045 -0
- data/vendor/ring/crypto/modes/asm/ghash-armv4.pl +517 -0
- data/vendor/ring/crypto/modes/asm/ghash-x86.pl +1393 -0
- data/vendor/ring/crypto/modes/asm/ghash-x86_64.pl +1741 -0
- data/vendor/ring/crypto/modes/asm/ghashv8-armx.pl +422 -0
- data/vendor/ring/crypto/modes/ctr.c +226 -0
- data/vendor/ring/crypto/modes/gcm.c +1206 -0
- data/vendor/ring/crypto/modes/gcm_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/modes/gcm_test.c +348 -0
- data/vendor/ring/crypto/modes/internal.h +299 -0
- data/vendor/ring/crypto/perlasm/arm-xlate.pl +170 -0
- data/vendor/ring/crypto/perlasm/readme +100 -0
- data/vendor/ring/crypto/perlasm/x86_64-xlate.pl +1164 -0
- data/vendor/ring/crypto/perlasm/x86asm.pl +292 -0
- data/vendor/ring/crypto/perlasm/x86gas.pl +263 -0
- data/vendor/ring/crypto/perlasm/x86masm.pl +200 -0
- data/vendor/ring/crypto/perlasm/x86nasm.pl +187 -0
- data/vendor/ring/crypto/poly1305/poly1305.c +331 -0
- data/vendor/ring/crypto/poly1305/poly1305_arm.c +301 -0
- data/vendor/ring/crypto/poly1305/poly1305_arm_asm.S +2015 -0
- data/vendor/ring/crypto/poly1305/poly1305_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/poly1305/poly1305_test.cc +80 -0
- data/vendor/ring/crypto/poly1305/poly1305_test.txt +52 -0
- data/vendor/ring/crypto/poly1305/poly1305_vec.c +892 -0
- data/vendor/ring/crypto/rand/asm/rdrand-x86_64.pl +75 -0
- data/vendor/ring/crypto/rand/internal.h +32 -0
- data/vendor/ring/crypto/rand/rand.c +189 -0
- data/vendor/ring/crypto/rand/urandom.c +219 -0
- data/vendor/ring/crypto/rand/windows.c +56 -0
- data/vendor/ring/crypto/refcount_c11.c +66 -0
- data/vendor/ring/crypto/refcount_lock.c +53 -0
- data/vendor/ring/crypto/refcount_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/refcount_test.c +58 -0
- data/vendor/ring/crypto/rsa/blinding.c +462 -0
- data/vendor/ring/crypto/rsa/internal.h +108 -0
- data/vendor/ring/crypto/rsa/padding.c +300 -0
- data/vendor/ring/crypto/rsa/rsa.c +450 -0
- data/vendor/ring/crypto/rsa/rsa_asn1.c +261 -0
- data/vendor/ring/crypto/rsa/rsa_impl.c +944 -0
- data/vendor/ring/crypto/rsa/rsa_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/rsa/rsa_test.cc +437 -0
- data/vendor/ring/crypto/sha/asm/sha-armv8.pl +436 -0
- data/vendor/ring/crypto/sha/asm/sha-x86_64.pl +2390 -0
- data/vendor/ring/crypto/sha/asm/sha256-586.pl +1275 -0
- data/vendor/ring/crypto/sha/asm/sha256-armv4.pl +735 -0
- data/vendor/ring/crypto/sha/asm/sha256-armv8.pl +14 -0
- data/vendor/ring/crypto/sha/asm/sha256-x86_64.pl +14 -0
- data/vendor/ring/crypto/sha/asm/sha512-586.pl +911 -0
- data/vendor/ring/crypto/sha/asm/sha512-armv4.pl +666 -0
- data/vendor/ring/crypto/sha/asm/sha512-armv8.pl +14 -0
- data/vendor/ring/crypto/sha/asm/sha512-x86_64.pl +14 -0
- data/vendor/ring/crypto/sha/sha1.c +271 -0
- data/vendor/ring/crypto/sha/sha256.c +204 -0
- data/vendor/ring/crypto/sha/sha512.c +355 -0
- data/vendor/ring/crypto/test/file_test.cc +326 -0
- data/vendor/ring/crypto/test/file_test.h +181 -0
- data/vendor/ring/crypto/test/malloc.cc +150 -0
- data/vendor/ring/crypto/test/scoped_types.h +95 -0
- data/vendor/ring/crypto/test/test.Windows.vcxproj +35 -0
- data/vendor/ring/crypto/test/test_util.cc +46 -0
- data/vendor/ring/crypto/test/test_util.h +41 -0
- data/vendor/ring/crypto/thread_none.c +55 -0
- data/vendor/ring/crypto/thread_pthread.c +165 -0
- data/vendor/ring/crypto/thread_test.Windows.vcxproj +25 -0
- data/vendor/ring/crypto/thread_test.c +200 -0
- data/vendor/ring/crypto/thread_win.c +282 -0
- data/vendor/ring/examples/checkdigest.rs +103 -0
- data/vendor/ring/include/openssl/aes.h +121 -0
- data/vendor/ring/include/openssl/arm_arch.h +129 -0
- data/vendor/ring/include/openssl/base.h +156 -0
- data/vendor/ring/include/openssl/bn.h +794 -0
- data/vendor/ring/include/openssl/buffer.h +18 -0
- data/vendor/ring/include/openssl/bytestring.h +235 -0
- data/vendor/ring/include/openssl/chacha.h +37 -0
- data/vendor/ring/include/openssl/cmac.h +76 -0
- data/vendor/ring/include/openssl/cpu.h +184 -0
- data/vendor/ring/include/openssl/crypto.h +43 -0
- data/vendor/ring/include/openssl/curve25519.h +88 -0
- data/vendor/ring/include/openssl/ec.h +225 -0
- data/vendor/ring/include/openssl/ec_key.h +129 -0
- data/vendor/ring/include/openssl/ecdh.h +110 -0
- data/vendor/ring/include/openssl/ecdsa.h +156 -0
- data/vendor/ring/include/openssl/err.h +201 -0
- data/vendor/ring/include/openssl/mem.h +101 -0
- data/vendor/ring/include/openssl/obj_mac.h +71 -0
- data/vendor/ring/include/openssl/opensslfeatures.h +68 -0
- data/vendor/ring/include/openssl/opensslv.h +18 -0
- data/vendor/ring/include/openssl/ossl_typ.h +18 -0
- data/vendor/ring/include/openssl/poly1305.h +51 -0
- data/vendor/ring/include/openssl/rand.h +70 -0
- data/vendor/ring/include/openssl/rsa.h +399 -0
- data/vendor/ring/include/openssl/thread.h +133 -0
- data/vendor/ring/include/openssl/type_check.h +71 -0
- data/vendor/ring/mk/Common.props +63 -0
- data/vendor/ring/mk/Windows.props +42 -0
- data/vendor/ring/mk/WindowsTest.props +18 -0
- data/vendor/ring/mk/appveyor.bat +62 -0
- data/vendor/ring/mk/bottom_of_makefile.mk +54 -0
- data/vendor/ring/mk/ring.mk +266 -0
- data/vendor/ring/mk/top_of_makefile.mk +214 -0
- data/vendor/ring/mk/travis.sh +40 -0
- data/vendor/ring/mk/update-travis-yml.py +229 -0
- data/vendor/ring/ring.sln +153 -0
- data/vendor/ring/src/aead.rs +682 -0
- data/vendor/ring/src/agreement.rs +248 -0
- data/vendor/ring/src/c.rs +129 -0
- data/vendor/ring/src/constant_time.rs +37 -0
- data/vendor/ring/src/der.rs +96 -0
- data/vendor/ring/src/digest.rs +690 -0
- data/vendor/ring/src/digest_tests.txt +57 -0
- data/vendor/ring/src/ecc.rs +28 -0
- data/vendor/ring/src/ecc_build.rs +279 -0
- data/vendor/ring/src/ecc_curves.rs +117 -0
- data/vendor/ring/src/ed25519_tests.txt +2579 -0
- data/vendor/ring/src/exe_tests.rs +46 -0
- data/vendor/ring/src/ffi.rs +29 -0
- data/vendor/ring/src/file_test.rs +187 -0
- data/vendor/ring/src/hkdf.rs +153 -0
- data/vendor/ring/src/hkdf_tests.txt +59 -0
- data/vendor/ring/src/hmac.rs +414 -0
- data/vendor/ring/src/hmac_tests.txt +97 -0
- data/vendor/ring/src/input.rs +312 -0
- data/vendor/ring/src/lib.rs +41 -0
- data/vendor/ring/src/pbkdf2.rs +265 -0
- data/vendor/ring/src/pbkdf2_tests.txt +113 -0
- data/vendor/ring/src/polyfill.rs +57 -0
- data/vendor/ring/src/rand.rs +28 -0
- data/vendor/ring/src/signature.rs +314 -0
- data/vendor/ring/third-party/NIST/README.md +9 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA1LongMsg.rsp +263 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA1Monte.rsp +309 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA1ShortMsg.rsp +267 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA224LongMsg.rsp +263 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA224Monte.rsp +309 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA224ShortMsg.rsp +267 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA256LongMsg.rsp +263 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA256Monte.rsp +309 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA256ShortMsg.rsp +267 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA384LongMsg.rsp +519 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA384Monte.rsp +309 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA384ShortMsg.rsp +523 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA512LongMsg.rsp +519 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA512Monte.rsp +309 -0
- data/vendor/ring/third-party/NIST/SHAVS/SHA512ShortMsg.rsp +523 -0
- data/vendor/ring/third-party/NIST/sha256sums.txt +1 -0
- metadata +333 -0
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 */
|
|
@@ -0,0 +1,55 @@
|
|
|
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 */
|
|
@@ -0,0 +1,165 @@
|
|
|
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 */
|
|
@@ -0,0 +1,25 @@
|
|
|
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>
|
|
@@ -0,0 +1,200 @@
|
|
|
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
|