Package org.apache.sshd.common.kex
Enum MontgomeryCurve
- java.lang.Object
-
- java.lang.Enum<MontgomeryCurve>
-
- org.apache.sshd.common.kex.MontgomeryCurve
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<MontgomeryCurve>,CurveSizeIndicator,KeySizeIndicator,OptionalFeature
public enum MontgomeryCurve extends java.lang.Enum<MontgomeryCurve> implements KeySizeIndicator, CurveSizeIndicator, OptionalFeature
Provides implementation details for Montgomery curves and their key exchange algorithms Curve25519/X25519 and Curve448/X448 specified in RFC 7748 and RFC 8731. Montgomery curves provide improved security and flexibility over Weierstrass curves used in ECDH.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringalgorithmprivate byte[]encodedPublicKeyPrefixprivate java.security.KeyFactorykeyFactoryprivate java.security.KeyPairGeneratorkeyPairGeneratorprivate intkeySizeprivate booleansupported-
Fields inherited from interface org.apache.sshd.common.OptionalFeature
FALSE, TRUE
-
-
Constructor Summary
Constructors Modifier Constructor Description privateMontgomeryCurve(java.lang.String algorithm, int keySize, byte[] encodedPublicKeyPrefix)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.crypto.KeyAgreementcreateKeyAgreement()java.security.PublicKeydecode(byte[] key)byte[]encode(java.security.PublicKey key)java.security.KeyPairgenerateKeyPair()java.lang.StringgetAlgorithm()intgetByteLength()Retrieves the length of a point coordinate in bytes.intgetKeySize()booleanisSupported()static MontgomeryCurvevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static MontgomeryCurve[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
x25519
public static final MontgomeryCurve x25519
X25519 uses Curve25519 and SHA-256 with a 32-byte key size.
-
x448
public static final MontgomeryCurve x448
X448 uses Curve448 and SHA-512 with a 56-byte key size.
-
-
Field Detail
-
algorithm
private final java.lang.String algorithm
-
keySize
private final int keySize
-
supported
private final boolean supported
-
keyPairGenerator
private final java.security.KeyPairGenerator keyPairGenerator
-
keyFactory
private final java.security.KeyFactory keyFactory
-
encodedPublicKeyPrefix
private final byte[] encodedPublicKeyPrefix
-
-
Method Detail
-
values
public static MontgomeryCurve[] 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 (MontgomeryCurve c : MontgomeryCurve.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MontgomeryCurve 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
-
getAlgorithm
public java.lang.String getAlgorithm()
-
getByteLength
public int getByteLength()
Description copied from interface:CurveSizeIndicatorRetrieves the length of a point coordinate in bytes.- Specified by:
getByteLengthin interfaceCurveSizeIndicator- Returns:
- the length
-
getKeySize
public int getKeySize()
- Specified by:
getKeySizein interfaceKeySizeIndicator- Returns:
- The number of bits used in the key
-
isSupported
public boolean isSupported()
- Specified by:
isSupportedin interfaceOptionalFeature
-
createKeyAgreement
public javax.crypto.KeyAgreement createKeyAgreement() throws java.security.GeneralSecurityException- Throws:
java.security.GeneralSecurityException
-
generateKeyPair
public java.security.KeyPair generateKeyPair()
-
encode
public byte[] encode(java.security.PublicKey key) throws java.security.InvalidKeyException- Throws:
java.security.InvalidKeyException
-
decode
public java.security.PublicKey decode(byte[] key) throws java.security.spec.InvalidKeySpecException- Throws:
java.security.spec.InvalidKeySpecException
-
-