Skip to content

Commit

Permalink
Add tests for v5 data signatures verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Sep 27, 2023
1 parent c0da658 commit bc33197
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/tests/ffi-enc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,3 +1469,51 @@ TEST_F(rnp_tests, test_ffi_encrypt_no_wrap)
// final cleanup
rnp_ffi_destroy(ffi);
}

TEST_F(rnp_tests, test_ffi_v5_signatures)
{
rnp_ffi_t ffi = NULL;
assert_rnp_success(rnp_ffi_create(&ffi, "GPG", "GPG"));
/* import v5 keys */
assert_true(import_pub_keys(ffi, "data/test_stream_key_load/v5-rsa-pub.asc"));
/* verify v5 attached signature */
rnp_input_t input = NULL;
assert_rnp_success(
rnp_input_from_path(&input, "data/test_messages/message.txt.signed.v5-rsa"));
rnp_output_t output = NULL;
assert_rnp_success(rnp_output_to_null(&output));
rnp_op_verify_t verify = NULL;
assert_rnp_success(rnp_op_verify_create(&verify, ffi, input, output));
assert_rnp_success(rnp_op_verify_execute(verify));
rnp_op_verify_signature_t sig = NULL;
assert_rnp_success(rnp_op_verify_get_signature_at(verify, 0, &sig));
assert_rnp_success(rnp_op_verify_signature_get_status(sig));
rnp_op_verify_destroy(verify);
rnp_input_destroy(input);
rnp_output_destroy(output);
/* verify v5 detached signature */
assert_rnp_success(rnp_input_from_path(&input, "data/test_messages/message.txt"));
rnp_input_t sigin = NULL;
assert_rnp_success(
rnp_input_from_path(&sigin, "data/test_messages/message.txt.signed.v5-detached-rsa"));
assert_rnp_success(rnp_op_verify_detached_create(&verify, ffi, input, sigin));
assert_rnp_success(rnp_op_verify_execute(verify));
assert_rnp_success(rnp_op_verify_get_signature_at(verify, 0, &sig));
assert_rnp_success(rnp_op_verify_signature_get_status(sig));
rnp_op_verify_destroy(verify);
rnp_input_destroy(input);
rnp_input_destroy(sigin);
/* verify cleartext signature */
assert_rnp_success(
rnp_input_from_path(&input, "data/test_messages/message.txt.signed.v5-clear-rsa"));
assert_rnp_success(rnp_output_to_null(&output));
assert_rnp_success(rnp_op_verify_create(&verify, ffi, input, output));
assert_rnp_success(rnp_op_verify_execute(verify));
assert_rnp_success(rnp_op_verify_get_signature_at(verify, 0, &sig));
assert_rnp_success(rnp_op_verify_signature_get_status(sig));
rnp_op_verify_destroy(verify);
rnp_input_destroy(input);
rnp_output_destroy(output);

rnp_ffi_destroy(ffi);
}

0 comments on commit bc33197

Please sign in to comment.