Package zeroecho.core.alg.chacha
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
- The constructor enforces
keySizeBits == 256. - Any other size results in an
IllegalArgumentException.
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 Summary
ConstructorsConstructorDescriptionChaChaKeyGenSpec(int keySizeBits) Constructs a new ChaCha20 key generation spec. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChaChaKeyGenSpecReturns the standard 256-bit key generation spec.Returns a short human-readable description of this spec.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of thekeySizeBitsrecord component.final StringtoString()Returns a string representation of this record class.
-
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- ifkeySizeBits != 256
-
-
Method Details
-
chacha256
Returns the standard 256-bit key generation spec.- Returns:
- a new
ChaChaKeyGenSpecwith size 256
-
description
Returns a short human-readable description of this spec.- Specified by:
descriptionin interfaceDescribable- Returns:
- the string
"256bits"
-
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. -
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. -
equals
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 '=='. -
keySizeBits
public int keySizeBits()Returns the value of thekeySizeBitsrecord component.- Returns:
- the value of the
keySizeBitsrecord component
-