#include <openssl/pem.h>
#include <gtest/gtest.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/rsa.h>
TEST(PEMTest, NoRC4) {
static const char kPEM[] =
"-----BEGIN RSA PUBLIC KEY-----\n"
"Proc-Type: 4,ENCRYPTED\n"
"DEK-Info: RC4 -\n"
"extra-info\n"
"router-signature\n"
"\n"
"Z1w=\n"
"-----END RSA PUBLIC KEY-----\n";
bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(kPEM, sizeof(kPEM) - 1));
ASSERT_TRUE(bio);
bssl::UniquePtr<RSA> rsa(PEM_read_bio_RSAPublicKey(
bio.get(), nullptr, nullptr, const_cast<char *>("password")));
EXPECT_FALSE(rsa);
uint32_t err = ERR_get_error();
EXPECT_EQ(ERR_LIB_PEM, ERR_GET_LIB(err));
EXPECT_EQ(PEM_R_UNSUPPORTED_ENCRYPTION, ERR_GET_REASON(err));
}