Package org.apache.sshd.common.cipher
Enum ECCurves
- java.lang.Object
-
- java.lang.Enum<ECCurves>
-
- org.apache.sshd.common.cipher.ECCurves
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<ECCurves>,KeySizeIndicator,KeyTypeIndicator,NamedResource,OptionalFeature
public enum ECCurves extends java.lang.Enum<ECCurves> implements KeyTypeIndicator, KeySizeIndicator, NamedResource, OptionalFeature
Utilities for working with elliptic curves.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classECCurves.Constantsstatic classECCurves.ECPointCompressionThe variousECPointrepresentation compression indicators
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<ECCurves>BY_KEY_SIZEprivate DigestFactorydigestFactorystatic java.util.NavigableSet<java.lang.String>KEY_TYPESASetof all the known curves key typesprivate intkeySizeprivate java.lang.StringkeyTypeprivate java.lang.Stringnamestatic java.util.NavigableSet<java.lang.String>NAMESASetof all the known curves namesprivate intnumOctetsprivate java.lang.StringoidStringprivate java.util.List<java.lang.Integer>oidValueprivate java.security.spec.ECParameterSpecparamsstatic java.util.List<ECCurves>SORTED_KEY_SIZEstatic java.util.Set<ECCurves>VALUESASetof all the known curves-
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 privateECCurves(java.lang.String name, int[] oid, java.security.spec.ECParameterSpec params, int numOctets, DigestFactory digestFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]encodeECPoint(java.security.spec.ECPoint group, java.security.spec.ECParameterSpec params)static byte[]encodeECPoint(java.security.spec.ECPoint group, java.security.spec.EllipticCurve curve)private static intfindFirstNonZeroIndex(byte... octets)static ECCurvesfromCurveName(java.lang.String name)static ECCurvesfromCurveParameters(java.security.spec.ECParameterSpec params)static ECCurvesfromCurveSize(int keySize)static ECCurvesfromECKey(java.security.interfaces.ECKey key)static ECCurvesfromKeyType(java.lang.String type)static ECCurvesfromOID(java.lang.String oid)static ECCurvesfromOIDValue(java.util.List<? extends java.lang.Number> oid)static intgetCurveSize(java.security.spec.ECParameterSpec params)DigestgetDigestForParams()intgetKeySize()java.lang.StringgetKeyType()java.lang.StringgetName()intgetNumPointOctets()java.lang.StringgetOID()java.util.List<java.lang.Integer>getOIDValue()java.security.spec.ECParameterSpecgetParameters()booleanisSupported()static java.security.spec.ECPointoctetStringToEcPoint(byte... octets)static java.math.BigIntegeroctetStringToInteger(byte... octets)Converts the given octet string (defined by ASN.1 specifications) to aBigIntegerAs 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 ECCurvesvalueOf(java.lang.String name)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.
-
-
-
Field Detail
-
VALUES
public static final java.util.Set<ECCurves> VALUES
ASetof all the known curves
-
NAMES
public static final java.util.NavigableSet<java.lang.String> NAMES
ASetof all the known curves names
-
KEY_TYPES
public static final java.util.NavigableSet<java.lang.String> KEY_TYPES
ASetof all the known curves key types
-
BY_KEY_SIZE
public static final java.util.Comparator<ECCurves> BY_KEY_SIZE
-
SORTED_KEY_SIZE
public static final java.util.List<ECCurves> SORTED_KEY_SIZE
-
name
private final java.lang.String name
-
keyType
private final java.lang.String keyType
-
oidString
private final java.lang.String oidString
-
oidValue
private final java.util.List<java.lang.Integer> oidValue
-
params
private final java.security.spec.ECParameterSpec params
-
keySize
private final int keySize
-
numOctets
private final int numOctets
-
digestFactory
private final DigestFactory digestFactory
-
-
Constructor Detail
-
ECCurves
private ECCurves(java.lang.String name, int[] oid, java.security.spec.ECParameterSpec params, int numOctets, DigestFactory digestFactory)
-
-
Method Detail
-
values
public static ECCurves[] 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 (ECCurves c : ECCurves.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ECCurves 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
-
getOID
public final java.lang.String getOID()
-
getOIDValue
public final java.util.List<java.lang.Integer> getOIDValue()
-
getKeyType
public final java.lang.String getKeyType()
- Specified by:
getKeyTypein interfaceKeyTypeIndicator- Returns:
- The SSH key type name - e.g., "ssh-rsa", "sshd-dss" etc.
-
isSupported
public final boolean isSupported()
- Specified by:
isSupportedin interfaceOptionalFeature
-
getParameters
public final java.security.spec.ECParameterSpec getParameters()
-
getKeySize
public final int getKeySize()
- Specified by:
getKeySizein 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
public final Digest getDigestForParams()
- Returns:
- The
Digestto use when hashing the curve's parameters
-
fromKeyType
public static ECCurves fromKeyType(java.lang.String type)
- Parameters:
type- The key type value - ignored ifnull/empty- Returns:
- The matching
ECCurvesconstant -nullif no match found case insensitive
-
fromCurveName
public static ECCurves fromCurveName(java.lang.String name)
- Parameters:
name- The curve name (case insensitive - ignored ifnull/empty- Returns:
- The matching
ECCurvesinstance -nullif no match found
-
fromECKey
public static ECCurves fromECKey(java.security.interfaces.ECKey key)
- Parameters:
key- TheECKey- ignored ifnull- Returns:
- The matching
ECCurvesinstance -nullif no match found
-
fromCurveParameters
public static ECCurves fromCurveParameters(java.security.spec.ECParameterSpec params)
- Parameters:
params- The curve'sECParameterSpec- ignored ifnull- Returns:
- The matching
ECCurvesvalue -nullif no match found - See Also:
getCurveSize(ECParameterSpec),fromCurveSize(int)
-
fromCurveSize
public static ECCurves fromCurveSize(int keySize)
- Parameters:
keySize- The key size (in bits)- Returns:
- The matching
ECCurvesvalue -nullif no match found
-
fromOIDValue
public static ECCurves fromOIDValue(java.util.List<? extends java.lang.Number> oid)
-
fromOID
public static ECCurves fromOID(java.lang.String oid)
-
getCurveSize
public static int getCurveSize(java.security.spec.ECParameterSpec params)
- Parameters:
params- The curve'sECParameterSpec- Returns:
- The curve's key size in bits
- Throws:
java.lang.IllegalArgumentException- if invalid parameters provided
-
encodeECPoint
public static byte[] encodeECPoint(java.security.spec.ECPoint group, java.security.spec.ECParameterSpec params)
-
encodeECPoint
public static byte[] encodeECPoint(java.security.spec.ECPoint group, java.security.spec.EllipticCurve curve)
-
removeLeadingZeroes
private static byte[] removeLeadingZeroes(byte[] input)
-
octetStringToInteger
public static java.math.BigInteger octetStringToInteger(byte... octets)
Converts the given octet string (defined by ASN.1 specifications) to aBigIntegerAs 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
BigIntegerrepresentation of the octet string
-
octetStringToEcPoint
public static java.security.spec.ECPoint octetStringToEcPoint(byte... octets)
-
findFirstNonZeroIndex
private static int findFirstNonZeroIndex(byte... octets)
-
-