Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4622

In Ruby's OpenSSL::PKey::RSA class, what does .to_s (aka .export) use as an initialization vector when it encrypts the private key?

$
0
0

This code returns an encrypted private key:

require 'openssl'rsa_key_pair = OpenSSL::PKey::RSA.new(2048)public_key = rsa_key_pair.public_keycipher = OpenSSL::Cipher::AES256.new(:CBC)password = "Password12@"private_key = rsa_key_pair.to_s(cipher, password)

Normally, when you use OpenSSL::Cipher::AES256 you have to provide the algorithm with both a key/password and an initialization vector, but private_key = rsa_key_pair.to_s(cipher, password) doesn't take an iv as an argument. What does it use as the iv, and/or what method can I use to decrypt the private key?


Viewing all articles
Browse latest Browse all 4622


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>