libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit b0f3bcbfd7c0a3b1db1f160d3f82154e456a730d
parent 0f0116107dedadfcbf870e41eeeaea7407ae9e67
Author: lash <dev@holbrook.no>
Date:   Tue, 15 Apr 2025 23:13:47 +0100

Merge branch 'lash/lockkey-test' into lash/keytests

Diffstat:
Msrc/lq/crypto.h | 2+-
Msrc/test/test_crypto.c | 30++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/lq/crypto.h b/src/lq/crypto.h @@ -93,7 +93,7 @@ enum lq_keystate_e { */ struct lq_privatekey_t { short key_typ; ///< Key type identifier. Unused for now. - char key_state; ///< Key state flags. + unsigned char key_state; ///< Key state flags. void *impl; ///< Private key implementation object }; typedef struct lq_privatekey_t LQPrivKey; diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c @@ -2,6 +2,8 @@ #include <stdlib.h> #include <string.h> +#include <rerr.h> + #include "lq/crypto.h" #include "lq/config.h" #include "lq/io.h" @@ -63,6 +65,33 @@ START_TEST(check_privatekey) { } END_TEST +START_TEST(check_privatekey_lock) { + int r; + LQPrivKey *pk; + + pk = lq_privatekey_new(passphrase, passphrase_len); + ck_assert_ptr_nonnull(pk); + + lq_privatekey_lock(pk, passphrase, passphrase_len); + r = lq_privatekey_lock(pk, passphrase, passphrase_len); + ck_assert_int_eq(r, ERR_NOOP); + + r = lq_privatekey_unlock(pk, passphrase, passphrase_len); + ck_assert_int_eq(r, ERR_OK); + + r = lq_privatekey_unlock(pk, passphrase, passphrase_len); + ck_assert_int_eq(r, ERR_NOOP); + + r = lq_privatekey_lock(pk, passphrase, passphrase_len); + ck_assert_int_eq(r, ERR_OK); + + r = lq_privatekey_lock(pk, passphrase, passphrase_len); + ck_assert_int_eq(r, ERR_NOOP); + + lq_privatekey_free(pk); +} +END_TEST + START_TEST(check_publickey) { int r; char path[LQ_PATH_MAX]; @@ -305,6 +334,7 @@ Suite * common_suite(void) { tc = tcase_create("file"); tcase_add_test(tc, check_digest); tcase_add_test(tc, check_privatekey); + tcase_add_test(tc, check_privatekey_lock); tcase_add_test(tc, check_publickey); tcase_add_test(tc, check_signature); tcase_add_test(tc, check_verify);