From 35f8edeedc0e42d040e2b5823a300aaa2e3ff13f Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Wed, 20 Apr 2016 01:16:45 +0900 Subject: 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). --- ext/openssl/openssl_missing.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ext/openssl/openssl_missing.c') 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 -- cgit v1.2.3