Package org.xwiki.crypto.signer
Interface Signer
-
public interface Signer
Interface on a signer engines ready to process data for signing or verification.- Since:
- 5.4RC1
- Version:
- $Id: 675eb0563d4ce474354596b38ceda75f3f603fe5 $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
generate()
Generate a signature for the accumulated data.byte[]
generate(byte[] input)
Generate a signature for the accumulated data, including the provided buffer.byte[]
generate(byte[] input, int inputOffset, int inputLen)
Generate a signature for the accumulated data, including the part of the provided buffer.String
getAlgorithmName()
byte[]
getEncoded()
FilterInputStream
getInputStream(InputStream is)
Return a pass through input stream, all data will be accumulated for calculating signatures.OutputStream
getOutputStream()
Return a pass through output stream, all data will be accumulated for calculating signatures.boolean
isForSigning()
void
update(byte input)
Accumulate byte data to calculate signature.void
update(byte[] input)
Accumulate byte array data to calculate signature.void
update(byte[] input, int inputOffset, int inputLen)
Accumulate part of a byte array to calculate signature.boolean
verify(byte[] signature)
Verify the given signature against the accumulated data.boolean
verify(byte[] signature, byte[] input)
Verify the given signature against the accumulated data, including the provided buffer.boolean
verify(byte[] signature, int signOffset, int signLen, byte[] input, int inputOffset, int inputLen)
Verify the given signature against the accumulated data, including the part of the provided buffer.
-
-
-
Method Detail
-
getAlgorithmName
String getAlgorithmName()
- Returns:
- the algorithm name of the underlying signer.
-
isForSigning
boolean isForSigning()
- Returns:
- true if the signer is initialised for signing, and false for verifying.
-
getInputStream
FilterInputStream getInputStream(InputStream is)
Return a pass through input stream, all data will be accumulated for calculating signatures. The signer is reset each time this function is called.- Parameters:
is
- an input stream to read from and pass through.- Returns:
- a pass through input stream.
-
getOutputStream
OutputStream getOutputStream()
Return a pass through output stream, all data will be accumulated for calculating signatures. The signer is reset each time this function is called.- Returns:
- an output stream to this signer.
-
update
void update(byte input)
Accumulate byte data to calculate signature.- Parameters:
input
- a byte.
-
update
void update(byte[] input)
Accumulate byte array data to calculate signature.- Parameters:
input
- a byte array.
-
update
void update(byte[] input, int inputOffset, int inputLen)
Accumulate part of a byte array to calculate signature.- Parameters:
input
- the input buffer.inputOffset
- the offset in input where the input starts.inputLen
- the input length.
-
generate
byte[] generate() throws GeneralSecurityException
Generate a signature for the accumulated data. The bytes that have been accumulated during a previous update or stream operations are signed. Upon finish, this method resets this signer.- Returns:
- a buffer with the signature.
- Throws:
GeneralSecurityException
- if this signing algorithm is unable to proceed properly.
-
generate
byte[] generate(byte[] input) throws GeneralSecurityException
Generate a signature for the accumulated data, including the provided buffer. The bytes that have been accumulated during a previous update or stream operations appended with the given input buffer are signed. Upon finish, this method resets this signer.- Parameters:
input
- the input buffer.- Returns:
- a buffer with the signature.
- Throws:
GeneralSecurityException
- if this signing algorithm is unable to proceed properly.
-
generate
byte[] generate(byte[] input, int inputOffset, int inputLen) throws GeneralSecurityException
Generate a signature for the accumulated data, including the part of the provided buffer. The bytes that have been accumulated during a previous update or stream operations appended with the first inputLen bytes in the input buffer, starting at inputOffset inclusive, are signed. Upon finish, this method resets this signer.- Parameters:
input
- the input buffer.inputOffset
- the offset in input where the input starts.inputLen
- the input length.- Returns:
- a buffer with the signature.
- Throws:
GeneralSecurityException
- if this signing algorithm is unable to proceed properly.
-
verify
boolean verify(byte[] signature) throws GeneralSecurityException
Verify the given signature against the accumulated data. The bytes that have been accumulated during a previous update or stream operations are signed, and signatures are compared. Upon finish, this method resets this signer.- Parameters:
signature
- to be verified.- Returns:
- true if signatures are equals.
- Throws:
GeneralSecurityException
- if this signing algorithm is unable to proceed properly.
-
verify
boolean verify(byte[] signature, byte[] input) throws GeneralSecurityException
Verify the given signature against the accumulated data, including the provided buffer. The bytes that have been accumulated during a previous update or stream operations appended with the given input buffer are signed, and signatures are compared. Upon finish, this method resets this signer.- Parameters:
signature
- to be verified.input
- the input buffer.- Returns:
- a buffer with the signature.
- Throws:
GeneralSecurityException
- if this signing algorithm is unable to proceed properly.
-
verify
boolean verify(byte[] signature, int signOffset, int signLen, byte[] input, int inputOffset, int inputLen) throws GeneralSecurityException
Verify the given signature against the accumulated data, including the part of the provided buffer. The bytes that have been accumulated during a previous update or stream operations appended with the first inputLen bytes in the input buffer, starting at inputOffset inclusive, are signed, and signatures are compared. Upon finish, this method resets this signer.- Parameters:
signature
- to be verified.signOffset
- the offset in signature buffer where the signature starts.signLen
- the signature length.input
- the input buffer.inputOffset
- the offset in input where the input starts.inputLen
- the input length.- Returns:
- a buffer with the signature.
- Throws:
GeneralSecurityException
- if this signing algorithm is unable to proceed properly.
-
getEncoded
byte[] getEncoded()
- Returns:
- the algorithm identifier of this signer in encoded form.
-
-