Fix call to PEM_read_bio_RSAPublicKey.

GitOrigin-RevId: 099e4b08a21f1d6788751222f7c98a6ab696eb49
This commit is contained in:
levlam 2018-10-27 02:51:27 +03:00
parent b9cbd43e96
commit 8de6d7484f

View File

@ -48,18 +48,14 @@ Result<RSA> RSA::from_pem(Slice pem) {
BIO_free(bio); BIO_free(bio);
}; };
auto *rsa = RSA_new(); auto rsa = PEM_read_bio_RSAPublicKey(bio, nullptr, nullptr, nullptr);
if (rsa == nullptr) { if (rsa == nullptr) {
return Status::Error("Cannot create RSA"); return Status::Error("Error while reading rsa pubkey");
} }
SCOPE_EXIT { SCOPE_EXIT {
RSA_free(rsa); RSA_free(rsa);
}; };
if (!PEM_read_bio_RSAPublicKey(bio, &rsa, nullptr, nullptr)) {
return Status::Error("Error while reading rsa pubkey");
}
if (RSA_size(rsa) != 256) { if (RSA_size(rsa) != 256) {
return Status::Error("RSA_size != 256"); return Status::Error("RSA_size != 256");
} }