From 52dee3bad04f9f6b550de22cb2091594bc1c6fe9 Mon Sep 17 00:00:00 2001 From: Johannes Bauer Date: Sat, 19 Oct 2019 11:32:32 +0200 Subject: [PATCH] More tests to show key changes Demonstrating that a new key is chosen on every close operation. --- vault.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/vault.c b/vault.c index 0eb745f..f60ebe1 100644 --- a/vault.c +++ b/vault.c @@ -264,16 +264,18 @@ int main(void) { */ struct vault_t *vault = vault_init(64, 0.1); dump(vault->data, vault->data_length); - if (!vault_close(vault)) { - fprintf(stderr, "vault close failed.\n"); - abort(); + for (int i = 0; i < 10; i++) { + if (!vault_close(vault)) { + fprintf(stderr, "vault close failed.\n"); + abort(); + } + dump(vault->data, vault->data_length); + if (!vault_open(vault)) { + fprintf(stderr, "vault open failed.\n"); + abort(); + } + dump(vault->data, vault->data_length); } - dump(vault->data, vault->data_length); - if (!vault_open(vault)) { - fprintf(stderr, "vault open failed.\n"); - abort(); - } - dump(vault->data, vault->data_length); vault_free(vault); return 0; }