@Beta public class SshKeys extends Object
Constructor and Description |
---|
SshKeys() |
Modifier and Type | Method and Description |
---|---|
static String |
encodeAsOpenSSH(RSAPublicKey key) |
static String |
encodeAsPem(RSAPrivateKey key) |
static String |
fingerprint(BigInteger publicExponent,
BigInteger modulus)
Create a fingerprint per the following spec
|
static String |
fingerprintPrivateKey(String privateKeyPEM) |
static String |
fingerprintPublicKey(String publicKeyOpenSSH) |
static Map<String,String> |
generate()
return a "public" -> rsa public key, "private" -> its corresponding private key
|
static Map<String,String> |
generate(KeyPairGenerator generator,
SecureRandom rand) |
static KeyPair |
generateRsaKeyPair(KeyPairGenerator generator,
SecureRandom rand) |
static byte[] |
keyBlob(BigInteger publicExponent,
BigInteger modulus) |
static boolean |
privateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey,
String fingerprint) |
static boolean |
privateKeyHasFingerprint(String privateKeyPEM,
String fingerprint) |
static boolean |
privateKeyHasSha1(RSAPrivateCrtKeySpec privateKey,
String fingerprint) |
static boolean |
privateKeyHasSha1(String privateKeyPEM,
String sha1HexColonDelimited) |
static boolean |
privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey,
RSAPublicKeySpec publicKey) |
static boolean |
privateKeyMatchesPublicKey(String privateKeyPEM,
String publicKeyOpenSSH) |
static boolean |
publicKeyHasFingerprint(RSAPublicKeySpec publicKey,
String fingerprint) |
static boolean |
publicKeyHasFingerprint(String publicKeyOpenSSH,
String fingerprint) |
static RSAPublicKeySpec |
publicKeySpecFromOpenSSH(com.google.common.io.InputSupplier<? extends InputStream> supplier)
Returns
RSAPublicKeySpec which was OpenSSH Base64 Encoded id_rsa.pub |
static RSAPublicKeySpec |
publicKeySpecFromOpenSSH(String idRsaPub)
Executes
Pems#publicKeySpecFromOpenSSH(InputSupplier) on the string which was OpenSSH
Base64 Encoded id_rsa.pub |
static String |
sha1(RSAPrivateCrtKeySpec privateKey)
Create a SHA-1 digest of the DER encoded private key.
|
static String |
sha1PrivateKey(String privateKeyPEM) |
public static RSAPublicKeySpec publicKeySpecFromOpenSSH(String idRsaPub)
Pems#publicKeySpecFromOpenSSH(InputSupplier)
on the string which was OpenSSH
Base64 Encoded id_rsa.pub
idRsaPub
- formatted ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB...
Pems#publicKeySpecFromOpenSSH(InputSupplier)
public static RSAPublicKeySpec publicKeySpecFromOpenSSH(com.google.common.io.InputSupplier<? extends InputStream> supplier) throws IOException
RSAPublicKeySpec
which was OpenSSH Base64 Encoded id_rsa.pub
supplier
- the input stream factory, formatted ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB...
RSAPublicKeySpec
which was OpenSSH Base64 Encoded id_rsa.pub
IOException
- if an I/O error occurspublic static KeyPair generateRsaKeyPair(KeyPairGenerator generator, SecureRandom rand)
generator
- to generate RSA key pairsrand
- for initializing generator
Crypto.rsaKeyPairGenerator()
public static Map<String,String> generate()
public static Map<String,String> generate(KeyPairGenerator generator, SecureRandom rand)
public static String encodeAsOpenSSH(RSAPublicKey key)
public static String encodeAsPem(RSAPrivateKey key)
public static boolean privateKeyMatchesPublicKey(String privateKeyPEM, String publicKeyOpenSSH)
privateKeyPEM
- RSA private key in PEM formatpublicKeyOpenSSH
- RSA public key in OpenSSH formatpublic static boolean privateKeyMatchesPublicKey(RSAPrivateCrtKeySpec privateKey, RSAPublicKeySpec publicKey)
public static boolean privateKeyHasFingerprint(RSAPrivateCrtKeySpec privateKey, String fingerprint)
public static boolean privateKeyHasFingerprint(String privateKeyPEM, String fingerprint)
privateKeyPEM
- RSA private key in PEM formatfingerprint
- ex. 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static String fingerprintPrivateKey(String privateKeyPEM)
privateKeyPEM
- RSA private key in PEM format2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static String fingerprintPublicKey(String publicKeyOpenSSH)
publicKeyOpenSSH
- RSA public key in OpenSSH format2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static boolean privateKeyHasSha1(RSAPrivateCrtKeySpec privateKey, String fingerprint)
public static boolean privateKeyHasSha1(String privateKeyPEM, String sha1HexColonDelimited)
privateKeyPEM
- RSA private key in PEM formatsha1HexColonDelimited
- ex. 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static String sha1PrivateKey(String privateKeyPEM)
privateKeyPEM
- RSA private key in PEM format2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static String sha1(RSAPrivateCrtKeySpec privateKey)
publicExponent
- modulus
- 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static boolean publicKeyHasFingerprint(RSAPublicKeySpec publicKey, String fingerprint)
public static boolean publicKeyHasFingerprint(String publicKeyOpenSSH, String fingerprint)
publicKeyOpenSSH
- RSA public key in OpenSSH formatfingerprint
- ex. 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static String fingerprint(BigInteger publicExponent, BigInteger modulus)
publicExponent
- modulus
- 2b:a9:62:95:5b:8b:1d:61:e0:92:f7:03:10:e9:db:d9
public static byte[] keyBlob(BigInteger publicExponent, BigInteger modulus)
Copyright © 2009-2013 jclouds. All Rights Reserved.