Skip to content

Commit e4160a5

Browse files
committed
fixup! pkey/rsa: port RSA#{private,public}_{encrypt,decrypt} to the EVP API
1 parent c6cf478 commit e4160a5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/openssl/pkey.rb

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class RSA
8383
# OpenSSL::PKey#sign_raw and OpenSSL::PKey#verify_raw instead.
8484
def private_encrypt(string, padding = PKCS1_PADDING)
8585
n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
86+
private? or raise OpenSSL::PKey::RSAError, "private key needed."
8687
begin
8788
sign_raw(nil, string, {
8889
"rsa_padding_mode" => translate_padding_mode(padding),
@@ -144,6 +145,7 @@ def public_encrypt(data, padding = PKCS1_PADDING)
144145
# OpenSSL::PKey#encrypt and OpenSSL::PKey#decrypt instead.
145146
def private_decrypt(data, padding = PKCS1_PADDING)
146147
n or raise OpenSSL::PKey::RSAError, "incomplete RSA"
148+
private? or raise OpenSSL::PKey::RSAError, "private key needed."
147149
begin
148150
decrypt(data, {
149151
"rsa_padding_mode" => translate_padding_mode(padding),

0 commit comments

Comments
 (0)