diff --git a/src/librepgp/stream-key.cpp b/src/librepgp/stream-key.cpp index 6fb61d0e5..1eab0e121 100644 --- a/src/librepgp/stream-key.cpp +++ b/src/librepgp/stream-key.cpp @@ -792,6 +792,7 @@ decrypt_secret_key(pgp_key_pkt_t *key, const char *password) FALLTHROUGH_STATEMENT; #endif case PGP_V4: + case PGP_V5: pgp_cipher_cfb_decrypt(&crypt, decdata.data(), key->sec_data, key->sec_len); ret = RNP_SUCCESS; break; diff --git a/src/tests/ffi-key.cpp b/src/tests/ffi-key.cpp index bf2bfcacf..0a644e297 100644 --- a/src/tests/ffi-key.cpp +++ b/src/tests/ffi-key.cpp @@ -4701,3 +4701,23 @@ TEST_F(rnp_tests, test_v5_keys_g23) rnp_ffi_destroy(ffi); } + +TEST_F(rnp_tests, test_v5_sec_keys) +{ + rnp_ffi_t ffi = NULL; + assert_rnp_success(rnp_ffi_create(&ffi, "GPG", "GPG")); + /* v5 rsa-rsa secret key */ + assert_true(import_sec_keys(ffi, "data/test_stream_key_load/v5-rsa-sec.asc")); + rnp_key_handle_t key = NULL; + assert_rnp_success(rnp_locate_key(ffi, "keyid", "b856a4197113d431", &key)); + assert_rnp_success(rnp_key_unlock(key, "password")); + assert_rnp_success(rnp_key_lock(key)); + rnp_key_handle_destroy(key); + /* v5 rsa secret subkey */ + assert_rnp_success(rnp_locate_key(ffi, "keyid", "2d400055b0345c33", &key)); + assert_rnp_success(rnp_key_unlock(key, "password")); + assert_rnp_success(rnp_key_lock(key)); + rnp_key_handle_destroy(key); + + rnp_ffi_destroy(ffi); +}