Package org.apache.sshd.common.cipher
Enum 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static enum
The variousECPoint
representation compression indicatorsNested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<ECCurves>
private final DigestFactory
static final NavigableSet<String>
ASet
of all the known curves key typesprivate final int
private final String
private final String
static final NavigableSet<String>
ASet
of all the known curves namesprivate final int
private final String
private final ECParameterSpec
ASet
of all the known curvesFields 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
ConstructorsModifierConstructorDescriptionprivate
ECCurves
(String name, int[] oid, ECParameterSpec params, int numOctets, DigestFactory digestFactory) -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
encodeECPoint
(ECPoint group, ECParameterSpec params) static byte[]
encodeECPoint
(ECPoint group, EllipticCurve curve) private static int
findFirstNonZeroIndex
(byte... octets) static ECCurves
fromCurveName
(String name) static ECCurves
fromCurveParameters
(ECParameterSpec params) static ECCurves
fromCurveSize
(int keySize) static ECCurves
static ECCurves
fromKeyType
(String type) static ECCurves
static ECCurves
fromOIDValue
(List<? extends Number> oid) static int
getCurveSize
(ECParameterSpec params) final Digest
final int
final String
final String
getName()
final int
final String
getOID()
final ECParameterSpec
final boolean
static ECPoint
octetStringToEcPoint
(byte... octets) static BigInteger
octetStringToInteger
(byte... octets) Converts the given octet string (defined by ASN.1 specifications) to aBigInteger
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.8private static byte[]
removeLeadingZeroes
(byte[] input) static ECCurves
Returns the enum constant of this type with the specified name.static ECCurves[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
nistp256
-
nistp384
-
nistp521
-
-
Field Details
-
Constructor Details
-
ECCurves
private ECCurves(String name, int[] oid, ECParameterSpec params, int numOctets, DigestFactory digestFactory)
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
getName
- Specified by:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
getOID
-
getOIDValue
-
getKeyType
- Specified by:
getKeyType
in interfaceKeyTypeIndicator
- Returns:
- The SSH key type name - e.g., "ssh-rsa", "sshd-dss" etc.
-
isSupported
public final boolean isSupported()- Specified by:
isSupported
in interfaceOptionalFeature
-
getParameters
-
getKeySize
public final int getKeySize()- Specified by:
getKeySize
in interfaceKeySizeIndicator
- 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
- Returns:
- The
Digest
to use when hashing the curve's parameters
-
fromKeyType
- Parameters:
type
- The key type value - ignored ifnull
/empty- Returns:
- The matching
ECCurves
constant -null
if no match found case insensitive
-
fromCurveName
- Parameters:
name
- The curve name (case insensitive - ignored ifnull
/empty- Returns:
- The matching
ECCurves
instance -null
if no match found
-
fromECKey
-
fromCurveParameters
- Parameters:
params
- The curve'sECParameterSpec
- ignored ifnull
- Returns:
- The matching
ECCurves
value -null
if no match found - See Also:
-
fromCurveSize
- Parameters:
keySize
- The key size (in bits)- Returns:
- The matching
ECCurves
value -null
if no match found
-
fromOIDValue
-
fromOID
-
getCurveSize
- Parameters:
params
- The curve'sECParameterSpec
- Returns:
- The curve's key size in bits
- Throws:
IllegalArgumentException
- if invalid parameters provided
-
encodeECPoint
-
encodeECPoint
-
removeLeadingZeroes
private static byte[] removeLeadingZeroes(byte[] input) -
octetStringToInteger
Converts the given octet string (defined by ASN.1 specifications) to aBigInteger
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
-
findFirstNonZeroIndex
private static int findFirstNonZeroIndex(byte... octets)
-