jeroen / openssl

OpenSSL bindings for R
Other
64 stars 22 forks source link

Can rsa_keygen and friends take a password argument #16

Closed richfitz closed 8 years ago

richfitz commented 8 years ago

Your openssl::read_key function accepts a string or callback as an argument to unlock a key with a password, perhaps rsa_keygen (and other _keygen functions) could take a similar password argument to generate a password with a phrase?

jeroen commented 8 years ago

The password is added on the level of the pem encoding. To create a password protected key:

library(openssl)
key <- rsa_keygen()
write_pem(key, "mykey.pem", password = "supersecret")

Now if you try to read the key from the pem file you will be asked for the password:

read_key("mykey.pem")
richfitz commented 8 years ago

Oh, thanks! I wondered if I was being dense. Could I suggest you add that to the help file ?rsa_keygen

jeroen commented 8 years ago

Sure, I accept PR's :)

richfitz commented 8 years ago

I'll see what I can do.

jeroen commented 8 years ago

Closed https://github.com/jeroenooms/openssl/commit/dc6e2e3baa69d0d3e8727414ea33c35c33757832. Thanks for the suggestion.