Created
May 25, 2020 20:55
-
-
Save svolobuev/4489f4735634f5e7f685274b9f8d5b39 to your computer and use it in GitHub Desktop.
ssh.PublicKey cast to rsa.PublicKey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rsa | |
import ( | |
"crypto/rsa" | |
"golang.org/x/crypto/ssh" | |
) | |
func FromSshPublicKey(key ssh.PublicKey) (*rsa.PublicKey, bool) { | |
if cryptoKey, ok := key.(ssh.CryptoPublicKey); ok { | |
rsaKey, ok := cryptoKey.CryptoPublicKey().(*rsa.PublicKey) | |
return rsaKey, ok | |
} | |
return nil, false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment