Method: OpenSSL::PKey::RSA#private_decrypt

Defined in:
lib/openssl/pkey.rb

#private_decrypt(data, padding = PKCS1_PADDING) ⇒ Object

:call-seq:

rsa.private_decrypt(string)          -> String
rsa.private_decrypt(string, padding) -> String

Decrypt string, which has been encrypted with the public key, with the private key. padding defaults to PKCS1_PADDING, which is known to be insecure but is kept for backwards compatibility.

Deprecated in version 3.0. Consider using PKey::PKey#encrypt and PKey::PKey#decrypt instead.



439
440
441
442
443
444
445
446
447
448
449
# File 'lib/openssl/pkey.rb', line 439

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),
    })
  rescue OpenSSL::PKey::PKeyError
    raise OpenSSL::PKey::RSAError, $!.message
  end
end