# generate a passphrase protected RSA private key with openssl
System.cmd("openssl", [
"genrsa",
"-out",
rsa_secure_private_key_path,
"-passout",
"pass:#{rand_string}",
"2048"
])
# generate a passphrase protected RSA private key with openssl
System.cmd("openssl", [
"genrsa",
"-aes256",
"-out",
rsa_secure_private_key_path,
"-passout",
"pass:#{rand_string}",
"2048"
])
1) test read secure RSA keys (ExPublicKeyTest)
test/ex_public_key_test.exs:79
** (CaseClauseError) no case clause matching: {:error, %FunctionClauseError{args: nil, arity: 4, clauses: nil, function: :decode, kind: nil, module: :pubkey_pbe}, [{:pubkey_pbe, :decode, [<<43, 180, 39, 134, 179, 160, 115, 204, 207, 162, 100, 17, 226, 84, 197, 254, 3, 10, 68, 212, 144, 49, 120, 150, 239, 201, 223, 214, 213, 157, 39, 151, 17, 109, 42, 106, 193, 217, 176, 117, 244, 187, ...>>, 'KLvk', 'AES-256-CBC', <<246, 36, 62, 81, 225, 191, 64, 102, 55, 197, 38, 121, 69, 244, 140, 46>>], [file: 'pubkey_pbe.erl', line: 59]}, {:public_key, :do_pem_entry_decode, 2, [file: 'public_key.erl', line: 1103]}, {ExPublicKey, :load_pem_entry, 2, [file: 'lib/ex_public_key.ex', line: 128]}, {ExPublicKey, :load_pem_entry, 2, [file: 'lib/ex_public_key.ex', line: 122]}, {ExPublicKey, :loads, 2, [file: 'lib/ex_public_key.ex', line: 94]}, {ExPublicKey, :loads!, 2, [file: 'lib/ex_public_key.ex', line: 107]}, {ExPublicKeyTest, :"test read secure RSA keys", 1, [file: 'test/ex_public_key_test.exs', line: 81]}, {ExUnit.Runner, :exec_test, 1, [file: 'lib/ex_unit/runner.ex', line: 306]}, {:timer, :tc, 1, [file: 'timer.erl', line: 166]}, {ExUnit.Runner, :"-spawn_test/3-fun-1-", 4, [file: 'lib/ex_unit/runner.ex', line: 245]}]}
code: secure_rsa_priv_key = ExPublicKey.loads!(secure_priv_key_string, context[:passphrase])
stacktrace:
(ex_crypto) lib/ex_public_key.ex:107: ExPublicKey.loads!/2
test/ex_public_key_test.exs:81: (test)
if you replace "-aes256" with "-aes128" . test/ex_public_key_test.exs is OK
Hi there,
I've found your very useful Elixir lib but I'm facing with an issue when I'm using AES-256-CBC private keys
Test case that fails:
test/ex_public_key_test.exs
insert at line : 32
"-aes256",
so instead of
we have now
and the test
mix test test/ex_public_key_test.exs:79
fails
if you replace "-aes256" with "-aes128" . test/ex_public_key_test.exs is OK
Any idea?
Many thanks in advance
Daniel