Enum Class JwsAlgorithm

java.lang.Object
java.lang.Enum<JwsAlgorithm>
com.revetsec.jose.JwsAlgorithm
All Implemented Interfaces:
Serializable, Comparable<JwsAlgorithm>, Constable

A JWS signature algorithm, named by its alg header value (RFC 7515 section 4.1.1, RFC 7518 section 3.1, RFC 8037 section 3.1 and RFC 9864).

Revetsec verifies RSASSA-PKCS1-v1_5 (RS*), RSASSA-PSS (PS*), ECDSA on P-256, P-384 and P-521 (ES*) and EdDSA over Ed25519, which RFC 9864 names Ed25519 and the older RFC 8037 names EdDSA. EdDSA is accepted for Ed25519 keys only. The HMAC algorithms (HS*) can be named here, but JwtValidator refuses them: it verifies only with public keys. There is no constant for none.

Wire values are compared exactly and case-sensitively, so rs256 and NONE name no algorithm here.

This enum is not switch-stable: a later release may add constants, so a switch over it needs a default branch.

Since:
1.0.0
Author:
Mark Allen
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    EdDSA over Ed25519, by its fully specified name (Ed25519, RFC 9864).
    EdDSA (EdDSA, RFC 8037 section 3.1), accepted for Ed25519 keys only.
    ECDSA on P-256 with SHA-256 (ES256, RFC 7518 section 3.4).
    ECDSA on P-384 with SHA-384 (ES384, RFC 7518 section 3.4).
    ECDSA on P-521 with SHA-512 (ES512, RFC 7518 section 3.4).
    HMAC with SHA-256 (HS256, RFC 7518 section 3.2).
    HMAC with SHA-384 (HS384, RFC 7518 section 3.2).
    HMAC with SHA-512 (HS512, RFC 7518 section 3.2).
    RSASSA-PSS with SHA-256, MGF1 with SHA-256 and a 32-byte salt (PS256, RFC 7518 section 3.5).
    RSASSA-PSS with SHA-384, MGF1 with SHA-384 and a 48-byte salt (PS384, RFC 7518 section 3.5).
    RSASSA-PSS with SHA-512, MGF1 with SHA-512 and a 64-byte salt (PS512, RFC 7518 section 3.5).
    RSASSA-PKCS1-v1_5 with SHA-256 (RS256, RFC 7518 section 3.3).
    RSASSA-PKCS1-v1_5 with SHA-384 (RS384, RFC 7518 section 3.3).
    RSASSA-PKCS1-v1_5 with SHA-512 (RS512, RFC 7518 section 3.3).
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the algorithm named by an alg value, compared exactly and case-sensitively.
    Returns this algorithm's alg value.
    Returns the enum constant of this class with the specified name.
    static JwsAlgorithm[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • RS256

      public static final JwsAlgorithm RS256
      RSASSA-PKCS1-v1_5 with SHA-256 (RS256, RFC 7518 section 3.3).
    • RS384

      public static final JwsAlgorithm RS384
      RSASSA-PKCS1-v1_5 with SHA-384 (RS384, RFC 7518 section 3.3).
    • RS512

      public static final JwsAlgorithm RS512
      RSASSA-PKCS1-v1_5 with SHA-512 (RS512, RFC 7518 section 3.3).
    • PS256

      public static final JwsAlgorithm PS256
      RSASSA-PSS with SHA-256, MGF1 with SHA-256 and a 32-byte salt (PS256, RFC 7518 section 3.5).
    • PS384

      public static final JwsAlgorithm PS384
      RSASSA-PSS with SHA-384, MGF1 with SHA-384 and a 48-byte salt (PS384, RFC 7518 section 3.5).
    • PS512

      public static final JwsAlgorithm PS512
      RSASSA-PSS with SHA-512, MGF1 with SHA-512 and a 64-byte salt (PS512, RFC 7518 section 3.5).
    • ES256

      public static final JwsAlgorithm ES256
      ECDSA on P-256 with SHA-256 (ES256, RFC 7518 section 3.4).
    • ES384

      public static final JwsAlgorithm ES384
      ECDSA on P-384 with SHA-384 (ES384, RFC 7518 section 3.4).
    • ES512

      public static final JwsAlgorithm ES512
      ECDSA on P-521 with SHA-512 (ES512, RFC 7518 section 3.4).
    • ED25519

      public static final JwsAlgorithm ED25519
      EdDSA over Ed25519, by its fully specified name (Ed25519, RFC 9864).
    • EDDSA

      public static final JwsAlgorithm EDDSA
      EdDSA (EdDSA, RFC 8037 section 3.1), accepted for Ed25519 keys only. RFC 9864 deprecates this name (section 4.1.2) in favor of fully specified ones, ED25519 for Ed25519 keys (section 2.2). On an Ed25519 key both name the same operation, so a key whose alg is one of the two verifies tokens that name the other; that alias is Revetsec's, not the RFC's.
    • HS256

      public static final JwsAlgorithm HS256
      HMAC with SHA-256 (HS256, RFC 7518 section 3.2). JwtValidator refuses it.
    • HS384

      public static final JwsAlgorithm HS384
      HMAC with SHA-384 (HS384, RFC 7518 section 3.2). JwtValidator refuses it.
    • HS512

      public static final JwsAlgorithm HS512
      HMAC with SHA-512 (HS512, RFC 7518 section 3.2). JwtValidator refuses it.
  • Method Details

    • values

      public static JwsAlgorithm[] 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 JwsAlgorithm 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
    • findByWireValue

      Returns the algorithm named by an alg value, compared exactly and case-sensitively.
      Parameters:
      wireValue - the alg value, such as RS256 or Ed25519
      Returns:
      the algorithm, or empty if wireValue names none of these algorithms
      Throws:
      NullPointerException - if wireValue is null
      Since:
      1.0.0
    • getWireValue

      Returns this algorithm's alg value.
      Returns:
      the alg value, such as RS256 or Ed25519
      Since:
      1.0.0