Package zeroecho.core

Enum Class KeyUsage

java.lang.Object
java.lang.Enum<KeyUsage>
zeroecho.core.KeyUsage
All Implemented Interfaces:
Serializable, Comparable<KeyUsage>, Constable

public enum KeyUsage extends Enum<KeyUsage>
Declares the intended purpose(s) of a cryptographic key.

Keys should be bound to a specific KeyUsage at generation or import time. Enforcing usage prevents accidental cross-purposes — e.g., reusing a signing key for encryption, or using a MAC key for key agreement — which can lead to serious vulnerabilities.

Typical usages

  • SIGN/VERIFY: digital signature schemes (Ed25519, ECDSA, RSA-PSS).
  • ENCRYPT/DECRYPT: confidentiality with symmetric or asymmetric encryption.
  • ENCAPSULATE/DECAPSULATE: key encapsulation mechanisms (KEM).
  • MAC: keyed message authentication (e.g., HMAC, KMAC).
  • DIGEST: unkeyed hashing (e.g., SHA-256, SHA3-512).
  • AGREEMENT: key agreement (e.g., X25519, ECDH) to derive shared secrets.

Security note: Many real-world breaches trace back to cryptographic keys being used outside their intended purpose. Libraries should validate KeyUsage before performing operations.

Since:
1.0
  • Enum Constant Details

    • SIGN

      public static final KeyUsage SIGN
      Create digital signatures.
    • VERIFY

      public static final KeyUsage VERIFY
      Verify digital signatures.
    • ENCRYPT

      public static final KeyUsage ENCRYPT
      Encrypt data for confidentiality.
    • DECRYPT

      public static final KeyUsage DECRYPT
      Decrypt data that was encrypted under the matching key/parameters.
    • ENCAPSULATE

      public static final KeyUsage ENCAPSULATE
      Encapsulate a shared secret in a KEM flow.
    • DECAPSULATE

      public static final KeyUsage DECAPSULATE
      Decapsulate a shared secret in a KEM flow.
    • MAC

      public static final KeyUsage MAC
      Compute a keyed message authentication code (e.g., HMAC, KMAC).
    • DIGEST

      public static final KeyUsage DIGEST
      Compute an unkeyed hash (e.g., SHA-256), pipeline-friendly.
    • AGREEMENT

      public static final KeyUsage AGREEMENT
      Perform key agreement (e.g., X25519, ECDH).
  • Method Details

    • values

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