Package zeroecho.core.alg.digest
Class Sha2Sha3Algorithm
java.lang.Object
zeroecho.core.CryptoAlgorithm
zeroecho.core.alg.AbstractCryptoAlgorithm
zeroecho.core.alg.digest.Sha2Sha3Algorithm
SHA-2, SHA-3, and SHAKE digest algorithms
Implementation of theCryptoAlgorithm abstraction for unkeyed hash
functions from the SHA-2 and SHA-3 families, including extendable-output
functions (XOFs) such as SHAKE128 and SHAKE256.
This algorithm is registered under the canonical identifier "DIGEST"
with the display name "SHA-2/SHA-3/SHAKE".
Capabilities
The algorithm declares a single capability:- Family:
AlgorithmFamily.DIGEST - Role:
KeyUsage.DIGEST - Context type:
DigestContext - Key type:
NullKey(no cryptographic key required) - Spec type:
DigestSpec(algorithm selection) - Default spec:
DigestSpec.sha256()
Provider model
Internally, this class delegates to the JCAMessageDigest implementation corresponding to the
chosen digest variant. The constructor performs lookup via
MessageDigest.getInstance(String), and wraps the result in a
JcaDigestContext.
Usage example
// Acquire algorithm via static registry
CryptoAlgorithm algo = CryptoAlgorithms.require("DIGEST");
// Create a digest context for SHA3-512
DigestContext ctx = CryptoAlgorithms.create(
"DIGEST", KeyUsage.DIGEST, NullKey.INSTANCE, DigestSpec.sha3_512());
// Stream data into the digest
ctx.update(inputStream);
byte[] hash = ctx.doFinal();
The NullKey sentinel must always be provided for the key argument
since digests are unkeyed functions. The DigestSpec determines the
exact digest variant (SHA-256, SHA-512, SHA3-256, SHAKE128, etc.).
Thread-safety
TheSha2Sha3Algorithm instance is immutable
and can be shared across threads. The created DigestContext objects
are not thread-safe and must not be used concurrently.- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class zeroecho.core.CryptoAlgorithm
CryptoAlgorithm.AsymBuilderInfo, CryptoAlgorithm.SymBuilderInfo -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the SHA-2/SHA-3/SHAKE digest algorithm definition and registers itsCapability. -
Method Summary
Methods inherited from class zeroecho.core.alg.AbstractCryptoAlgorithm
capabilityMethods inherited from class zeroecho.core.CryptoAlgorithm
addCapability, asymmetricBuildersInfo, asymmetricKeyBuilder, bind, create, displayName, generateKeyPair, generateKeyPair, generateSecret, id, importPrivate, importPublic, importSecret, listCapabilities, priority, providerName, registerAsymmetricKeyBuilder, registerSymmetricKeyBuilder, roles, supports, symmetricBuildersInfo, symmetricKeyBuilder
-
Constructor Details
-
Sha2Sha3Algorithm
public Sha2Sha3Algorithm()Constructs the SHA-2/SHA-3/SHAKE digest algorithm definition and registers itsCapability.The default digest specification is
DigestSpec.sha256(), ensuring compatibility with common tests and catalog listings.
-