X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Fmodes_internal_test.c;h=e0f1adf6af2c94bd579fbc05738126564e987303;hp=6b02fd014861ab8d79305215d01134b376b7bfd6;hb=89b0402822ae03ba102182ce35204e9b4d1d19b5;hpb=d807db26a403b4de69d7846656362e70f5083428 diff --git a/test/modes_internal_test.c b/test/modes_internal_test.c index 6b02fd0148..e0f1adf6af 100644 --- a/test/modes_internal_test.c +++ b/test/modes_internal_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,7 +17,6 @@ #include "../crypto/modes/modes_lcl.h" #include "testutil.h" #include "internal/nelem.h" -#include "internal/cryptlib.h" typedef struct { size_t size; @@ -100,7 +99,7 @@ static const SIZED_DATA aes_cts128_vectors[] = { CTS128_TEST_VECTOR(64), }; -static AES_KEY *cts128_encrypt_key_schedule() +static AES_KEY *cts128_encrypt_key_schedule(void) { static int init_key = 1; static AES_KEY ks; @@ -112,7 +111,7 @@ static AES_KEY *cts128_encrypt_key_schedule() return &ks; } -static AES_KEY *cts128_decrypt_key_schedule() +static AES_KEY *cts128_decrypt_key_schedule(void) { static int init_key = 1; static AES_KEY ks; @@ -884,75 +883,10 @@ static int test_gcm128(int idx) return 1; } -static void benchmark_gcm128(const unsigned char *K, size_t Klen, - const unsigned char *IV, size_t IVlen) -{ -#ifdef OPENSSL_CPUID_OBJ - GCM128_CONTEXT ctx; - AES_KEY key; - uint32_t start, gcm_t, ctr_t; - union { - u64 u; - u8 c[1024]; - } buf; - - AES_set_encrypt_key(K, Klen * 8, &key); - CRYPTO_gcm128_init(&ctx, &key, (block128_f) AES_encrypt); - CRYPTO_gcm128_setiv(&ctx, IV, IVlen); - - CRYPTO_gcm128_encrypt(&ctx, buf.c, buf.c, sizeof(buf)); - start = OPENSSL_rdtsc(); - CRYPTO_gcm128_encrypt(&ctx, buf.c, buf.c, sizeof(buf)); - gcm_t = OPENSSL_rdtsc() - start; - - CRYPTO_ctr128_encrypt(buf.c, buf.c, sizeof(buf), - &key, ctx.Yi.c, ctx.EKi.c, &ctx.mres, - (block128_f) AES_encrypt); - start = OPENSSL_rdtsc(); - CRYPTO_ctr128_encrypt(buf.c, buf.c, sizeof(buf), - &key, ctx.Yi.c, ctx.EKi.c, &ctx.mres, - (block128_f) AES_encrypt); - ctr_t = OPENSSL_rdtsc() - start; - - printf("%.2f-%.2f=%.2f\n", - gcm_t / (double)sizeof(buf), - ctr_t / (double)sizeof(buf), - (gcm_t - ctr_t) / (double)sizeof(buf)); -# ifdef GHASH - { - void (*gcm_ghash_p) (u64 Xi[2], const u128 Htable[16], - const u8 *inp, size_t len) = ctx.ghash; - - GHASH((&ctx), buf.c, sizeof(buf)); - start = OPENSSL_rdtsc(); - for (i = 0; i < 100; ++i) - GHASH((&ctx), buf.c, sizeof(buf)); - gcm_t = OPENSSL_rdtsc() - start; - printf("%.2f\n", gcm_t / (double)sizeof(buf) / (double)i); - } -# endif -#else - fprintf(stderr, - "Benchmarking of modes isn't available on this platform\n"); -#endif -} - int setup_tests(void) { - if (test_has_option("-h")) { - printf("-h\tThis help\n"); - printf("-b\tBenchmark gcm128 in addition to the tests\n"); - return 1; - } - ADD_ALL_TESTS(test_aes_cts128, OSSL_NELEM(aes_cts128_vectors)); ADD_ALL_TESTS(test_aes_cts128_nist, OSSL_NELEM(aes_cts128_vectors)); ADD_ALL_TESTS(test_gcm128, OSSL_NELEM(gcm128_vectors)); return 1; } - -void cleanup_tests(void) -{ - if (test_has_option("-b")) - benchmark_gcm128(K1, sizeof(K1), IV1, sizeof(IV1)); -}