Skip to content

Commit

Permalink
Add test to make sure that secret key is not locked back during signa…
Browse files Browse the repository at this point in the history
…ture import.
  • Loading branch information
ni4 committed Feb 16, 2020
1 parent 6b2f7ed commit 27b3a5e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/tests/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6854,3 +6854,34 @@ TEST_F(rnp_tests, test_ffi_export_revocation)

assert_rnp_success(rnp_ffi_destroy(ffi));
}

TEST_F(rnp_tests, test_ffi_secret_sig_import)
{
rnp_ffi_t ffi = NULL;
rnp_input_t input = NULL;

assert_rnp_success(rnp_ffi_create(&ffi, "GPG", "GPG"));
assert_rnp_success(rnp_input_from_path(&input, "data/test_key_validity/alice-sec.asc"));
assert_rnp_success(rnp_import_keys(ffi, input, RNP_LOAD_SAVE_SECRET_KEYS, NULL));
assert_rnp_success(rnp_input_destroy(input));

rnp_key_handle_t key_handle = NULL;
assert_rnp_success(rnp_locate_key(ffi, "userid", "Alice <alice@rnp>", &key_handle));
bool locked = false;
/* unlock secret key */
assert_rnp_success(rnp_key_is_locked(key_handle, &locked));
assert_true(locked);
assert_rnp_success(rnp_key_unlock(key_handle, "password"));
assert_rnp_success(rnp_key_is_locked(key_handle, &locked));
assert_false(locked);
/* import revocation signature */
assert_rnp_success(rnp_input_from_path(&input, "data/test_key_validity/alice-rev.pgp"));
assert_rnp_success(rnp_import_signatures(ffi, input, 0, NULL));
assert_rnp_success(rnp_input_destroy(input));

/* make sure that key is still unlocked */
assert_rnp_success(rnp_key_is_locked(key_handle, &locked));
assert_false(locked);
assert_rnp_success(rnp_key_handle_destroy(key_handle));
assert_rnp_success(rnp_ffi_destroy(ffi));
}
2 changes: 2 additions & 0 deletions src/tests/rnp_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ void test_ffi_import_signatures(void **state);

void test_ffi_export_revocation(void **state);

void test_ffi_secret_sig_import(void **state);

void test_dsa_roundtrip(void **state);

void test_dsa_verify_negative(void **state);
Expand Down

0 comments on commit 27b3a5e

Please sign in to comment.