Enum Class BuiltinCiphers

java.lang.Object
java.lang.Enum<BuiltinCiphers>
org.apache.sshd.common.cipher.BuiltinCiphers
All Implemented Interfaces:
Serializable, Comparable<BuiltinCiphers>, Constable, Supplier<Cipher>, AlgorithmNameProvider, BuiltinFactory<Cipher>, CipherFactory, CipherInformation, Factory<Cipher>, KeySizeIndicator, NamedFactory<Cipher>, NamedResource, OptionalFeature

public enum BuiltinCiphers extends Enum<BuiltinCiphers> implements CipherFactory
Provides easy access to the currently implemented ciphers
  • Enum Constant Details

  • Field Details

    • VALUES

      public static final Set<BuiltinCiphers> VALUES
    • EXTENSIONS

      private static final Map<String,CipherFactory> EXTENSIONS
    • factoryName

      private final String factoryName
    • ivsize

      private final int ivsize
    • authSize

      private final int authSize
    • kdfSize

      private final int kdfSize
    • keysize

      private final int keysize
    • blkSize

      private final int blkSize
    • algorithm

      private final String algorithm
    • transformation

      private final String transformation
    • supported

      private final boolean supported
  • Constructor Details

    • BuiltinCiphers

      private BuiltinCiphers(String factoryName, int ivsize, int authSize, int kdfSize, String algorithm, int keySize, String transformation, int blkSize)
  • Method Details

    • values

      public static BuiltinCiphers[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BuiltinCiphers valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getName

      public final String getName()
      Specified by:
      getName in interface NamedResource
      Returns:
      The resource name
    • toString

      public final String toString()
      Overrides:
      toString in class Enum<BuiltinCiphers>
    • isSupported

      public boolean isSupported()
      Specified by:
      isSupported in interface OptionalFeature
      Returns:
      true if the current JVM configuration supports this cipher - e.g., AES-256 requires the Java Cryptography Extension (JCE)
    • getKeySize

      public int getKeySize()
      Specified by:
      getKeySize in interface KeySizeIndicator
      Returns:
      The number of bits used in the key
    • getIVSize

      public int getIVSize()
      Specified by:
      getIVSize in interface CipherInformation
      Returns:
      Size of the initialization vector (in bytes)
    • getAuthenticationTagSize

      public int getAuthenticationTagSize()
      Specified by:
      getAuthenticationTagSize in interface CipherInformation
      Returns:
      Size of the authentication tag (AT) in bytes or 0 if this cipher does not support authentication
    • getKdfSize

      public int getKdfSize()
      Specified by:
      getKdfSize in interface CipherInformation
      Returns:
      The block size (in bytes) used to derive the secret key for this cipher
    • getCipherBlockSize

      public int getCipherBlockSize()
      Specified by:
      getCipherBlockSize in interface CipherInformation
      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 String getAlgorithm()
      Specified by:
      getAlgorithm in interface AlgorithmNameProvider
    • getTransformation

      public String getTransformation()
      Specified by:
      getTransformation in interface CipherInformation
      Returns:
      The actual transformation used - e.g., AES/CBC/NoPadding
    • create

      public Cipher create()
      Specified by:
      create in interface Factory<Cipher>
      Returns:
      A new instance
    • registerExtension

      public static void registerExtension(CipherFactory extension)
      Registered a NamedFactory to be available besides the built-in ones when parsing configuration
      Parameters:
      extension - The factory to register
      Throws:
      IllegalArgumentException - if factory instance is null, or overrides a built-in one or overrides another registered factory with the same name (case insensitive).
    • getRegisteredExtensions

      public static NavigableSet<CipherFactory> getRegisteredExtensions()
      Returns:
      A SortedSet of the currently registered extensions, sorted according to the factory name (case insensitive)
    • unregisterExtension

      public static NamedFactory<Cipher> unregisterExtension(String name)
      Unregisters specified extension
      Parameters:
      name - The factory name - ignored if null/empty
      Returns:
      The registered extension - null if not found
    • fromString

      public static BuiltinCiphers fromString(String s)
      Parameters:
      s - The Enum's name - ignored if null/empty
      Returns:
      The matching BuiltinCiphers whose Enum.name() matches (case insensitive) the provided argument - null if no match
    • fromFactory

      public static BuiltinCiphers fromFactory(NamedFactory<Cipher> factory)
      Parameters:
      factory - The NamedFactory for the cipher - ignored if null
      Returns:
      The matching BuiltinCiphers whose factory name matches (case insensitive) the cipher factory name
      See Also:
    • fromFactoryName

      public static BuiltinCiphers fromFactoryName(String name)
      Parameters:
      name - The factory name - ignored if null/empty
      Returns:
      The matching BuiltinCiphers whose factory name matches (case insensitive) the provided name - null if no match
    • parseCiphersList

      public static BuiltinCiphers.ParseResult parseCiphersList(String ciphers)
      Parameters:
      ciphers - A comma-separated list of ciphers' names - ignored if null/empty
      Returns:
      A BuiltinCiphers.ParseResult containing 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(String... ciphers)
    • parseCiphersList

      public static BuiltinCiphers.ParseResult parseCiphersList(Collection<String> ciphers)
    • resolveFactory

      public static CipherFactory resolveFactory(String name)
      Parameters:
      name - The factory name
      Returns:
      The factory or null if it is neither a built-in one or a registered extension