[Cryptech-Commits] [sw/stm32] branch js_keywrap updated: Add timing tests for key unwrap.
git at cryptech.is
git at cryptech.is
Thu Aug 16 21:38:24 UTC 2018
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch js_keywrap
in repository sw/stm32.
The following commit(s) were added to refs/heads/js_keywrap by this push:
new a9ef90a Add timing tests for key unwrap.
a9ef90a is described below
commit a9ef90a4cfde26f858460e65805c84cd38b4a285
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Thu Aug 16 17:38:03 2018 -0400
Add timing tests for key unwrap.
---
projects/cli-test/mgmt-keywrap.c | 50 ++++++++++++++++++++++++++++++++--------
1 file changed, 40 insertions(+), 10 deletions(-)
diff --git a/projects/cli-test/mgmt-keywrap.c b/projects/cli-test/mgmt-keywrap.c
index 798206d..1f98658 100644
--- a/projects/cli-test/mgmt-keywrap.c
+++ b/projects/cli-test/mgmt-keywrap.c
@@ -165,10 +165,7 @@ static int cmd_keywrap_test(struct cli_def *cli, const char *command, char *argv
cli_print(cli, "\n2. Test vectors with keywrap core");
if (hal_aes_use_keywrap_core(1) == 0) {
- cli_print(cli, "keywrap core not found");
-#if 0
- return CLI_ERROR;
-#endif
+ cli_print(cli, "keywrap core not found, skipping");
}
else {
run_test(cli, K_128, sizeof(K_128), C_128, sizeof(C_128));
@@ -188,8 +185,8 @@ static int cmd_keywrap_test(struct cli_def *cli, const char *command, char *argv
if (keysize <= 0 || iterations <= 0)
goto usage;
- uint8_t Q[keysize + 8];
- uint8_t C[keysize + 8];
+ uint8_t Q[keysize + 8]; size_t Q_len;
+ uint8_t C[keysize + 8]; size_t C_len;
memset(C, 0, sizeof(C));
if ((err = hal_get_random(NULL, Q, keysize)) != LIBHAL_OK) {
cli_print(cli, "hal_get_random: %s", hal_error_string(err));
@@ -203,10 +200,9 @@ static int cmd_keywrap_test(struct cli_def *cli, const char *command, char *argv
return CLI_ERROR;
}
- cli_print(cli, "\n3. timing with software keywrap");
+ cli_print(cli, "\n3. wrap timing with software keywrap");
hal_aes_use_keywrap_core(0);
- size_t C_len = sizeof(C);
uint32_t start = HAL_GetTick();
for (int i = 0; i < iterations; ++i) {
C_len = sizeof(C);
@@ -220,7 +216,7 @@ static int cmd_keywrap_test(struct cli_def *cli, const char *command, char *argv
cli_print(cli, "%ld.%03lds total, %ld.%03ldms per wrap",
elapsed / 1000, elapsed % 1000, per / 1000, per % 1000);
- cli_print(cli, "\n4. timing with keywrap core");
+ cli_print(cli, "\n4. wrap timing with keywrap core");
if (hal_aes_use_keywrap_core(1) == 0) {
cli_print(cli, "keywrap core not found, skipping");
@@ -240,7 +236,41 @@ static int cmd_keywrap_test(struct cli_def *cli, const char *command, char *argv
elapsed / 1000, elapsed % 1000, per / 1000, per % 1000);
}
- /* XXX measure unwrap timing as well */
+ cli_print(cli, "\n5. unwrap timing with software keywrap");
+
+ hal_aes_use_keywrap_core(0);
+ start = HAL_GetTick();
+ for (int i = 0; i < iterations; ++i) {
+ Q_len = sizeof(Q);
+ if ((err = hal_aes_keyunwrap(NULL, kek, kek_len, C, C_len, Q, &Q_len)) != LIBHAL_OK) {
+ cli_print(cli, "hal_aes_keyunwrap: %s", hal_error_string(err));
+ return CLI_ERROR;
+ }
+ }
+ elapsed = HAL_GetTick() - start;
+ per = 1000 * elapsed / iterations;
+ cli_print(cli, "%ld.%03lds total, %ld.%03ldms per wrap",
+ elapsed / 1000, elapsed % 1000, per / 1000, per % 1000);
+
+ cli_print(cli, "\n6. unwrap timing with keywrap core");
+
+ if (hal_aes_use_keywrap_core(1) == 0) {
+ cli_print(cli, "keywrap core not found, skipping");
+ }
+ else {
+ start = HAL_GetTick();
+ for (int i = 0; i < iterations; ++i) {
+ Q_len = sizeof(Q);
+ if ((err = hal_aes_keyunwrap(NULL, kek, kek_len, C, C_len, Q, &Q_len)) != LIBHAL_OK) {
+ cli_print(cli, "hal_aes_keywrap: %s", hal_error_string(err));
+ return CLI_ERROR;
+ }
+ }
+ elapsed = HAL_GetTick() - start;
+ per = 1000 * elapsed / iterations;
+ cli_print(cli, "%ld.%03lds total, %ld.%03ldms per wrap",
+ elapsed / 1000, elapsed % 1000, per / 1000, per % 1000);
+ }
return CLI_OK;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list