From d807db26a403b4de69d7846656362e70f5083428 Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Sun, 19 Nov 2017 17:40:56 +0100 Subject: [PATCH] Create a prototype for OPENSSL_rdtsc Switch to make it return an uint32_t instead of the various different types it returns now. Fixes: #3125 Reviewed-by: Andy Polyakov GH: #4757 --- crypto/armcap.c | 7 ++++--- crypto/sparcv9cap.c | 3 ++- include/internal/cryptlib.h | 4 ++++ test/modes_internal_test.c | 3 ++- test/poly1305_internal_test.c | 4 ++-- test/siphash_internal_test.c | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/crypto/armcap.c b/crypto/armcap.c index b55a71ee78..a1f77fa2fc 100644 --- a/crypto/armcap.c +++ b/crypto/armcap.c @@ -13,6 +13,7 @@ #include #include #include +#include "internal/cryptlib.h" #include "arm_arch.h" @@ -23,7 +24,7 @@ void OPENSSL_cpuid_setup(void) { } -unsigned long OPENSSL_rdtsc(void) +uint32_t OPENSSL_rdtsc(void) { return 0; } @@ -45,9 +46,9 @@ void _armv8_aes_probe(void); void _armv8_sha1_probe(void); void _armv8_sha256_probe(void); void _armv8_pmull_probe(void); -unsigned long _armv7_tick(void); +uint32_t _armv7_tick(void); -unsigned long OPENSSL_rdtsc(void) +uint32_t OPENSSL_rdtsc(void) { if (OPENSSL_armcap_P & ARMV7_TICK) return _armv7_tick(); diff --git a/crypto/sparcv9cap.c b/crypto/sparcv9cap.c index 61d0334ee4..c8c567536b 100644 --- a/crypto/sparcv9cap.c +++ b/crypto/sparcv9cap.c @@ -15,6 +15,7 @@ #include #include #include +#include "internal/cryptlib.h" #include "sparc_arch.h" @@ -98,7 +99,7 @@ unsigned long _sparcv9_random(void); size_t _sparcv9_vis1_instrument_bus(unsigned int *, size_t); size_t _sparcv9_vis1_instrument_bus2(unsigned int *, size_t, size_t); -unsigned long OPENSSL_rdtsc(void) +uint32_t OPENSSL_rdtsc(void) { if (OPENSSL_sparcv9cap_P[0] & SPARCV9_TICK_PRIVILEGED) #if defined(__sun) && defined(__SVR4) diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h index 4280185ab4..25ccdb1001 100644 --- a/include/internal/cryptlib.h +++ b/include/internal/cryptlib.h @@ -94,6 +94,10 @@ FILE *openssl_fopen(const char *filename, const char *mode); void *openssl_fopen(const char *filename, const char *mode); # endif +#ifdef OPENSSL_CPUID_OBJ +uint32_t OPENSSL_rdtsc(); +#endif + #ifdef __cplusplus } #endif diff --git a/test/modes_internal_test.c b/test/modes_internal_test.c index f3e46fed80..6b02fd0148 100644 --- a/test/modes_internal_test.c +++ b/test/modes_internal_test.c @@ -17,6 +17,7 @@ #include "../crypto/modes/modes_lcl.h" #include "testutil.h" #include "internal/nelem.h" +#include "internal/cryptlib.h" typedef struct { size_t size; @@ -889,7 +890,7 @@ static void benchmark_gcm128(const unsigned char *K, size_t Klen, #ifdef OPENSSL_CPUID_OBJ GCM128_CONTEXT ctx; AES_KEY key; - size_t start, gcm_t, ctr_t, OPENSSL_rdtsc(); + uint32_t start, gcm_t, ctr_t; union { u64 u; u8 c[1024]; diff --git a/test/poly1305_internal_test.c b/test/poly1305_internal_test.c index d1d71c92ee..3631f3488a 100644 --- a/test/poly1305_internal_test.c +++ b/test/poly1305_internal_test.c @@ -16,6 +16,7 @@ #include "internal/poly1305.h" #include "../crypto/poly1305/poly1305_local.h" #include "internal/nelem.h" +#include "internal/cryptlib.h" typedef struct { size_t size; @@ -40,8 +41,7 @@ static void benchmark_poly1305() POLY1305 poly1305; unsigned char key[32]; unsigned char buf[8192]; - unsigned long long stopwatch; - unsigned long long OPENSSL_rdtsc(); + uint32_t stopwatch; unsigned int i; memset (buf,0x55,sizeof(buf)); diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index d832aab660..fe207620c7 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -17,6 +17,7 @@ #include "internal/siphash.h" #include "../crypto/siphash/siphash_local.h" #include "internal/nelem.h" +#include "internal/cryptlib.h" static BIO* b_stderr = NULL; static BIO* b_stdout = NULL; @@ -43,8 +44,7 @@ static int benchmark_siphash(void) SIPHASH siphash; unsigned char key[SIPHASH_KEY_SIZE]; unsigned char buf[8192]; - unsigned long long stopwatch; - unsigned long long OPENSSL_rdtsc(); + uint32_t stopwatch; unsigned int i; memset (buf,0x55,sizeof(buf));