Enum Class ECAlgorithm

java.lang.Object
java.lang.Enum<ECAlgorithm>
io.inverno.mod.security.jose.jwa.ECAlgorithm
All Implemented Interfaces:
JWAAlgorithm<ECJWK>, Serializable, Comparable<ECAlgorithm>, Constable

public enum ECAlgorithm extends Enum<ECAlgorithm> implements JWAAlgorithm<ECJWK>

Elliptic Curve algorithms as defined by RFC7518.

Signature algorithms:

  • ES256
  • ES384
  • ES512
  • ES256K (deprecated)

These algorithms are bound to the following Elliptic curves respectively: ECCurve.P_256, ECCurve.P_384, ECCurve.P_521 and ECCurve.SECP256K1.

Key Management algorithms:

  • ECDH-ES
  • ECDH-ES+A128KW
  • ECDH-ES+A192KW
  • ECDH-ES+A256KW
Since:
1.5
Author:
Jeremy Kuhn
  • Enum Constant Details

    • ES256

      public static final ECAlgorithm ES256
      ES256 ECDSA signature algorithm as defined by RFC7518 Section 3.4
    • ES384

      public static final ECAlgorithm ES384
      ES384 ECDSA signature algorithm as defined by RFC7518 Section 3.4
    • ES512

      public static final ECAlgorithm ES512
      ES512 ECDSA signature algorithm as defined by RFC7518 Section 3.4
    • ES256K

      @Deprecated public static final ECAlgorithm ES256K
      Deprecated.
      secp256k1 elliptic curve has been disabled in the JDK (>=15), it can be activated by setting jdk.sunec.disableNative property to false (-Djdk.sunec.disableNative=false)
      ES256K ECDSA signature algorithm as defined by RFC8812 Section 3.2
    • ECDH_ES

      public static final ECAlgorithm ECDH_ES
      ECDH-ES Elliptic Curve Diffie-Hellman key agreement algorithm as defined by RFC7518 Section 4.6
    • ECDH_ES_A128KW

      public static final ECAlgorithm ECDH_ES_A128KW
      ECDH-ES+A128KW Elliptic Curve Diffie-Hellman key agreement algorithm as defined by RFC7518 Section 4.6
    • ECDH_ES_A192KW

      public static final ECAlgorithm ECDH_ES_A192KW
      ECDH-ES+A192KW Elliptic Curve Diffie-Hellman key agreement algorithm as defined by RFC7518 Section 4.6
    • ECDH_ES_A256KW

      public static final ECAlgorithm ECDH_ES_A256KW
      ECDH-ES+A256KW Elliptic Curve Diffie-Hellman key agreement algorithm as defined by RFC7518 Section 4.6
  • Method Details

    • values

      public static ECAlgorithm[] 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 ECAlgorithm 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
    • getAlgorithm

      public String getAlgorithm()
      Description copied from interface: JWAAlgorithm

      Returns the JWA registered name of the algorithm.

      Specified by:
      getAlgorithm in interface JWAAlgorithm<ECJWK>
      Returns:
      a JWA registered name
    • isSignature

      public boolean isSignature()
      Description copied from interface: JWAAlgorithm

      Determines whether the algorithm is a signature algorithm.

      Specified by:
      isSignature in interface JWAAlgorithm<ECJWK>
      Returns:
      true if the algorithm is a signature algorithm, false otherwise
    • isKeyManagement

      public boolean isKeyManagement()
      Description copied from interface: JWAAlgorithm

      Determines whether the algorithm is a key management algorithm.

      Specified by:
      isKeyManagement in interface JWAAlgorithm<ECJWK>
      Returns:
      true if the algorithm is a key management algorithm, false otherwise
    • isEncryption

      public boolean isEncryption()
      Description copied from interface: JWAAlgorithm

      Determines whether the algorithm is an encryption algorithm.

      Specified by:
      isEncryption in interface JWAAlgorithm<ECJWK>
      Returns:
      true if the algorithm is an encryption algorithm, false otherwise
    • createSigner

      public JWASigner createSigner(ECJWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a signer from the algorithm.

      Specified by:
      createSigner in interface JWAAlgorithm<ECJWK>
      Parameters:
      jwk - the key to use for signing
      Returns:
      a JWA signer
      Throws:
      JWAProcessingException - if the algorithm is not a signature algorithm or if there was an error creating the signer
    • createKeyManager

      public JWAKeyManager createKeyManager(ECJWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a key manager from the algorithm.

      Specified by:
      createKeyManager in interface JWAAlgorithm<ECJWK>
      Parameters:
      jwk - the key to use for signing
      Returns:
      a JWA key manager
      Throws:
      JWAProcessingException - if the algorithm is not a key management algorithm or if there was an error creating the key manager
    • createCipher

      public JWACipher createCipher(ECJWK jwk) throws JWAProcessingException
      Description copied from interface: JWAAlgorithm

      Creates a cipher from the algorithm.

      Specified by:
      createCipher in interface JWAAlgorithm<ECJWK>
      Parameters:
      jwk - the key to use for signing
      Returns:
      a JWA cipher
      Throws:
      JWAProcessingException - if the algorithm is not an encryption algorithm or if there was an error creating the cipher
    • getJcaAlgorithm

      public String getJcaAlgorithm()

      Return the JCA algorithm corresponding to the JWA algorithm.

      Note that this is only applicable for signing algorithms.

      Returns:
      a JCA algorithm name or null
    • getCurve

      public ECCurve getCurve()

      Returns the Elliptic curve bound to the algorithm.

      Note that this does not apply to ECDH algorithms for which the curve is defined by an ephemeral key.

      Returns:
      an Elliptic curve or null
    • getKeyWrappingAlgorithm

      public String getKeyWrappingAlgorithm()

      Returns a JCA key wrapping algorithm to be used to wrap a derived key.

      Note that this does not apply to signing algorithm.

      Returns:
      a JCA key wrapping algorithm or null
    • fromAlgorithm

      public static ECAlgorithm fromAlgorithm(String alg) throws IllegalArgumentException

      Returns the Elliptic Curve algorithm corresponding to the specified JWA registered algorithm name.

      Parameters:
      alg - a JWA registered algorithm name
      Returns:
      an Elliptic curve algorithm
      Throws:
      IllegalArgumentException - if the specified algorithm is not an EC algorithm