anon.crypto
Interface IMySignature

All Superinterfaces:
ISignatureCreationAlgorithm, ISignatureVerificationAlgorithm
All Known Implementing Classes:
MyDSASignature, MyECDSASignature, MyRSASignature

public interface IMySignature
extends ISignatureVerificationAlgorithm, ISignatureCreationAlgorithm

This interface represents a signature algorithm.


Method Summary
 byte[] decodeForXMLSignature(byte[] a_encodedSignature)
          Tries to decode a signature in a way as it would meet the W3C standard for XML signature values.
 byte[] encodeForXMLSignature(byte[] a_signature)
          Encodes a signature in a way it meets the W3C standard for XML signature values.
 java.lang.String getXMLSignatureAlgorithmReference()
          Returns a description of the the signature algorithm for XML signatures as defined in http://www.w3.org/TR/xmldsig-core/#sec-AlgID.
 void initSign(IMyPrivateKey a_privateKey)
          Initialises the algorithm for signing.
 void initVerify(IMyPublicKey a_publicKey)
          Initialises the algorithm for verifying.
 byte[] sign(byte[] a_message)
          Signs a message and returns the signature.
 boolean verify(byte[] a_message, byte[] a_signature)
          Tests if the signature of a specified message is valid.
 
Methods inherited from interface anon.crypto.ISignatureVerificationAlgorithm
getIdentifier, verify
 
Methods inherited from interface anon.crypto.ISignatureCreationAlgorithm
getIdentifier
 

Method Detail

initVerify

void initVerify(IMyPublicKey a_publicKey)
                throws java.security.InvalidKeyException
Initialises the algorithm for verifying. This must be done before doing the verify operation. The general contract of this method is that it must check if the algorithm has previously been initialised with the given key. If yes the method does nothing to save resources.

Parameters:
a_publicKey - a public key
Throws:
java.security.InvalidKeyException - if the key is invalid

initSign

void initSign(IMyPrivateKey a_privateKey)
              throws java.security.InvalidKeyException
Initialises the algorithm for signing. This must be done before doing the sign operation. The general contract of this method is that it must check if the algorithm has previously been initialised with the given key. If yes the method does nothing to save resources.

Parameters:
a_privateKey - a private key
Throws:
java.security.InvalidKeyException - if the key is invalid

verify

boolean verify(byte[] a_message,
               byte[] a_signature)
Tests if the signature of a specified message is valid.

Specified by:
verify in interface ISignatureVerificationAlgorithm
Parameters:
a_message - a message
a_signature - a signature
Returns:
true if the signature of a specified message is valid; false otherwiese

sign

byte[] sign(byte[] a_message)
Signs a message and returns the signature.

Specified by:
sign in interface ISignatureCreationAlgorithm
Parameters:
a_message - a message
Returns:
the signature that was created

encodeForXMLSignature

byte[] encodeForXMLSignature(byte[] a_signature)
Encodes a signature in a way it meets the W3C standard for XML signature values. Without this encoding, XML signatures cannot be created by this algorithm.

Specified by:
encodeForXMLSignature in interface ISignatureCreationAlgorithm
Parameters:
a_signature - an non-encoded signature
Returns:
the encoded signature or null if an error occured
See Also:
http://www.w3.org/TR/xmldsig-core/#sec-SignatureAlg

decodeForXMLSignature

byte[] decodeForXMLSignature(byte[] a_encodedSignature)
Tries to decode a signature in a way as it would meet the W3C standard for XML signature values. Without this decoding, XML signatures cannot be verified by this algorithm.

Specified by:
decodeForXMLSignature in interface ISignatureVerificationAlgorithm
Parameters:
a_encodedSignature - an encoded signature
Returns:
the decoded signature or null if an error occured
See Also:
http://www.w3.org/TR/xmldsig-core/#sec-SignatureAlg

getXMLSignatureAlgorithmReference

java.lang.String getXMLSignatureAlgorithmReference()
Returns a description of the the signature algorithm for XML signatures as defined in http://www.w3.org/TR/xmldsig-core/#sec-AlgID. This description is optional, documents may be signed without it.

Specified by:
getXMLSignatureAlgorithmReference in interface ISignatureCreationAlgorithm
Specified by:
getXMLSignatureAlgorithmReference in interface ISignatureVerificationAlgorithm
Returns:
a description of the the signature algorithm for XML signatures
See Also:
http://www.w3.org/TR/xmldsig-core/#sec-AlgID