crypto data types

97 views
Skip to first unread message

R Srinivasan

unread,
Jan 13, 2020, 11:57:49 AM1/13/20
to golang-nuts
friends 

looking for guidance on how to get an rsa.PublicKey from id_rsa.pub

seems like I can parse the id_rsa.pub contents and get a ssh.PublicKey but how do I transform this into an rsa.PublicKey

i need the coersion in order to use other support services.

thanks for any pointers, srini

a2800276

unread,
Jan 14, 2020, 8:43:29 AM1/14/20
to golang-nuts

looking for guidance on how to get an rsa.PublicKey from id_rsa.pub
seems like I can parse the id_rsa.pub contents and get a ssh.PublicKey but how do I transform this into an rsa.PublicKey
i need the coersion in order to use other support services.


Please consider whether this is really what you need to be doing. If you're being provided with a id_rsa.pub file (presumably from a .ssh configuration directory) you will very likely be performing ssh operations, which are ideally left up to the ssh library to perform. 

If you have a very exotic usecase an know what you are doing, the ssh package uses the crypto.rsa package internally to parse the ssh keyfiles, so just have a look at the implementation there: https://github.com/golang/crypto/blob/master/ssh/keys.go#L262

Good Luck! 

R Srinivasan

unread,
Jan 14, 2020, 4:37:08 PM1/14/20
to golang-nuts
Indeed. My search yielded:


which had exactly what I needed (and should probably be included in the standard ssh package)

The use case itself - a digital signature facility in our Over The Network software upgrade procedure. 

The following is a go rewrite of the tool (from my previous project) :


thanks, srini
Reply all
Reply to author
Forward
0 new messages