PUB
- Generic public key typePRV
- Generic private key typepublic interface PuttyKeyPairResourceParser<PUB extends PublicKey,PRV extends PrivateKey> extends IdentityResourceLoader<PUB,PRV>, KeyPairResourceParser
KeyPair
from PuTTY's ".ppk" file.
Note(s):
Sample PuTTY file format
PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: rsa-key-20080514 Public-Lines: 4 AAAAB3NzaC1yc2EAAAABJQAAAIEAiPVUpONjGeVrwgRPOqy3Ym6kF/f8bltnmjA2 BMdAtaOpiD8A2ooqtLS5zWYuc0xkW0ogoKvORN+RF4JI+uNUlkxWxnzJM9JLpnvA HrMoVFaQ0cgDMIHtE1Ob1cGAhlNInPCRnGNJpBNcJ/OJye3yt7WqHP4SPCCLb6nL nmBUrLM= Private-Lines: 8 AAAAgGtYgJzpktzyFjBIkSAmgeVdozVhgKmF6WsDMUID9HKwtU8cn83h6h7ug8qA hUWcvVxO201/vViTjWVz9ALph3uMnpJiuQaaNYIGztGJBRsBwmQW9738pUXcsUXZ 79KJP01oHn6Wkrgk26DIOsz04QOBI6C8RumBO4+F1WdfueM9AAAAQQDmA4hcK8Bx nVtEpcF310mKD3nsbJqARdw5NV9kCxPnEsmy7Sy1L4Ob/nTIrynbc3MA9HQVJkUz 7V0va5Pjm/T7AAAAQQCYbnG0UEekwk0LG1Hkxh1OrKMxCw2KWMN8ac3L0LVBg/Tk 8EnB2oT45GGeJaw7KzdoOMFZz0iXLsVLNUjNn2mpAAAAQQCN6SEfWqiNzyc/w5n/ lFVDHExfVUJp0wXv+kzZzylnw4fs00lC3k4PZDSsb+jYCMesnfJjhDgkUA0XPyo8 Emdk Private-MAC: 50c45751d18d74c00fca395deb7b7695e3ed6f77
Modifier and Type | Field and Description |
---|---|
static int |
FORMAT_3_MAC_KEY_LENGTH
PUTTY key v3 MAC key length
|
static String |
KEY_FILE_HEADER_PREFIX |
static List<String> |
KNOWN_HEADERS |
static String |
NO_PRIVATE_KEY_ENCRYPTION_VALUE
Value (case insensitive) used to denote that private key is not encrypted
|
static String |
PPK_FILE_SUFFIX |
static String |
PRIVATE_LINES_HEADER |
static String |
PUBLIC_LINES_HEADER |
MAX_BIGINT_OCTETS_COUNT
EMPTY
MAX_CIPHER_NAME_LENGTH, MAX_KEY_COMMENT_LENGTH, MAX_KEY_TYPE_NAME_LENGTH, MAX_PRIVATE_KEY_DATA_SIZE, MAX_PUBLIC_KEY_DATA_SIZE
Modifier and Type | Method and Description |
---|---|
default boolean |
canExtractKeyPairs(NamedResource resourceKey,
List<String> lines) |
static void |
decodeEncryptionKey(int formatVersion,
String passphrase,
byte[] iv,
byte[] key,
Map<String,String> headers)
Converts a pass-phrase into a key, by following the conventions that PuTTY uses.
|
static byte[] |
decodePrivateKeyBytes(byte[] encBytes,
String cipherName,
String cipherMode,
int numBits,
byte[] initVector,
byte[] keyValue) |
static byte[] |
decodePrivateKeyBytes(int formatVersion,
byte[] prvBytes,
String algName,
int numBits,
String algMode,
String password,
Map<String,String> headers) |
static void |
deriveFormat2EncryptionKey(String passphrase,
byte[] iv,
byte[] key)
Uses the "legacy" KDF via SHA-1
|
static void |
deriveFormat3EncryptionKey(String passphrase,
String keyDerivationType,
byte[] iv,
byte[] key,
Map<String,String> headers) |
static byte[] |
getHexArrayHeaderValue(Map<String,String> headers,
String key) |
static int |
getIntegerHeaderValue(Map<String,String> headers,
String key) |
static String |
getStringHeaderValue(Map<String,String> headers,
String key) |
getPrivateKeyType, getPublicKeyType
findSupporterByKeyTypeName, getSupportedKeyTypes
aggregate, aggregate, containsMarkerLine, containsMarkerLine, extractDataBytes, findMarkerLine, findMarkerLine, joinDataLines
loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs
static final String KEY_FILE_HEADER_PREFIX
static final String PUBLIC_LINES_HEADER
static final String PRIVATE_LINES_HEADER
static final String PPK_FILE_SUFFIX
static final String NO_PRIVATE_KEY_ENCRYPTION_VALUE
static final int FORMAT_3_MAC_KEY_LENGTH
default boolean canExtractKeyPairs(NamedResource resourceKey, List<String> lines) throws IOException, GeneralSecurityException
canExtractKeyPairs
in interface KeyPairResourceParser
resourceKey
- A hint as to the origin of the text lineslines
- The resource linestrue
if the parser can extract some key pairs from the linesIOException
- If failed to process the linesGeneralSecurityException
- If failed to extract information regarding the possibility to extract the key
pairsstatic byte[] decodePrivateKeyBytes(int formatVersion, byte[] prvBytes, String algName, int numBits, String algMode, String password, Map<String,String> headers) throws GeneralSecurityException
GeneralSecurityException
static byte[] decodePrivateKeyBytes(byte[] encBytes, String cipherName, String cipherMode, int numBits, byte[] initVector, byte[] keyValue) throws GeneralSecurityException
GeneralSecurityException
static void decodeEncryptionKey(int formatVersion, String passphrase, byte[] iv, byte[] key, Map<String,String> headers) throws GeneralSecurityException
formatVersion
- The file format versionpassphrase
- The Password to be used as seed for the key - ignored if null
/emptyiv
- Initialization vector to be populated if necessarykey
- Key to be populatedheaders
- Any extra headers found in the PPK file that might be used for KDFGeneralSecurityException
- If cannot derive the key bytes from the passwordstatic void deriveFormat3EncryptionKey(String passphrase, String keyDerivationType, byte[] iv, byte[] key, Map<String,String> headers) throws GeneralSecurityException
GeneralSecurityException
static void deriveFormat2EncryptionKey(String passphrase, byte[] iv, byte[] key) throws GeneralSecurityException
passphrase
- The Password to be used as seed for the key - ignored if null
/emptyiv
- Initialization vector to be populated if necessarykey
- Key to be populatedGeneralSecurityException
- If cannot retrieve SHA-1 digestCopyright © 2008–2024 The Apache Software Foundation. All rights reserved.