Skip to content

Commit

Permalink
Fix broken tests(time-machine)
Browse files Browse the repository at this point in the history
  • Loading branch information
desvxx committed Sep 23, 2024
1 parent 7ec1224 commit 397675d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/tests/ffi-enc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ TEST_F(rnp_tests, test_ffi_encrypt_pass)
assert_rnp_failure(rnp_op_encrypt_add_password(op, "pass1", "WRONG", 0, NULL));
assert_rnp_failure(rnp_op_encrypt_add_password(op, "pass1", NULL, 0, "WRONG"));
assert_rnp_success(rnp_op_encrypt_add_password(op, "pass1", NULL, 0, NULL));

// Allow insecure ciphers
if (blowfish_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "BLOWFISH", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
}
if (cast5_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "CAST5", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
}

// add password
if (!sm2_enabled() && !twofish_enabled()) {
assert_rnp_failure(rnp_op_encrypt_add_password(op, "pass2", "SM3", 12345, "TWOFISH"));
Expand Down Expand Up @@ -624,6 +635,10 @@ TEST_F(rnp_tests, test_ffi_encrypt_pk)
key = NULL;
// set the data encryption cipher
if (cast5_enabled()) {
if (cast5_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "CAST5", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
}
assert_rnp_success(rnp_op_encrypt_set_cipher(op, "CAST5"));
} else {
assert_rnp_failure(rnp_op_encrypt_set_cipher(op, "CAST5"));
Expand Down Expand Up @@ -1184,6 +1199,10 @@ TEST_F(rnp_tests, test_ffi_encrypt_pk_key_provider)
key = NULL;
// set the data encryption cipher
if (cast5_enabled()) {
if (cast5_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "CAST5", 0, RNP_SECURITY_REMOVE_ALL, 0, NULL));
}
assert_rnp_success(rnp_op_encrypt_set_cipher(op, "CAST5"));
} else {
assert_rnp_failure(rnp_op_encrypt_set_cipher(op, "CAST5"));
Expand Down Expand Up @@ -1293,6 +1312,10 @@ TEST_F(rnp_tests, test_ffi_encrypt_and_sign)
key = NULL;
// set the data encryption cipher
if (cast5_enabled()) {
if (cast5_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "CAST5", 0, RNP_SECURITY_REMOVE_ALL, 0, NULL));
}
assert_rnp_success(rnp_op_encrypt_set_cipher(op, "CAST5"));
} else {
assert_rnp_failure(rnp_op_encrypt_set_cipher(op, "CAST5"));
Expand Down
21 changes: 21 additions & 0 deletions src/tests/generatekey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,26 @@ cipher_supported(const std::string &cipher)
return true;
}

static void
enable_insecure_ciphers(rnp_ffi_t ffi)
{
// Allow insecure ciphers
if (cast5_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "CAST5", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
}
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "TRIPLEDES", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
if (idea_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "IDEA", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
}
if (blowfish_enabled()) {
assert_rnp_success(rnp_remove_security_rule(
ffi, RNP_FEATURE_SYMM_ALG, "BLOWFISH", 0, RNP_SECURITY_REMOVE_ALL, 0, nullptr));
}
}

TEST_F(rnp_tests, rnpkeys_generatekey_testEncryption)
{
const char *cipherAlg[] = {
Expand All @@ -264,6 +284,7 @@ TEST_F(rnp_tests, rnpkeys_generatekey_testEncryption)
for (unsigned int armored = 0; armored <= 1; ++armored) {
/* Set up rnp and encrypt the dataa */
assert_true(setup_cli_rnp_common(&rnp, RNP_KEYSTORE_GPG, NULL, NULL));
enable_insecure_ciphers(rnp.ffi);
/* Load keyring */
assert_true(rnp.load_keyrings(false));
size_t seccount = 0;
Expand Down

0 comments on commit 397675d

Please sign in to comment.