Record Class ChaChaKeyGenSpec

java.lang.Object
java.lang.Record
zeroecho.core.alg.chacha.ChaChaKeyGenSpec
Record Components:
keySizeBits - key size in bits (must be 256)
All Implemented Interfaces:
Describable, AlgorithmKeySpec

public record ChaChaKeyGenSpec(int keySizeBits) extends Record implements AlgorithmKeySpec, Describable

ChaCha20 key generation specification

Immutable record describing the key size for ChaCha20 key generation. Only 256-bit keys are permitted by the ChaCha20 design.

Validation

Factory method

  • chacha256() provides a convenient way to obtain a standard 256-bit spec.

Usage example


 ChaChaKeyGenSpec spec = ChaChaKeyGenSpec.chacha256();
 SecretKey key = cryptoAlgorithm.generateSecret(spec);
 
Since:
1.0
  • Constructor Details

    • ChaChaKeyGenSpec

      public ChaChaKeyGenSpec(int keySizeBits)
      Constructs a new ChaCha20 key generation spec.
      Parameters:
      keySizeBits - must be 256; otherwise an exception is thrown
      Throws:
      IllegalArgumentException - if keySizeBits != 256
  • Method Details

    • chacha256

      public static ChaChaKeyGenSpec chacha256()
      Returns the standard 256-bit key generation spec.
      Returns:
      a new ChaChaKeyGenSpec with size 256
    • description

      public String description()
      Returns a short human-readable description of this spec.
      Specified by:
      description in interface Describable
      Returns:
      the string "256bits"
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • keySizeBits

      public int keySizeBits()
      Returns the value of the keySizeBits record component.
      Returns:
      the value of the keySizeBits record component