Openssl generating private key

0

I'm trying to generate a private key with passphrase from the command line. For the same pass:: shmicha and the same algo -aes128 i'm getting differents results. It' is normal ? Please help

openssl genrsa -aes128 -passout pass::shmicha -out privkey.pem 2048

Thanks much for the reply! If I understand well, the pass is just a key used to protect the generated key. But I’m still having trouble understanding something. When I display the content of privkey.pem using

`vi privkey.pem` 

what does the lines “Xuj1s……………1mGOYJagDmPhhVwesVw2vL0duTpbriFn/zHO” means.

-----BEGIN RSA PRIVATE KEY-----

Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,8B89A8DEC7D83AB7A4221F8BA46C1028

**Xuj1s17OmgIQEbEukuLVhdCQRppOc74+RVTswqhtE8fkIvHICrmMu05R3W5YJBPF
DvUhmB+0Nz8q6DNCtJ+DmRmSJJ7OLAz+xyUw5SxiUAkSDXzRzXkIiQtXYl4iXPG0
UZrbR/Q5o03azAzP9aGjn2ESWE1OugY7BkjUQ+6lF4JyT8uO8KDDR7cFeQpcOi96
hggL57qaXW21abRyksk0owD72Wsq7npaApfRV5jTINctDZSG287GlzfbHts691f4
3Kb3h3VAMqP/+Q6s57cC1OoN02PPb3WKWg5lT3jJXhebZ5/39Yo38aLVqN/E00Dw
xyWNzQj+1C2mpWJnkZpnReviLsp+fvK9BiBYSDIhoJxlsrMffS1YgFy/6Zc2bgK8
MtLdjhP489lJb2FCzk949FyGF3esgLsuRPJXPV3Br2HwWCWzJhD72vzm5660W7E9
qOHBQXU+jBYbPEex4yOLAlMdVoWDzCmbMvywYs7TwADl+f+XNBw6HLTWaNcSV2Q/
Po6fSpk4pW4fKCk7hDkRPx9bg2BSxhz7EGhha49EAo4SPGKK5jdLw33pgEH8Erv9
b1D/f0WNJOaPeNL9vtqPQw4LDukQMaBcyU78wuDtx7T30sq/98gcak77JlwIFwga
IxtCUaEx8wJMAdYVyzPMUw2GC54oXQjIFC/6Rz1cRgdFZpmRhMAfkefAnA4r/56C
Y2UoZh8y9kbqgAZPivSWV8ErwLASk6gfIDSZcXEHCGx+9Q7ONTa7iaycVo73J3gC
KrJYTL9IzGb/CHTDnOQ9Z8/GYoxTUpqdkZb9+WOdfBkWHb3PoeqU7kdxi7eS5MAy
6TGT4vvziwo00nthhHW33zsv09AGrN8WjEBH3jpSrzi4EDixrtohM0jHfcvnCDTt
SI7IqzqagT6FWUTRNT3qN3Or1UPAf7yxAYNSY6JPE0P9Qp0ibh4bT6Wet6vNpwHt
aMhBKQCyN7awCsOLhOhoMhGjfd+/EUOS6u2yLo6NM5x4RcHPaYHOHOXK6x/jARbj
BGb8BEMhtGf0hbc8SKKIO98Ji9IgWZj+koIJh1WI1i05W22Dmbo2/HdI5qeLZ+ce
Dpxy4ckpmnFlQ6wpf2mOSIXiWkHJnDKCkC55BA96+33QTg7tW7YhIWfu/fxCQz5c
F4Oby/bnej99uMaO6o4rVK6Yxcc/p1ElfGKN6+iGx16hWo7cnmUV8csmXitYOoeV
s8MO85cNhSTZ1xwR+NXoRvEsFBKJV9n7ea/Kd0oidbpCqkORh4nxpH8YgjZWYxzS
hegLs8OlXfcJBiZTCZdtSH0xGn0f9iz+O4hjpRQXK70PYpESTPERE9jZ4h8i0inK
aAprqwJHd9/UN3jm7+K2k6zmlhJtbs5T2Efe8KMnPOTjPZihtG6Zg22H1403vPrM
3Pugv10a7iHa6n0xm5PzMRdE5uDkb80i1QcB2+xVQp5qlyzGa5E6Ll9pQ+GKmvYB
zCyeUedIICRvze6ciTxOCLYzHbv0LARXWzWPdLTzG1YZHC0CfmvgKQNYNc8p15fC
5Qwq2KTs/7BaO7dgihcXC2kUpyg/1mGOYJagDmPhhVwesVw2vL0duTpbriFn/zHO**

-----END RSA PRIVATE KEY-----

user2916111

Posted 2013-10-24T14:04:55.973

Reputation:

The file you listed is PEM formatted. Your RSA private key has been encrypted with a password and then a Base64 encoding has been applied so that the binary can be expressed as human-readable text in PEM format. The “Xuj1s……………mGOYJagDmPhhVwesVw2vL0duTpbriFn/zHO” text is the result of Base64 encoding the binary. – None – 2013-10-25T17:23:59.717

Answers

1

zozo is correct. You are mixing things up. The command you are using in your question generates an RSA private key encrypted with AES128 using the passphrase ":shmicha". To prove this, try to list out the contents of "privkey.pem" with this command:

openssl rsa -in privkey.pem -text

This will prompt you for a passphrase. When you enter ":schmicha", it will list out the contents. Yes, ":" is the first letter of the passphrase. I'm not sure if that was your intention, but that is what you told it to use. If you don't enter that passphrase, it won't list out the private key.

In your comment to zozo's answer, you mention that your key works when you use the command:

openssl enc -aes128 -a -in test -K C2CBF98262F7F9D1D5880279C25AA5E4 -iv 0

You are not even using your RSA key when you use this command. This command is encrypting a file called "test" using aes128 and the key "C2CBF98262F7F9D1D5880279C25AA5E4". This command has nothing to do with the RSA key you generated in your question.

The genrsa command will generate a new and different private key every time. You are just using the same passphrase to encrypt the different keys.

gtrig

Posted 2013-10-24T14:04:55.973

Reputation: 126

1

Yes, is normal. The private key has a random component. The pass must be input when using the key, is not the phrase the key is based on.

zozo

Posted 2013-10-24T14:04:55.973

Reputation: 121

thank you for your response. But normally when i encrypt file with the generated key (explicitly) i don't use the pass. – None – 2013-10-24T15:58:01.453

openssl enc -aes128 - a -in test -K C2CBF98262F7F9D1D5880279C25AA5E4 -iv 0 – None – 2013-10-24T16:00:48.123