Maybe this works?
% openssl rsa -text -noout < id_rsa
Private-Key: (2048 bit)
modulus:
00:ad:03: ...
...
publicExponent: 35 (0x23)
privateExponent:
94:12:aa: ...
Вопрос
In order to perform asymmetric encryption Common's Lisp Ironclad library requires the key to be initialized with the exponent and modulus. Given that I probably don't want to generate the keys myself, so standing on the shoulder of the giants of OpenSSL for key generation I do
ssh-keygen -t rsa -C "foo@bar.com"
Inspecting the fils generated file I see it is a in the PEM format.
file ~/.id_rsa
=> ~/.ssh/id_rsa: PEM RSA private key
Following some other SO questions I get this
openssl asn1parse -i -in ~/.ssh/id_rsa
0:d=0 hl=4 l=1187 cons: SEQUENCE
4:d=1 hl=2 l= 1 prim: INTEGER :00
7:d=1 hl=4 l= 257 prim: INTEGER :BBFB9E...
268:d=1 hl=2 l= 3 prim: INTEGER :010001
273:d=1 hl=4 l= 256 prim: INTEGER :769BE9...
533:d=1 hl=3 l= 129 prim: INTEGER :ECCB14004...
665:d=1 hl=3 l= 129 prim: INTEGER :CB3B02...
797:d=1 hl=3 l= 128 prim: INTEGER :78054EF...
928:d=1 hl=3 l= 128 prim: INTEGER :0D474BC43....
1059:d=1 hl=3 l= 129 prim: INTEGER :D71D75FF....
Now from there some posts say do add the option -strparse 19 (others 18) to get the exponent and modulus. That is where I get an error in the following lines:
openssl asn1parse -i -in ~/.ssh/id_rsa -strparse 19
Error parsing structure
140334635108032:error:0D07209B:asn1 encoding routines:ASN1_get_object:too long:asn1_lib.c:142:
140334635108032:error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header:tasn_dec.c:1306:
140334635108032:error:0D06A03A:asn1 encoding routines:ASN1_COLLECT:nested asn1 error:tasn_dec.c:1190:
So it may be that the PEM is not in an asn1parse format. I've also tried with -inform DER. So the question is how do I go from generating a key to obtaining the modulus and exponent from the PEM Certificate.
Решение
Maybe this works?
% openssl rsa -text -noout < id_rsa
Private-Key: (2048 bit)
modulus:
00:ad:03: ...
...
publicExponent: 35 (0x23)
privateExponent:
94:12:aa: ...