Class ChaChaSpec
java.lang.Object
zeroecho.core.alg.chacha.ChaChaSpec
- All Implemented Interfaces:
ChaChaBaseSpec, Describable, ContextSpec
ChaCha20 stream cipher specification
Immutable parameter set for configuring aChaCha20 context. Provides
an initial counter and an optional SymmetricHeaderCodec.
Fields
initialCounter()- the initial block counter used when no counter is present in the context or header (must be non-negative). Default is1, matching common practice.header()- optional codec for encoding/decoding a stream header that carries runtime parameters such as nonce and counter.
Construction
Use the fluentChaChaSpec.Builder: ChaChaSpec spec = ChaChaSpec.builder()
.initialCounter(42)
.header(new ChaChaHeaderCodec())
.build();
Convenience factory
chacha20(SymmetricHeaderCodec)returns a spec with initial counter1and the provided header codec.
- Since:
- 1.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ChaChaSpec.Builderbuilder()Returns a new builder for constructing aChaChaSpec.static ChaChaSpecchacha20(SymmetricHeaderCodec header) Convenience factory for a ChaCha20 spec with counter = 1.Human-readable description of this spec.header()Returns the optional header codec.intReturns the configured initial counter.
-
Method Details
-
builder
Returns a new builder for constructing aChaChaSpec.- Returns:
- fresh builder instance
-
chacha20
Convenience factory for a ChaCha20 spec with counter = 1.- Parameters:
header- optional header codec- Returns:
- new spec instance
-
initialCounter
public int initialCounter()Returns the configured initial counter.- Returns:
- non-negative counter value
-
header
Returns the optional header codec.- Specified by:
headerin interfaceChaChaBaseSpec- Returns:
- codec instance or
null
-
description
Human-readable description of this spec.- Specified by:
descriptionin interfaceDescribable- Returns:
- string of the form
"ChaCha20(counter=N)"
-