Package org.apache.sshd.common.cipher
Enum BuiltinCiphers
- java.lang.Object
-
- java.lang.Enum<BuiltinCiphers>
-
- org.apache.sshd.common.cipher.BuiltinCiphers
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<BuiltinCiphers>,java.util.function.Supplier<Cipher>,AlgorithmNameProvider,BuiltinFactory<Cipher>,CipherFactory,CipherInformation,Factory<Cipher>,KeySizeIndicator,NamedFactory<Cipher>,NamedResource,OptionalFeature
public enum BuiltinCiphers extends java.lang.Enum<BuiltinCiphers> implements CipherFactory
Provides easy access to the currently implemented ciphers
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBuiltinCiphers.Constantsstatic classBuiltinCiphers.ParseResultHolds the result ofparseCiphersList(String)
-
Enum Constant Summary
Enum Constants Enum Constant Description aes128cbcaes128ctraes128gcmaes192cbcaes192ctraes256cbcaes256ctraes256gcmarcfour128Deprecated.arcfour256Deprecated.blowfishcbcDeprecated.cc20p1305_opensshnonetripledescbcDeprecated.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringalgorithmprivate intauthSizeprivate intblkSizeprivate static java.util.Map<java.lang.String,CipherFactory>EXTENSIONSprivate java.lang.StringfactoryNameprivate intivsizeprivate intkeySizeprivate java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>supportedprivate java.lang.Stringtransformationstatic java.util.Set<BuiltinCiphers>VALUES-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Fields inherited from interface org.apache.sshd.common.OptionalFeature
FALSE, TRUE
-
-
Constructor Summary
Constructors Modifier Constructor Description privateBuiltinCiphers(java.lang.String factoryName, int ivsize, int authSize, java.lang.String algorithm, int keySizeInBits, java.lang.String transformation, int blkSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Ciphercreate()static BuiltinCiphersfromFactory(NamedFactory<Cipher> factory)static BuiltinCiphersfromFactoryName(java.lang.String name)static BuiltinCiphersfromString(java.lang.String s)java.lang.StringgetAlgorithm()intgetAuthenticationTagSize()intgetCipherBlockSize()intgetIVSize()intgetKdfSize()intgetKeySize()java.lang.StringgetName()static java.util.NavigableSet<CipherFactory>getRegisteredExtensions()java.lang.StringgetTransformation()booleanisSupported()static BuiltinCiphers.ParseResultparseCiphersList(java.lang.String ciphers)static BuiltinCiphers.ParseResultparseCiphersList(java.lang.String... ciphers)static BuiltinCiphers.ParseResultparseCiphersList(java.util.Collection<java.lang.String> ciphers)static voidregisterExtension(CipherFactory extension)Registered aNamedFactoryto be available besides the built-in ones when parsing configurationstatic CipherFactoryresolveFactory(java.lang.String name)java.lang.StringtoString()static NamedFactory<Cipher>unregisterExtension(java.lang.String name)Unregisters specified extensionstatic BuiltinCiphersvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static BuiltinCiphers[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
none
public static final BuiltinCiphers none
-
aes128cbc
public static final BuiltinCiphers aes128cbc
-
aes128ctr
public static final BuiltinCiphers aes128ctr
-
aes128gcm
public static final BuiltinCiphers aes128gcm
-
aes256gcm
public static final BuiltinCiphers aes256gcm
-
aes192cbc
public static final BuiltinCiphers aes192cbc
-
aes192ctr
public static final BuiltinCiphers aes192ctr
-
aes256cbc
public static final BuiltinCiphers aes256cbc
-
aes256ctr
public static final BuiltinCiphers aes256ctr
-
arcfour128
@Deprecated public static final BuiltinCiphers arcfour128
Deprecated.- See Also:
- SSHD-1004
-
arcfour256
@Deprecated public static final BuiltinCiphers arcfour256
Deprecated.- See Also:
- SSHD-1004
-
blowfishcbc
@Deprecated public static final BuiltinCiphers blowfishcbc
Deprecated.- See Also:
- SSHD-1004
-
cc20p1305_openssh
public static final BuiltinCiphers cc20p1305_openssh
-
tripledescbc
@Deprecated public static final BuiltinCiphers tripledescbc
Deprecated.- See Also:
- SSHD-1004
-
-
Field Detail
-
VALUES
public static final java.util.Set<BuiltinCiphers> VALUES
-
EXTENSIONS
private static final java.util.Map<java.lang.String,CipherFactory> EXTENSIONS
-
factoryName
private final java.lang.String factoryName
-
ivsize
private final int ivsize
-
authSize
private final int authSize
-
keySize
private final int keySize
-
blkSize
private final int blkSize
-
algorithm
private final java.lang.String algorithm
-
transformation
private final java.lang.String transformation
-
supported
private final java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> supported
-
-
Method Detail
-
values
public static BuiltinCiphers[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BuiltinCiphers c : BuiltinCiphers.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BuiltinCiphers valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getName
public final java.lang.String getName()
- Specified by:
getNamein interfaceNamedResource- Returns:
- The resource name
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Enum<BuiltinCiphers>
-
isSupported
public boolean isSupported()
- Specified by:
isSupportedin interfaceOptionalFeature- Returns:
trueif the current JVM configuration supports this cipher - e.g., AES-256 requires the Java Cryptography Extension (JCE)
-
getKeySize
public int getKeySize()
- Specified by:
getKeySizein interfaceKeySizeIndicator- Returns:
- The number of bits used in the key
-
getIVSize
public int getIVSize()
- Specified by:
getIVSizein interfaceCipherInformation- Returns:
- Size of the initialization vector (in bytes)
-
getAuthenticationTagSize
public int getAuthenticationTagSize()
- Specified by:
getAuthenticationTagSizein interfaceCipherInformation- Returns:
- Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
-
getKdfSize
public int getKdfSize()
- Specified by:
getKdfSizein interfaceCipherInformation- Returns:
- The block size (in bytes) used to derive the secret key for this cipher
-
getCipherBlockSize
public int getCipherBlockSize()
- Specified by:
getCipherBlockSizein interfaceCipherInformation- Returns:
- Size of block data used by the cipher (in bytes). For stream ciphers this value is (currently) used to indicate some average work buffer size to be used for the automatic re-keying mechanism described in RFC 4253 - Section 9
-
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithmin interfaceAlgorithmNameProvider
-
getTransformation
public java.lang.String getTransformation()
- Specified by:
getTransformationin interfaceCipherInformation- Returns:
- The actual transformation used - e.g., AES/CBC/NoPadding
-
create
public Cipher create()
-
registerExtension
public static void registerExtension(CipherFactory extension)
Registered aNamedFactoryto be available besides the built-in ones when parsing configuration- Parameters:
extension- The factory to register- Throws:
java.lang.IllegalArgumentException- if factory instance isnull, or overrides a built-in one or overrides another registered factory with the same name (case insensitive).
-
getRegisteredExtensions
public static java.util.NavigableSet<CipherFactory> getRegisteredExtensions()
- Returns:
- A
SortedSetof the currently registered extensions, sorted according to the factory name (case insensitive)
-
unregisterExtension
public static NamedFactory<Cipher> unregisterExtension(java.lang.String name)
Unregisters specified extension- Parameters:
name- The factory name - ignored ifnull/empty- Returns:
- The registered extension -
nullif not found
-
fromString
public static BuiltinCiphers fromString(java.lang.String s)
- Parameters:
s- TheEnum's name - ignored ifnull/empty- Returns:
- The matching
BuiltinCipherswhoseEnum.name()matches (case insensitive) the provided argument -nullif no match
-
fromFactory
public static BuiltinCiphers fromFactory(NamedFactory<Cipher> factory)
- Parameters:
factory- TheNamedFactoryfor the cipher - ignored ifnull- Returns:
- The matching
BuiltinCipherswhose factory name matches (case insensitive) the cipher factory name - See Also:
fromFactoryName(String)
-
fromFactoryName
public static BuiltinCiphers fromFactoryName(java.lang.String name)
- Parameters:
name- The factory name - ignored ifnull/empty- Returns:
- The matching
BuiltinCipherswhose factory name matches (case insensitive) the provided name -nullif no match
-
parseCiphersList
public static BuiltinCiphers.ParseResult parseCiphersList(java.lang.String ciphers)
- Parameters:
ciphers- A comma-separated list of ciphers' names - ignored ifnull/empty- Returns:
- A
BuiltinCiphers.ParseResultcontaining the successfully parsed factories and the unknown ones. Note: it is up to caller to ensure that the lists do not contain duplicates
-
parseCiphersList
public static BuiltinCiphers.ParseResult parseCiphersList(java.lang.String... ciphers)
-
parseCiphersList
public static BuiltinCiphers.ParseResult parseCiphersList(java.util.Collection<java.lang.String> ciphers)
-
resolveFactory
public static CipherFactory resolveFactory(java.lang.String name)
- Parameters:
name- The factory name- Returns:
- The factory or
nullif it is neither a built-in one or a registered extension
-
-