Interface JWSAlgorithm
- All Superinterfaces:
de.christofreichardt.diagnosis.Traceable
- All Known Implementing Classes:
HmacSHA256, SHA256withECDSA, SHA256withRSA, SHA512WithECDSA
public interface JWSAlgorithm
extends de.christofreichardt.diagnosis.Traceable
All algorithm classes used for signing or validating must implement this interface. The methods below are acting as adapters
between the instances responsible for signing (or rather validating) and the cryptographic algorithms provided by the
Java platform.
- Author:
- Christof Reichardt
-
Method Summary
Modifier and TypeMethodDescriptionReturns the name of the underlying algorithm object.voidInitialises the underlying algorithm provided by the Java platform with the given key.postSigning(byte[] signature) Optional post-processing of the signature bytes, for example the signature bytes might be DER encoded and RFC 7515 or rather RFC 7518 require a different format.byte[]preValidating(byte[] signature) Optional pre-processing of the to be validated signature bytes, for example the verifying algorithm instance given by the Java runtime might require DER encoded signature bytes.byte[]Requests a signature from the underlying algorithm for the delivered bytes.voidupdate(byte[] data) Hands over the given bytes to the underlying algorithm provided by the Java platform.booleanverify(byte[] signature) Requests the validation of the delivered data agianst the given signature.Methods inherited from interface de.christofreichardt.diagnosis.Traceable
getCurrentTracer
-
Method Details
-
init
Initialises the underlying algorithm provided by the Java platform with the given key.- Parameters:
key- the cryptographic key used for signing or validating.- Throws:
GeneralSecurityException- if something goes wrong during the initialization.
-
update
Hands over the given bytes to the underlying algorithm provided by the Java platform.- Parameters:
data- the data to be signed or to be validated.- Throws:
GeneralSecurityException- if something goes wrong during the update, e.g. the underlying algorithm hasn't been properly initialized.
-
signature
Requests a signature from the underlying algorithm for the delivered bytes.- Returns:
- the signature bytes
- Throws:
GeneralSecurityException- if the underlying algorithm couldn't process the delivered data for various reasons.
-
verify
Requests the validation of the delivered data agianst the given signature.- Parameters:
signature- the signature bytes.- Returns:
- indicates if the signature has been valid.
- Throws:
GeneralSecurityException- if the underlying algorithm couldn't process the delivered data for various reasons.
-
algorithm
String algorithm()Returns the name of the underlying algorithm object.- Returns:
- the name of the underlying algorithm object.
-
postSigning
Optional post-processing of the signature bytes, for example the signature bytes might be DER encoded and RFC 7515 or rather RFC 7518 require a different format.- Parameters:
signature- the signature bytes.- Returns:
- the optionally processed signature bytes
-
preValidating
byte[] preValidating(byte[] signature) Optional pre-processing of the to be validated signature bytes, for example the verifying algorithm instance given by the Java runtime might require DER encoded signature bytes.- Parameters:
signature- the signature bytes.- Returns:
- the optionally processed signature bytes
-