- All Implemented Interfaces:
Serializable, Comparable<EncType>, java.lang.constant.Constable
Defines the properties for various encryption types that I2P supports or may someday support.
All PublicKeys and PrivateKeys have a type. Note that a EncType specifies both an algorithm and parameters, so that we may change primes or curves for a given algorithm.
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E>Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionUsed by i2pd.Reserved, not used by anybody.Reserved, not used by anybody.Proposal 144.2048-bit MODP Group from RFC 3526.Proposal 169.For internal use only (Bob side ciphertext) Proposal 169.For internal use only (Alice side) Proposal 169.Proposal 169.For internal use only (Bob side ciphertext) Proposal 169.For internal use only (Alice side) Proposal 169.Proposal 169.For internal use only (Bob side ciphertext) Proposal 169.For internal use only (Alice side) Proposal 169.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringName of the algorithm for display.private final EncAlgoThe underlying algorithm family.private static final EncType[]The types indexed by their code.private final intThe two byte encryption type code.private final booleanTrue if the implementation is available.private final booleanTrue for a post quantum type.private final AlgorithmParameterSpecParameters of the algorithm, if any.private final intLength of the private key, in bytes.private final intLength of the public key, in bytes.private final StringVersion that introduced this type.Constructor Summary
ConstructorsModifierConstructorDescriptionprivateEncType(int cod, int pubLen, int privLen, EncAlgo baseAlgo, String transformation, AlgorithmParameterSpec pSpec, String supportedSince) Creates an encryption type with its parameters.Method Summary
Modifier and TypeMethodDescriptionThe standard name used for the Java crypto factories.The standard base algorithm name used for the Java crypto factories.static EncTypegetByCode(int code) Encryption type by code.intgetCode()The unique identifier for this type.The elliptic curve ECParameterSpec for ECDSA; DSAParameterSpec for DSA.intThe length of the private key, in bytes.intThe length of the public key, in bytes.The router version in which this type was first supported.booleanChecks if this encryption type is available in the JVM.static booleanisAvailable(int code) Checks if the encryption type with the given code is available.static booleanisAvailable(String stype) Checks if the encryption type with the given name or number is available.booleanisPQ()Checks if this is a post-quantum encryption type.static EncTypeparseEncType(String stype) Convenience for user apps.static EncTypeReturns the enum constant of this class with the specified name.static EncType[]values()Returns an array containing the constants of this enum class, in the order they are declared.private booleanChecks whether the implementation loads.
Enum Constant Details
ELGAMAL_2048
2048-bit MODP Group from RFC 3526. This is the default. Pubkey 256 bytes, privkey 256 bytes.EC_P256
Used by i2pd. Not yet supported by Java I2P. Pubkey 64 bytes; privkey 32 bytes. See proposal 145.EC_P384
Reserved, not used by anybody. Pubkey 96 bytes; privkey 48 bytes. See proposal 145.EC_P521
Reserved, not used by anybody. Pubkey 132 bytes; privkey 66 bytes. See proposal 145.ECIES_X25519
Proposal 144. Pubkey 32 bytes; privkey 32 bytes.MLKEM512_X25519
Proposal 169. Pubkey 32 bytes; privkey 32 bytes.MLKEM768_X25519
Proposal 169. Pubkey 32 bytes; privkey 32 bytes.MLKEM1024_X25519
Proposal 169. Pubkey 32 bytes; privkey 32 bytes.MLKEM512_X25519_INT
For internal use only (Alice side) Proposal 169. Pubkey 800 bytes; privkey 1632 bytes.MLKEM768_X25519_INT
For internal use only (Alice side) Proposal 169. Pubkey 1184 bytes; privkey 2400 bytes.MLKEM1024_X25519_INT
For internal use only (Alice side) Proposal 169. Pubkey 1568 bytes; privkey 3168 bytes.MLKEM512_X25519_CT
For internal use only (Bob side ciphertext) Proposal 169. Pubkey 768 bytes; privkey 0.MLKEM768_X25519_CT
For internal use only (Bob side ciphertext) Proposal 169. Pubkey 1088 bytes; privkey 0.MLKEM1024_X25519_CT
For internal use only (Bob side ciphertext) Proposal 169. Pubkey 1568 bytes; privkey 0.
Field Details
code
private final int codeThe two byte encryption type code.pubkeyLen
private final int pubkeyLenLength of the public key, in bytes.privkeyLen
private final int privkeyLenLength of the private key, in bytes.base
The underlying algorithm family.algoName
Name of the algorithm for display.since
Version that introduced this type.params
Parameters of the algorithm, if any.isAvail
private final boolean isAvailTrue if the implementation is available.isPQ
private final boolean isPQTrue for a post quantum type.BY_CODE
The types indexed by their code.
Constructor Details
EncType
private EncType(int cod, int pubLen, int privLen, EncAlgo baseAlgo, String transformation, AlgorithmParameterSpec pSpec, String supportedSince) Creates an encryption type with its parameters.- Parameters:
cod- the two byte encryption type codepubLen- length of the public key, in bytesprivLen- length of the private key, in bytesbaseAlgo- the underlying algorithm familytransformation- full JCE transformation string, e.g. "EC/None/NoPadding"pSpec- parameters of the algorithm, null if nonesupportedSince- version that introduced this type
Method Details
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
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 nameNullPointerException- if the argument is null
getCode
public int getCode()The unique identifier for this type.- Returns:
- the numeric code used in RouterInfo and LeaseSet encodings
getPubkeyLen
public int getPubkeyLen()The length of the public key, in bytes.- Returns:
- the key length in bytes
getPrivkeyLen
public int getPrivkeyLen()The length of the private key, in bytes.- Returns:
- the key length in bytes
getBaseAlgorithm
The standard base algorithm name used for the Java crypto factories.- Returns:
- the JCE base algorithm family, without the padding or digest mode
getAlgorithmName
The standard name used for the Java crypto factories.- Returns:
- the full JCE transformation string, base algorithm plus mode
getParams
The elliptic curve ECParameterSpec for ECDSA; DSAParameterSpec for DSA.- Returns:
- the algorithm's parameter spec, ECParameterSpec for ECDSA or DSAParameterSpec for DSA
- Throws:
InvalidParameterSpecException- if the algorithm is not available on this JVM.
getSupportedSince
The router version in which this type was first supported.- Returns:
- the supported since
isAvailable
public boolean isAvailable()Checks if this encryption type is available in the JVM.- Returns:
- true if supported in this JVM
x_isAvailable
private boolean x_isAvailable()Checks whether the implementation loads.- Returns:
- true if the cipher can be used
isAvailable
public static boolean isAvailable(int code) Checks if the encryption type with the given code is available.- Parameters:
code- the numeric code assigned to the encryption type- Returns:
- true if supported in this JVM
isAvailable
Checks if the encryption type with the given name or number is available.- Parameters:
stype- the encryption type code or name to look up, as accepted by parseEncType- Returns:
- true if supported in this JVM
isPQ
public boolean isPQ()Checks if this is a post-quantum encryption type.- Returns:
- true if this is a PQ type
getByCode
Encryption type by code.- Parameters:
code- the numeric code assigned to the encryption type- Returns:
- Null if not supported.
parseEncType