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 class
BCryptKdfOptions.BCryptBadRoundsException
-
Field Summary
Fields Modifier and Type Field Description static 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.private static java.util.concurrent.atomic.AtomicInteger
MAX_ROUNDS_HOLDER
static java.lang.String
NAME
private int
numRounds
private 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 void
bcryptKdf(byte[] password, byte[] output)
byte[]
decodePrivateKeyBytes(SessionContext session, NamedResource resourceKey, java.lang.String cipherName, byte[] privateDataBytes, java.lang.String password)
boolean
equals(java.lang.Object obj)
static int
getMaxAllowedRounds()
java.lang.String
getName()
int
getNumRounds()
byte[]
getSalt()
int
hashCode()
protected void
initialize(java.io.InputStream stream, int maxSaltSize)
void
initialize(java.lang.String name, byte[] kdfOptions)
boolean
isEncrypted()
static void
setMaxAllowedRounds(int value)
void
setNumRounds(int numRounds)
void
setSalt(byte[] salt)
java.lang.String
toString()
-
-
-
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-a
parameter to thessh-keygen
command) 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:
initialize
in 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:
isEncrypted
in 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:
decodePrivateKeyBytes
in interfaceOpenSSHKeyDecryptor
- Throws:
java.io.IOException
java.security.GeneralSecurityException
-
bcryptKdf
protected void bcryptKdf(byte[] password, byte[] output) throws java.io.IOException, java.security.GeneralSecurityException
- Throws:
java.io.IOException
java.security.GeneralSecurityException
-
getName
public final java.lang.String getName()
- Specified by:
getName
in 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getMaxAllowedRounds
public static int getMaxAllowedRounds()
-
setMaxAllowedRounds
public static void setMaxAllowedRounds(int value)
-
-