Class BCryptKdfOptions
- java.lang.Object
-
- org.apache.sshd.common.config.keys.loader.openssh.kdf.BCryptKdfOptions
-
- All Implemented Interfaces:
OpenSSHKdfOptions,OpenSSHKeyDecryptor,NamedResource
public class BCryptKdfOptions extends java.lang.Object implements OpenSSHKdfOptions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBCryptKdfOptions.BCryptBadRoundsException
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_ROUNDSVarious discussions on the net seem to indicate that 64 is the value at which many computers seem to slow down noticeably, so we are rather generous here.private static java.util.concurrent.atomic.AtomicIntegerMAX_ROUNDS_HOLDERstatic java.lang.StringNAMEprivate intnumRoundsprivate byte[]salt-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Fields inherited from interface org.apache.sshd.common.config.keys.loader.openssh.OpenSSHKdfOptions
IS_NONE_KDF, MAX_KDF_NAME_LENGTH, MAX_KDF_OPTIONS_SIZE, NONE_KDF
-
-
Constructor Summary
Constructors Constructor Description BCryptKdfOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbcryptKdf(byte[] password, byte[] output)byte[]decodePrivateKeyBytes(SessionContext session, NamedResource resourceKey, java.lang.String cipherName, byte[] privateDataBytes, java.lang.String password)booleanequals(java.lang.Object obj)static intgetMaxAllowedRounds()java.lang.StringgetName()intgetNumRounds()byte[]getSalt()inthashCode()protected voidinitialize(java.io.InputStream stream, int maxSaltSize)voidinitialize(java.lang.String name, byte[] kdfOptions)booleanisEncrypted()static voidsetMaxAllowedRounds(int value)voidsetNumRounds(int numRounds)voidsetSalt(byte[] salt)java.lang.StringtoString()
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_MAX_ROUNDS
public static final int DEFAULT_MAX_ROUNDS
Various discussions on the net seem to indicate that 64 is the value at which many computers seem to slow down noticeably, so we are rather generous here. The default value (unless overridden by the-aparameter to thessh-keygencommand) is usually 16.- See Also:
- Constant Field Values
-
MAX_ROUNDS_HOLDER
private static final java.util.concurrent.atomic.AtomicInteger MAX_ROUNDS_HOLDER
-
salt
private byte[] salt
-
numRounds
private int numRounds
-
-
Method Detail
-
initialize
public void initialize(java.lang.String name, byte[] kdfOptions) throws java.io.IOException- Specified by:
initializein interfaceOpenSSHKdfOptions- Throws:
java.io.IOException
-
initialize
protected void initialize(java.io.InputStream stream, int maxSaltSize) throws java.io.IOException- Throws:
java.io.IOException
-
isEncrypted
public boolean isEncrypted()
- Specified by:
isEncryptedin interfaceOpenSSHKeyDecryptor
-
decodePrivateKeyBytes
public byte[] decodePrivateKeyBytes(SessionContext session, NamedResource resourceKey, java.lang.String cipherName, byte[] privateDataBytes, java.lang.String password) throws java.io.IOException, java.security.GeneralSecurityException
- Specified by:
decodePrivateKeyBytesin interfaceOpenSSHKeyDecryptor- Throws:
java.io.IOExceptionjava.security.GeneralSecurityException
-
bcryptKdf
protected void bcryptKdf(byte[] password, byte[] output) throws java.io.IOException, java.security.GeneralSecurityException- Throws:
java.io.IOExceptionjava.security.GeneralSecurityException
-
getName
public final java.lang.String getName()
- Specified by:
getNamein interfaceNamedResource- Returns:
- The resource name
-
getSalt
public byte[] getSalt()
-
setSalt
public void setSalt(byte[] salt)
-
getNumRounds
public int getNumRounds()
-
setNumRounds
public void setNumRounds(int numRounds)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getMaxAllowedRounds
public static int getMaxAllowedRounds()
-
setMaxAllowedRounds
public static void setMaxAllowedRounds(int value)
-
-