Class AesSpec.Builder
java.lang.Object
zeroecho.core.alg.aes.AesSpec.Builder
- Enclosing class:
AesSpec
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a validatedAesSpec.header(SymmetricHeaderCodec codec) Installs a header codec used by the cipher context to persist and recover runtime parameters (e.g., IV, tag length, AAD hash).mode(AesSpec.Mode m) Selects the AES mode.Selects the padding scheme for CBC.tagLenBits(int t) Sets the GCM authentication tag length in bits.
-
Constructor Details
-
Builder
public Builder()Creates a builder initialized for AES-GCM with a 128-bit tag.
-
-
Method Details
-
mode
Selects the AES mode.- Parameters:
m- the block mode (AesSpec.Mode.CBC,AesSpec.Mode.GCM, orAesSpec.Mode.CTR)- Returns:
- this builder
- Throws:
NullPointerException- ifmisnull
-
padding
Selects the padding scheme for CBC.Ignored for GCM and CTR, which always use
AesSpec.Padding.NOPADDING.- Parameters:
p- the padding scheme- Returns:
- this builder
- Throws:
NullPointerException- ifpisnull
-
tagLenBits
Sets the GCM authentication tag length in bits.Valid only when the mode is
AesSpec.Mode.GCM. The value must be 96, 104, 112, 120, or 128.- Parameters:
t- the tag length in bits- Returns:
- this builder
-
header
Installs a header codec used by the cipher context to persist and recover runtime parameters (e.g., IV, tag length, AAD hash).When
null, no header is written or parsed.- Parameters:
codec- the codec to embed, ornullto disable- Returns:
- this builder
-
build
Builds a validatedAesSpec.Validation rules:
- If mode is
AesSpec.Mode.GCM, padding must beAesSpec.Padding.NOPADDINGandtagLenBitsmust be 96–128 in steps of 8. - If mode is not GCM,
tagLenBitsmust be 0.
- Returns:
- an immutable specification
- Throws:
IllegalArgumentException- if parameters are inconsistent
- If mode is
-