Class PKCS8KeyFile
- java.lang.Object
-
- net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider
-
- net.schmizz.sshj.userauth.keyprovider.PKCS8KeyFile
-
- All Implemented Interfaces:
FileKeyProvider
,KeyProvider
- Direct Known Subclasses:
OpenSSHKeyFile
public class PKCS8KeyFile extends BaseFileKeyProvider
Key File implementation supporting PEM-encoded PKCS8 and PKCS1 formats with or without password-based encryption
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PKCS8KeyFile.ECNamedCurveObjectIdentifier
static class
PKCS8KeyFile.Factory
private static class
PKCS8KeyFile.KeyAlgorithmObjectIdentifier
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
BOUNCY_CASTLE_CLASS
Bouncy Castle class for detecting support of historical OpenSSL password-based decryptionprivate static boolean
HISTORICAL_DECRYPTION_SUPPORTED
protected org.slf4j.Logger
log
-
Fields inherited from class net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider
kp, pwdf, resource, type
-
-
Constructor Summary
Constructors Constructor Description PKCS8KeyFile()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.math.BigInteger
getBigInteger(com.hierynomus.asn1.types.constructed.ASN1Sequence sequence, int index)
private PKCS8KeyFile.ECNamedCurveObjectIdentifier
getEcNamedCurve(java.lang.String objectId)
private java.security.PublicKey
getEcPublicKey(byte[] bitString, java.security.spec.ECParameterSpec ecParameterSpec)
private PKCS8KeyFile.KeyAlgorithmObjectIdentifier
getKeyAlgorithmObjectIdentifier(java.lang.String objectId)
private java.security.spec.PKCS8EncodedKeySpec
getPkcs8DecryptedKeySpec(char[] password, byte[] encoded)
private java.security.KeyPair
getPkcs8KeyPair(byte[] encoded)
private java.security.KeyPair
getPkcs8KeyPair(PKCS8KeyFile.KeyAlgorithmObjectIdentifier objectIdentifier, byte[] privateKeyInfo)
private java.security.PrivateKey
getPkcs8PrivateKey(PKCS8KeyFile.KeyAlgorithmObjectIdentifier objectIdentifier, byte[] privateKeyInfo)
private static boolean
isHistoricalDecryptionSupported()
private java.security.KeyPair
readDsaKeyPair(byte[] pemKeyBody)
private java.security.KeyPair
readEcKeyPair(byte[] pemKeyBody)
private java.security.KeyPair
readEncryptedPkcs8KeyPair(byte[] pemKeyBody)
protected java.security.KeyPair
readKeyPair()
private java.security.KeyPair
readKeyPair(PEMKey pemKey)
private java.security.KeyPair
readRsaKeyPair(byte[] pemKeyBody)
java.lang.String
toString()
-
-
-
Field Detail
-
BOUNCY_CASTLE_CLASS
private static final java.lang.String BOUNCY_CASTLE_CLASS
Bouncy Castle class for detecting support of historical OpenSSL password-based decryption- See Also:
- Constant Field Values
-
HISTORICAL_DECRYPTION_SUPPORTED
private static final boolean HISTORICAL_DECRYPTION_SUPPORTED
-
log
protected final org.slf4j.Logger log
-
-
Method Detail
-
readKeyPair
protected java.security.KeyPair readKeyPair() throws java.io.IOException
- Specified by:
readKeyPair
in classBaseFileKeyProvider
- Throws:
java.io.IOException
-
readKeyPair
private java.security.KeyPair readKeyPair(PEMKey pemKey) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
readDsaKeyPair
private java.security.KeyPair readDsaKeyPair(byte[] pemKeyBody) throws java.io.IOException
- Throws:
java.io.IOException
-
readRsaKeyPair
private java.security.KeyPair readRsaKeyPair(byte[] pemKeyBody) throws java.io.IOException
- Throws:
java.io.IOException
-
readEcKeyPair
private java.security.KeyPair readEcKeyPair(byte[] pemKeyBody) throws java.io.IOException
- Throws:
java.io.IOException
-
getEcNamedCurve
private PKCS8KeyFile.ECNamedCurveObjectIdentifier getEcNamedCurve(java.lang.String objectId)
-
readEncryptedPkcs8KeyPair
private java.security.KeyPair readEncryptedPkcs8KeyPair(byte[] pemKeyBody) throws java.io.IOException
- Throws:
java.io.IOException
-
getPkcs8DecryptedKeySpec
private java.security.spec.PKCS8EncodedKeySpec getPkcs8DecryptedKeySpec(char[] password, byte[] encoded) throws java.io.IOException, java.security.GeneralSecurityException
- Throws:
java.io.IOException
java.security.GeneralSecurityException
-
getPkcs8KeyPair
private java.security.KeyPair getPkcs8KeyPair(byte[] encoded) throws java.io.IOException
- Throws:
java.io.IOException
-
getPkcs8KeyPair
private java.security.KeyPair getPkcs8KeyPair(PKCS8KeyFile.KeyAlgorithmObjectIdentifier objectIdentifier, byte[] privateKeyInfo) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
getPkcs8PrivateKey
private java.security.PrivateKey getPkcs8PrivateKey(PKCS8KeyFile.KeyAlgorithmObjectIdentifier objectIdentifier, byte[] privateKeyInfo) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
getEcPublicKey
private java.security.PublicKey getEcPublicKey(byte[] bitString, java.security.spec.ECParameterSpec ecParameterSpec) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
getKeyAlgorithmObjectIdentifier
private PKCS8KeyFile.KeyAlgorithmObjectIdentifier getKeyAlgorithmObjectIdentifier(java.lang.String objectId)
-
getBigInteger
private java.math.BigInteger getBigInteger(com.hierynomus.asn1.types.constructed.ASN1Sequence sequence, int index)
-
isHistoricalDecryptionSupported
private static boolean isHistoricalDecryptionSupported()
-
-