From eda207f0a3d571a774039d772bff40131ff218d6 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Tue, 18 Feb 2020 19:36:58 -0500 Subject: timing tests for RSA signing --- ks.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'ks.c') diff --git a/ks.c b/ks.c index a682cd2..0e6b4ec 100644 --- a/ks.c +++ b/ks.c @@ -3,7 +3,9 @@ * ---- * Keystore, generic parts anyway. This is internal within libhal. * - * Copyright (c) 2015-2017, NORDUnet A/S All rights reserved. + * Copyright (c) 2015-2018, NORDUnet A/S All rights reserved. + * Copyright: 2020, The Commons Conservancy Cryptech Project + * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -15,9 +17,9 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * - Neither the name of the NORDUnet nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. + * - Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -39,6 +41,13 @@ #include "hal_internal.h" #include "ks.h" +#ifdef DO_TIMING +#include "stm-dwt.h" +#else +#define DWT_start(x) +#define DWT_stop(x) +#endif + /* * PIN block gets the all-zeros UUID, which will never be returned by * the UUID generation code (by definition -- it's not a version 4 UUID). @@ -667,8 +676,13 @@ hal_error_t hal_ks_fetch(hal_ks_t *ks, *der_len = der_max; - if ((err = hal_mkm_get_kek(kek, &kek_len, sizeof(kek))) == HAL_OK) + DWT_start(DWT_hal_mkm_get_kek); + if ((err = hal_mkm_get_kek(kek, &kek_len, sizeof(kek))) == HAL_OK) { + DWT_stop(DWT_hal_mkm_get_kek); + DWT_start(DWT_hal_aes_keyunwrap); err = hal_aes_keyunwrap(NULL, kek, kek_len, der, k_der_len, der, der_len); + DWT_stop(DWT_hal_aes_keyunwrap); + } memset(kek, 0, sizeof(kek)); } -- cgit v1.2.3