Skip to content

Commit

Permalink
fixup! pkey/rsa: port RSA#{private,public}_{encrypt,decrypt} to the E…
Browse files Browse the repository at this point in the history
…VP API
  • Loading branch information
rhenium committed Jul 10, 2020
1 parent c6cf478 commit e4160a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/openssl/pkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class RSA
# OpenSSL::PKey#sign_raw and OpenSSL::PKey#verify_raw instead.
def private_encrypt(string, padding = PKCS1_PADDING)
n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
private? or raise OpenSSL::PKey::RSAError, "private key needed."
begin
sign_raw(nil, string, {
"rsa_padding_mode" => translate_padding_mode(padding),
Expand Down Expand Up @@ -144,6 +145,7 @@ def public_encrypt(data, padding = PKCS1_PADDING)
# OpenSSL::PKey#encrypt and OpenSSL::PKey#decrypt instead.
def private_decrypt(data, padding = PKCS1_PADDING)
n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
private? or raise OpenSSL::PKey::RSAError, "private key needed."
begin
decrypt(data, {
"rsa_padding_mode" => translate_padding_mode(padding),
Expand Down

0 comments on commit e4160a5

Please sign in to comment.