diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-04-20 01:16:45 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-04-27 23:07:40 +0900 |
commit | 35f8edeedc0e42d040e2b5823a300aaa2e3ff13f (patch) | |
tree | bc24606db97e14a1fb7fdc46b01c802e4043d6a3 /ext/openssl/openssl_missing.c | |
parent | 4a4a6f8999594a056ad03451646143016ec9a5d1 (diff) | |
download | ruby-35f8edeedc0e42d040e2b5823a300aaa2e3ff13f.tar.gz |
ext/openssl: always use our implementation of SSL_SESSION_cmp()
Implement CRYPTO_memcmp() if it is not available.
Always use our SSL_SESSION_cmp() (renamed to ossl_SSL_SESSION_cmp()).
SSL_SESSION_cmp() was removed in OpenSSL 1.0.0 and we have used a
reimplemented one. However our implementation is better than the
original (it uses CRYPTO_memcmp() instead of plain memcmp).
Diffstat (limited to 'ext/openssl/openssl_missing.c')
-rw-r--r-- | ext/openssl/openssl_missing.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c index bd8eef5ea9..f9db04fe97 100644 --- a/ext/openssl/openssl_missing.c +++ b/ext/openssl/openssl_missing.c @@ -352,3 +352,21 @@ ASN1_put_eoc(unsigned char **pp) return 2; } #endif + +#if !defined(HAVE_CRYPTO_MEMCMP) +int +CRYPTO_memcmp(const volatile void * volatile in_a, + const volatile void * volatile in_b, + size_t len) +{ + size_t i; + const volatile unsigned char *a = in_a; + const volatile unsigned char *b = in_b; + unsigned char x = 0; + + for (i = 0; i < len; i++) + x |= a[i] ^ b[i]; + + return x; +} +#endif |