All Implemented Interfaces:
Serializable, Comparable<EncType>, java.lang.constant.Constable

public enum EncTypeextends Enum<EncType>
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.

  • Enum Constant Details

    • ELGAMAL_2048

      public static final EncType ELGAMAL_2048
      2048-bit MODP Group from RFC 3526. This is the default. Pubkey 256 bytes, privkey 256 bytes.
    • EC_P256

      public static final EncType EC_P256
      Used by i2pd. Not yet supported by Java I2P. Pubkey 64 bytes; privkey 32 bytes. See proposal 145.
    • EC_P384

      public static final EncType EC_P384
      Reserved, not used by anybody. Pubkey 96 bytes; privkey 48 bytes. See proposal 145.
    • EC_P521

      public static final EncType EC_P521
      Reserved, not used by anybody. Pubkey 132 bytes; privkey 66 bytes. See proposal 145.
    • ECIES_X25519

      public static final EncType ECIES_X25519
      Proposal 144. Pubkey 32 bytes; privkey 32 bytes.
    • MLKEM512_X25519

      public static final EncType MLKEM512_X25519
      Proposal 169. Pubkey 32 bytes; privkey 32 bytes.
    • MLKEM768_X25519

      public static final EncType MLKEM768_X25519
      Proposal 169. Pubkey 32 bytes; privkey 32 bytes.
    • MLKEM1024_X25519

      public static final EncType MLKEM1024_X25519
      Proposal 169. Pubkey 32 bytes; privkey 32 bytes.
    • MLKEM512_X25519_INT

      public static final EncType MLKEM512_X25519_INT
      For internal use only (Alice side) Proposal 169. Pubkey 800 bytes; privkey 1632 bytes.
    • MLKEM768_X25519_INT

      public static final EncType MLKEM768_X25519_INT
      For internal use only (Alice side) Proposal 169. Pubkey 1184 bytes; privkey 2400 bytes.
    • MLKEM1024_X25519_INT

      public static final EncType MLKEM1024_X25519_INT
      For internal use only (Alice side) Proposal 169. Pubkey 1568 bytes; privkey 3168 bytes.
    • MLKEM512_X25519_CT

      public static final EncType MLKEM512_X25519_CT
      For internal use only (Bob side ciphertext) Proposal 169. Pubkey 768 bytes; privkey 0.
    • MLKEM768_X25519_CT

      public static final EncType MLKEM768_X25519_CT
      For internal use only (Bob side ciphertext) Proposal 169. Pubkey 1088 bytes; privkey 0.
    • MLKEM1024_X25519_CT

      public static final EncType MLKEM1024_X25519_CT
      For internal use only (Bob side ciphertext) Proposal 169. Pubkey 1568 bytes; privkey 0.
  • Field Details

    • code

      private final int code
      The two byte encryption type code.
    • pubkeyLen

      private final int pubkeyLen
      Length of the public key, in bytes.
    • privkeyLen

      private final int privkeyLen
      Length of the private key, in bytes.
    • base

      private final EncAlgo base
      The underlying algorithm family.
    • algoName

      private final String algoName
      Name of the algorithm for display.
    • since

      private final String since
      Version that introduced this type.
    • params

      private final AlgorithmParameterSpec params
      Parameters of the algorithm, if any.
    • isAvail

      private final boolean isAvail
      True if the implementation is available.
    • isPQ

      private final boolean isPQ
      True for a post quantum type.
    • BY_CODE

      private static final EncType[] 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 code
      pubLen - length of the public key, in bytes
      privLen - length of the private key, in bytes
      baseAlgo - the underlying algorithm family
      transformation - full JCE transformation string, e.g. "EC/None/NoPadding"
      pSpec - parameters of the algorithm, null if none
      supportedSince - version that introduced this type
  • Method Details

    • values

      public static EncType[] 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

      public static EncType valueOf(String name)
      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 name
      NullPointerException - 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

      public EncAlgo 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

      public String 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

      public String 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

      public static boolean isAvailable(String stype)
      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

      public static EncType getByCode(int code)
      Encryption type by code.
      Parameters:
      code - the numeric code assigned to the encryption type
      Returns:
      Null if not supported.
    • parseEncType

      public static EncType parseEncType(String stype)
      Convenience for user apps.
      Parameters:
      stype - the encryption type code or name to look up, as accepted by parseEncType
      Returns:
      null if not found