R
- the type of Request
used when computing a digest.V
- the type of VerifyDigestRequest
used when verifying a digest.public interface DigestAlgorithm<R extends Request<InputStream>,V extends VerifyDigestRequest> extends Identifiable
DigestAlgorithm
is a
Cryptographic Hash Function
that computes and verifies cryptographic digests. There are three types of DigestAlgorithm
s represented
by subtypes, and RFC-standard implementations are available as constants in Registry
singletons:
Subtype | Standard Implementation Registry | Security Model |
---|---|---|
HashAlgorithm |
Jwks.HASH |
Unsecured (unkeyed), does not require a key to compute or verify digests. |
MacAlgorithm |
Jwts.SIG |
Requires a SecretKey to both compute and verify digests (aka
"Message Authentication Codes"). |
SignatureAlgorithm |
Jwts.SIG |
Requires a PrivateKey to compute and PublicKey to verify digests
(aka "Digital Signatures"). |
Standard Identifier
DigestAlgorithm
extends Identifiable
: the value returned from
getId()
will be used as the JWT standard identifier where required.
For example,
when a MacAlgorithm
or SignatureAlgorithm
is used to secure a JWS, the value returned from
algorithm.getId()
will be used as the JWS "alg"
protected header value. Or when a
HashAlgorithm
is used to compute a JwkThumbprint
, it's algorithm.getId()
value will be
used within the thumbprint's URI
per JWT RFC requirements.
byte[] digest(R request) throws SecurityException
payload
.request
- the request containing the data to be hashed, mac'd or signed.payload
.SecurityException
- if there is invalid key input or a problem during digest creation.boolean verify(V request) throws SecurityException
true
if the provided digest
matches the expected value
for the given payload
, false
otherwise.request
- the request containing the digest
to verify for the
associated payload
.true
if the provided digest
matches the expected value
for the given payload
, false
otherwise.SecurityException
- if there is an invalid key input or a problem that won't allow digest verification.Copyright © 2014–2024 jsonwebtoken.io. All rights reserved.