Class GenericOpenSSHEd25519PrivateKeyEntryDecoder<PUB extends java.security.PublicKey,PRV extends java.security.PrivateKey>
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.config.keys.impl.AbstractIdentityResourceLoader<PUB,PRV>
-
- org.apache.sshd.common.config.keys.impl.AbstractKeyEntryResolver<PUB,PRV>
-
- org.apache.sshd.common.config.keys.impl.AbstractPrivateKeyEntryDecoder<PUB,PRV>
-
- org.apache.sshd.common.util.security.eddsa.generic.GenericOpenSSHEd25519PrivateKeyEntryDecoder<PUB,PRV>
-
- All Implemented Interfaces:
IdentityResourceLoader<PUB,PRV>,KeyEntryResolver<PUB,PRV>,KeyTypeNamesSupport,PrivateKeyEntryDecoder<PUB,PRV>,PrivateKeyEntryResolver
- Direct Known Subclasses:
OpenSSHEd25519PrivateKeyEntryDecoder
public class GenericOpenSSHEd25519PrivateKeyEntryDecoder<PUB extends java.security.PublicKey,PRV extends java.security.PrivateKey> extends AbstractPrivateKeyEntryDecoder<PUB,PRV>
-
-
Field Summary
Fields Modifier and Type Field Description protected EdDSASupport<PUB,PRV>edDSASupportprivate static intKEYPAIR_SIZEprivate static intPK_SIZEprivate static intSK_SIZE-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.config.keys.IdentityResourceLoader
MAX_BIGINT_OCTETS_COUNT
-
Fields inherited from interface org.apache.sshd.common.config.keys.PrivateKeyEntryResolver
FAILING, IGNORING
-
-
Constructor Summary
Constructors Constructor Description GenericOpenSSHEd25519PrivateKeyEntryDecoder(java.lang.Class<PUB> pubType, java.lang.Class<PRV> prvType, EdDSASupport<PUB,PRV> edDSASupport)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PRVclonePrivateKey(PRV key)PUBclonePublicKey(PUB key)PRVdecodePrivateKey(SessionContext session, java.lang.String keyType, FilePasswordProvider passwordProvider, java.io.InputStream keyData)java.lang.StringencodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey)Encodes thePrivateKeyusing theOpenSSHformat - same one used by thedecodePublicKeymethod(s)java.security.KeyFactorygetKeyFactoryInstance()java.security.KeyPairGeneratorgetKeyPairGenerator()booleanisPublicKeyRecoverySupported()PUBrecoverPublicKey(PRV prvKey)Attempts to recover the public key given the private one-
Methods inherited from class org.apache.sshd.common.config.keys.impl.AbstractKeyEntryResolver
generatePrivateKey, generatePublicKey, toString
-
Methods inherited from class org.apache.sshd.common.config.keys.impl.AbstractIdentityResourceLoader
getPrivateKeyType, getPublicKeyType, getSupportedKeyTypes
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.config.keys.IdentityResourceLoader
getPrivateKeyType, getPublicKeyType
-
Methods inherited from interface org.apache.sshd.common.config.keys.KeyEntryResolver
cloneKeyPair, generateKeyPair
-
Methods inherited from interface org.apache.sshd.common.config.keys.KeyTypeNamesSupport
getSupportedKeyTypes
-
Methods inherited from interface org.apache.sshd.common.config.keys.PrivateKeyEntryDecoder
decodePrivateKey, decodePrivateKey, decodePrivateKey, resolve
-
-
-
-
Field Detail
-
PK_SIZE
private static final int PK_SIZE
- See Also:
- Constant Field Values
-
SK_SIZE
private static final int SK_SIZE
- See Also:
- Constant Field Values
-
KEYPAIR_SIZE
private static final int KEYPAIR_SIZE
- See Also:
- Constant Field Values
-
edDSASupport
protected final EdDSASupport<PUB extends java.security.PublicKey,PRV extends java.security.PrivateKey> edDSASupport
-
-
Constructor Detail
-
GenericOpenSSHEd25519PrivateKeyEntryDecoder
public GenericOpenSSHEd25519PrivateKeyEntryDecoder(java.lang.Class<PUB> pubType, java.lang.Class<PRV> prvType, EdDSASupport<PUB,PRV> edDSASupport)
-
-
Method Detail
-
decodePrivateKey
public PRV decodePrivateKey(SessionContext session, java.lang.String keyType, FilePasswordProvider passwordProvider, java.io.InputStream keyData) throws java.io.IOException, java.security.GeneralSecurityException
- Parameters:
session- TheSessionContextfor invoking this load command - may benullif not invoked within a session context (e.g., offline tool or session unknown).keyType- The reported / encode key typepasswordProvider- TheFilePasswordProviderto use in case the data is encrypted - may benullif no encrypted data is expectedkeyData- The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types- Returns:
- The decoded
PrivateKey - Throws:
java.io.IOException- If failed to read from the data streamjava.security.GeneralSecurityException- If failed to generate the key
-
encodePrivateKey
public java.lang.String encodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey) throws java.io.IOException
Description copied from interface:PrivateKeyEntryDecoderEncodes thePrivateKeyusing theOpenSSHformat - same one used by thedecodePublicKeymethod(s)- Parameters:
s- TheSecureByteArrayOutputStreamto write the data to.key- ThePrivateKey- may not benullpubKey- ThePublicKeybelonging to the private key - must be non-nullifpublic key recoveryis not supported- Returns:
- The key type value - one of the
KeyTypeNamesSupport.getSupportedKeyTypes()ornullif encoding not supported - Throws:
java.io.IOException- If failed to generate the encoding
-
isPublicKeyRecoverySupported
public boolean isPublicKeyRecoverySupported()
-
recoverPublicKey
public PUB recoverPublicKey(PRV prvKey) throws java.security.GeneralSecurityException
Description copied from interface:PrivateKeyEntryDecoderAttempts to recover the public key given the private one- Parameters:
prvKey- ThePrivateKey- Returns:
- The recovered
PublicKey-nullif cannot recover it - Throws:
java.security.GeneralSecurityException- If failed to generate the public key
-
clonePublicKey
public PUB clonePublicKey(PUB key) throws java.security.GeneralSecurityException
- Parameters:
key- ThePublicKeyto clone - ignored ifnull- Returns:
- The cloned key (or
nullif no original key) - Throws:
java.security.GeneralSecurityException- If failed to clone the key
-
clonePrivateKey
public PRV clonePrivateKey(PRV key) throws java.security.GeneralSecurityException
- Parameters:
key- ThePrivateKeyto clone - ignored ifnull- Returns:
- The cloned key (or
nullif no original key) - Throws:
java.security.GeneralSecurityException- If failed to clone the key
-
getKeyPairGenerator
public java.security.KeyPairGenerator getKeyPairGenerator() throws java.security.GeneralSecurityException- Returns:
- A
KeyPairGeneratorsuitable for this decoder - Throws:
java.security.GeneralSecurityException- If failed to create the generator
-
getKeyFactoryInstance
public java.security.KeyFactory getKeyFactoryInstance() throws java.security.GeneralSecurityException- Returns:
- A
KeyFactorysuitable for the specific decoder type - Throws:
java.security.GeneralSecurityException- If failed to create one
-
-