Enum ECCurves

java.lang.Object
java.lang.Enum<ECCurves>
org.apache.sshd.common.cipher.ECCurves
All Implemented Interfaces:
Serializable, Comparable<ECCurves>, java.lang.constant.Constable, KeySizeIndicator, KeyTypeIndicator, NamedResource, OptionalFeature

public enum ECCurves extends Enum<ECCurves> implements KeyTypeIndicator, KeySizeIndicator, NamedResource, OptionalFeature
Utilities for working with elliptic curves.
  • Enum Constant Details

    • nistp256

      public static final ECCurves nistp256
    • nistp384

      public static final ECCurves nistp384
    • nistp521

      public static final ECCurves nistp521
  • Field Details

    • VALUES

      public static final Set<ECCurves> VALUES
      A Set of all the known curves
    • NAMES

      public static final NavigableSet<String> NAMES
      A Set of all the known curves names
    • KEY_TYPES

      public static final NavigableSet<String> KEY_TYPES
      A Set of all the known curves key types
    • BY_KEY_SIZE

      public static final Comparator<ECCurves> BY_KEY_SIZE
    • SORTED_KEY_SIZE

      public static final List<ECCurves> SORTED_KEY_SIZE
    • name

      private final String name
    • keyType

      private final String keyType
    • oidString

      private final String oidString
    • oidValue

      private final List<Integer> oidValue
    • params

      private final ECParameterSpec params
    • keySize

      private final int keySize
    • numOctets

      private final int numOctets
    • digestFactory

      private final DigestFactory digestFactory
  • Constructor Details

  • Method Details

    • values

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

      public static ECCurves valueOf(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:
      IllegalArgumentException - if this enum type 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
    • getOID

      public final String getOID()
    • getOIDValue

      public final List<Integer> getOIDValue()
    • getKeyType

      public final String getKeyType()
      Specified by:
      getKeyType in interface KeyTypeIndicator
      Returns:
      The SSH key type name - e.g., "ssh-rsa", "sshd-dss" etc.
    • isSupported

      public final boolean isSupported()
      Specified by:
      isSupported in interface OptionalFeature
    • getParameters

      public final ECParameterSpec getParameters()
    • getKeySize

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

      public final int getNumPointOctets()
      Returns:
      The number of octets used to represent the point(s) for the curve
    • getDigestForParams

      public final Digest getDigestForParams()
      Returns:
      The Digest to use when hashing the curve's parameters
    • fromKeyType

      public static ECCurves fromKeyType(String type)
      Parameters:
      type - The key type value - ignored if null/empty
      Returns:
      The matching ECCurves constant - null if no match found case insensitive
    • fromCurveName

      public static ECCurves fromCurveName(String name)
      Parameters:
      name - The curve name (case insensitive - ignored if null/empty
      Returns:
      The matching ECCurves instance - null if no match found
    • fromECKey

      public static ECCurves fromECKey(ECKey key)
      Parameters:
      key - The ECKey - ignored if null
      Returns:
      The matching ECCurves instance - null if no match found
    • fromCurveParameters

      public static ECCurves fromCurveParameters(ECParameterSpec params)
      Parameters:
      params - The curve's ECParameterSpec - ignored if null
      Returns:
      The matching ECCurves value - null if no match found
      See Also:
    • fromCurveSize

      public static ECCurves fromCurveSize(int keySize)
      Parameters:
      keySize - The key size (in bits)
      Returns:
      The matching ECCurves value - null if no match found
    • fromOIDValue

      public static ECCurves fromOIDValue(List<? extends Number> oid)
    • fromOID

      public static ECCurves fromOID(String oid)
    • getCurveSize

      public static int getCurveSize(ECParameterSpec params)
      Parameters:
      params - The curve's ECParameterSpec
      Returns:
      The curve's key size in bits
      Throws:
      IllegalArgumentException - if invalid parameters provided
    • encodeECPoint

      public static byte[] encodeECPoint(ECPoint group, ECParameterSpec params)
    • encodeECPoint

      public static byte[] encodeECPoint(ECPoint group, EllipticCurve curve)
    • removeLeadingZeroes

      private static byte[] removeLeadingZeroes(byte[] input)
    • octetStringToInteger

      public static BigInteger octetStringToInteger(byte... octets)
      Converts the given octet string (defined by ASN.1 specifications) to a BigInteger As octet strings always represent positive integers, a zero-byte is prepended to the given array if necessary (if is MSB equal to 1), then this is converted to BigInteger The conversion is defined in the Section 2.3.8
      Parameters:
      octets - - octet string bytes to be converted
      Returns:
      The BigInteger representation of the octet string
    • octetStringToEcPoint

      public static ECPoint octetStringToEcPoint(byte... octets)
    • findFirstNonZeroIndex

      private static int findFirstNonZeroIndex(byte... octets)