Skip to content

Commit

Permalink
Debug Botan 3.1.1 test failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Feb 12, 2024
1 parent 8c433ee commit 55a2b14
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tests/cipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,4 +1222,12 @@ TEST_F(rnp_tests, test_windows_botan_crash)
assert_int_equal(botan_cipher_reset(cipher), 0);
assert_int_equal(botan_cipher_destroy(cipher), 0);
}

TEST_F(rnp_tests, test_botan_hex_decode)
{
std::string str = "BC6709B15C23A4A";
std::vector<uint8_t> res(str.size() / 2 + 2);
size_t len = rnp::hex_decode(str.c_str(), res.data(), res.size());
res.resize(len);
}
#endif
54 changes: 54 additions & 0 deletions src/tests/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,18 +1461,29 @@ TEST_F(rnp_tests, test_ffi_locate_key)
{
rnp_key_handle_t key = NULL;
assert_rnp_failure(rnp_locate_key(NULL, "keyid", "7BC6709B15C23A4A", &key));
RNP_LOG("1");
assert_rnp_failure(rnp_locate_key(ffi, NULL, "7BC6709B15C23A4A", &key));
RNP_LOG("2");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", NULL, &key));
RNP_LOG("3");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "7BC6709B15C23A4A", NULL));
RNP_LOG("4");
assert_rnp_failure(rnp_locate_key(ffi, "wrong", "7BC6709B15C23A4A", &key));
RNP_LOG("5");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "BC6709B15C23A4A", &key));
RNP_LOG("6");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "C6709B15C23A4A", &key));
RNP_LOG("7");
assert_rnp_failure(
rnp_locate_key(ffi, "fingerprint", "5A3CBF583AA80A2CCC53AA7BC6709B15C23A4A", &key));
RNP_LOG("8");
assert_rnp_failure(
rnp_locate_key(ffi, "grip", "D6A0800A3FACDE0C0EB60B16B3669ED380FDFA", &key));
RNP_LOG("9");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "0x7BC6 709B\r15C2 3A4A\n", &key));
RNP_LOG("10");
assert_rnp_success(rnp_locate_key(ffi, "keyid", "0x7BC6 709B\t15C2 3A4A\t", &key));
RNP_LOG("11");
assert_non_null(key);
rnp_key_handle_destroy(key);
}
Expand Down Expand Up @@ -6037,3 +6048,46 @@ TEST_F(rnp_tests, test_result_to_string)
}
}
}

TEST_F(rnp_tests, test_ffi_wrong_hex_length)
{
rnp_ffi_t ffi = NULL;

// setup FFI
assert_rnp_success(rnp_ffi_create(&ffi, "GPG", "GPG"));
// load our keyrings
assert_true(load_keys_gpg(ffi, "data/keyrings/1/pubring.gpg"));

// edge cases
{
rnp_key_handle_t key = NULL;
assert_rnp_failure(rnp_locate_key(NULL, "keyid", "7BC6709B15C23A4A", &key));
RNP_LOG("1");
assert_rnp_failure(rnp_locate_key(ffi, NULL, "7BC6709B15C23A4A", &key));
RNP_LOG("2");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", NULL, &key));
RNP_LOG("3");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "7BC6709B15C23A4A", NULL));
RNP_LOG("4");
assert_rnp_failure(rnp_locate_key(ffi, "wrong", "7BC6709B15C23A4A", &key));
RNP_LOG("5");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "BC6709B15C23A4A", &key));
RNP_LOG("6");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "C6709B15C23A4A", &key));
RNP_LOG("7");
assert_rnp_failure(
rnp_locate_key(ffi, "fingerprint", "5A3CBF583AA80A2CCC53AA7BC6709B15C23A4A", &key));
RNP_LOG("8");
assert_rnp_failure(
rnp_locate_key(ffi, "grip", "D6A0800A3FACDE0C0EB60B16B3669ED380FDFA", &key));
RNP_LOG("9");
assert_rnp_failure(rnp_locate_key(ffi, "keyid", "0x7BC6 709B\r15C2 3A4A\n", &key));
RNP_LOG("10");
assert_rnp_success(rnp_locate_key(ffi, "keyid", "0x7BC6 709B\t15C2 3A4A\t", &key));
RNP_LOG("11");
assert_non_null(key);
rnp_key_handle_destroy(key);
}

rnp_ffi_destroy(ffi);
}

0 comments on commit 55a2b14

Please sign in to comment.