net.i2p.crypto

## Enum EncType

- java.lang.Object
- - java.lang.Enum<EncType>
  - - net.i2p.crypto.EncType

- All Implemented Interfaces:
    Serializable, Comparable<EncType>

      public enum EncType
      extends 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 Summary

    Enum Constants
    Enum Constant and Description
    `EC_P256` Used by i2pd.
    `EC_P384` Reserved, not used by anybody.
    `EC_P521` Reserved, not used by anybody.
    `ECIES_X25519` Proposal 144.
    `ELGAMAL_2048` 2048-bit MODP Group from RFC 3526.
    `MLKEM1024_X25519` Proposal 169.
    `MLKEM1024_X25519_CT` For internal use only (Bob side ciphertext) Proposal 169.
    `MLKEM1024_X25519_INT` For internal use only (Alice side) Proposal 169.
    `MLKEM512_X25519` Proposal 169.
    `MLKEM512_X25519_CT` For internal use only (Bob side ciphertext) Proposal 169.
    `MLKEM512_X25519_INT` For internal use only (Alice side) Proposal 169.
    `MLKEM768_X25519` Proposal 169.
    `MLKEM768_X25519_CT` For internal use only (Bob side ciphertext) Proposal 169.
    `MLKEM768_X25519_INT` For internal use only (Alice side) Proposal 169.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getAlgorithmName()` the standard name used for the Java crypto factories
    `EncAlgo` | `getBaseAlgorithm()` the standard base algorithm name used for the Java crypto factories
    `static EncType` | `getByCode(int code)` Gets the encryption type by code.
    `int` | `getCode()` the unique identifier for this type
    `AlgorithmParameterSpec` | `getParams()` The elliptic curve ECParameterSpec for ECDSA; DSAParameterSpec for DSA
    `int` | `getPrivkeyLen()` the length of the private key, in bytes
    `int` | `getPubkeyLen()` the length of the public key, in bytes
    `String` | `getSupportedSince()` The router version in which this type was first supported.
    `boolean` | `isAvailable()` Checks if this encryption type is available in the JVM.
    `static boolean` | `isAvailable(int code)` Checks if the encryption type with the given code is available.
    `static boolean` | `isAvailable(String stype)` Checks if the encryption type with the given name or number is available.
    `boolean` | `isPQ()` Checks if this is a post-quantum encryption type.
    `static EncType` | `parseEncType(String stype)` Convenience for user apps
    `static EncType` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static EncType[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### 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

    - #### 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.

    - #### MLKEM1024_X25519

          public static final EncType MLKEM1024_X25519

      Proposal 169. Pubkey 32 bytes; privkey 32 bytes

    - #### MLKEM1024_X25519_CT

          public static final EncType MLKEM1024_X25519_CT

      For internal use only (Bob side ciphertext) Proposal 169. Pubkey 1568 bytes; privkey 0

    - #### 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

          public static final EncType MLKEM512_X25519

      Proposal 169. Pubkey 32 bytes; privkey 32 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

    - #### 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

          public static final EncType MLKEM768_X25519

      Proposal 169. Pubkey 32 bytes; privkey 32 bytes

    - #### MLKEM768_X25519_CT

          public static final EncType MLKEM768_X25519_CT

      For internal use only (Bob side ciphertext) Proposal 169. Pubkey 1088 bytes; privkey 0

    - #### MLKEM768_X25519_INT

          public static final EncType MLKEM768_X25519_INT

      For internal use only (Alice side) Proposal 169. Pubkey 1184 bytes; privkey 2400 bytes

  - ### Method Detail

    - #### getAlgorithmName

          public String getAlgorithmName()

      the standard name used for the Java crypto factories

    - #### getBaseAlgorithm

          public EncAlgo getBaseAlgorithm()

      the standard base algorithm name used for the Java crypto factories

    - #### getByCode

          public static EncType getByCode(int code)

      Gets the encryption type by code.
      Returns:
        null if not supported

    - #### getCode

          public int getCode()

      the unique identifier for this type

    - #### getParams

          public AlgorithmParameterSpec getParams()
                                           throws InvalidParameterSpecException

      The elliptic curve ECParameterSpec for ECDSA; DSAParameterSpec for DSA
      Throws:
        `InvalidParameterSpecException` - if the algorithm is not available on this JVM.

    - #### getPrivkeyLen

          public int getPrivkeyLen()

      the length of the private key, in bytes

    - #### getPubkeyLen

          public int getPubkeyLen()

      the length of the public key, in bytes

    - #### getSupportedSince

          public String getSupportedSince()

      The router version in which this type was first supported.

    - #### isAvailable

          public boolean isAvailable()

      Checks if this encryption type is available in the JVM.
      Returns:
        true if supported in this JVM

    - #### isAvailable

          public static boolean isAvailable(int code)

      Checks if the encryption type with the given code is available.
      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` - number or name
      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

    - #### parseEncType

          public static EncType parseEncType(String stype)

      Convenience for user apps
      Parameters:
        `stype` - number or name
      Returns:
        null if not found

    - #### valueOf

          public static EncType valueOf(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:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### values

          public static EncType[] 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 (EncType c : EncType.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared