#include <DSIGSignature.hpp>
Collaboration diagram for DSIGSignature:
The DSIGSignature class is used to manipulate and verify <signature> blocks. It should only ever be created via the XSECProvider class.
Public Member Functions | |
Load and Setup Functions | |
void | load (void) |
Load the signature information from the DOM source. | |
void | setSigningKey (XSECCryptoKey *k) |
Externally set the signing/verification key. | |
Signature Operations | |
bool | verify (void) |
Verify that a signature is valid. | |
bool | verifySignatureOnly (void) |
Verify a signature is valid (skip references). | |
void | sign (void) |
Sign a DSIGSignature DOM structure. | |
Functions to create and manipulate signature elements. | |
void | setDSIGNSPrefix (const XMLCh *prefix) |
Set the prefix be used for the DSIG namespace. | |
void | setECNSPrefix (const XMLCh *prefix) |
Set the prefix be used for the Exclusive Canonicalisation namespace. | |
void | setXPFNSPrefix (const XMLCh *prefix) |
Set the prefix be used for the XPath-Filter2 namespace. | |
void | setPrettyPrint (bool flag) |
Set Pretty Print. | |
bool | getPrettyPrint (void) |
Tell caller whether PrettyPrinting is active. | |
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * | createBlankSignature (XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, canonicalizationMethod cm=CANON_C14N_NOC, signatureMethod sm=SIGNATURE_DSA, hashMethod hm=HASH_SHA1) |
Create a <Signature> DOM structure. | |
DSIGReference * | createReference (const XMLCh *URI, hashMethod hm=HASH_SHA1, char *type=NULL) |
Add a new reference to the end of the list of <Reference> nodes. | |
General and Information functions. | |
unsigned int | calculateSignedInfoAndReferenceHash (unsigned char *hashBuf, unsigned int hashBufLen) |
Get the hash of the Signed Value. | |
unsigned int | calculateSignedInfoHash (unsigned char *hashBuf, unsigned int hashBufLen) |
Get the hash of the Signed Value. | |
DSIGReferenceList * | getReferenceList (void) |
Return the reference list for outside use. | |
XSECBinTXFMInputStream * | makeBinInputStream (void) const |
Create an input stream from SignedInfo. | |
const XMLCh * | getErrMsgs (void) |
Get the Error messages from the last verify. | |
const XMLCh * | getDSIGNSPrefix () |
Get the NS Prefix being used for DSIG elements. | |
const XMLCh * | getECNSPrefix () |
Get the NS being used for EC nodes. | |
const XMLCh * | getXPFNSPrefix () |
Get the NS being used for XPath Filter2 nodes. | |
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * | getParentDocument () |
canonicalizationMethod | getCanonicalizationMethod (void) |
Get canonicalisation algorithm. | |
hashMethod | getHashMethod (void) |
Get the hash method. | |
signatureMethod | getSignatureMethod (void) |
Get the signature method. | |
const XMLCh * | getSignatureValue (void) const |
Get the Signature Value. | |
XSECSafeBufferFormatter * | getSBFormatter (void) |
Helper function for sub Classes. | |
Resolver manipulation | |
void | setURIResolver (XSECURIResolver *resolver) |
Register a URIResolver. | |
XSECURIResolver * | getURIResolver (void) |
Return a pointer to the resolver being used. | |
void | setKeyInfoResolver (XSECKeyInfoResolver *resolver) |
Register a KeyInfoResolver. | |
XSECKeyInfoResolver * | getKeyInfoResolver (void) |
Return a pointer to the resolver being used. | |
KeyInfo Element Manipulation | |
DSIGKeyInfoList * | getKeyInfoList () |
Get the list of <KeyInfo> elements. | |
void | clearKeyInfo (void) |
Clear out all KeyInfo elements in the signature. | |
DSIGKeyInfoValue * | appendDSAKeyValue (const XMLCh *P, const XMLCh *Q, const XMLCh *G, const XMLCh *Y) |
Append a DSA KeyValue element. | |
DSIGKeyInfoValue * | appendRSAKeyValue (const XMLCh *modulus, const XMLCh *exponent) |
Append a RSA KeyValue element. | |
DSIGKeyInfoX509 * | appendX509Data (void) |
Append a X509Data element. | |
DSIGKeyInfoName * | appendKeyName (const XMLCh *name, bool isDName=false) |
Append a KeyName element. | |
DSIGKeyInfoPGPData * | appendPGPData (const XMLCh *id, const XMLCh *packet) |
Append a PGPData element. | |
DSIGKeyInfoSPKIData * | appendSPKIData (const XMLCh *sexp) |
Append a SPKIData element. | |
DSIGKeyInfoMgmtData * | appendMgmtData (const XMLCh *data) |
Append a MgmtData element. | |
Object handling | |
DSIGObject * | appendObject (void) |
Append an object container. | |
int | getObjectLength (void) |
Find the number of ds:Object nodes within the Signature. | |
DSIGObject * | getObjectItem (int i) |
Get a particular ds:Object from within the Signature. | |
ID handling | |
void | setIdByAttributeName (bool flag) |
Set Id finding behaviour. | |
bool | getIdByAttributeName (void) |
Determine Id finding behaviour. | |
void | registerIdAttributeName (const XMLCh *name) |
Add an attribute name to be searched for when looking for Id attributes. | |
bool | deregisterIdAttributeName (const XMLCh *name) |
Remove an attribute name to be searched for when looking for Id attributes. | |
void | registerIdAttributeNameNS (const XMLCh *ns, const XMLCh *name) |
Add an attribute name within a particular Namespace to be searched for when looking for Id attributes. | |
bool | deregisterIdAttributeNameNS (const XMLCh *ns, const XMLCh *name) |
Remove an attribute name and ns to be searched for when looking for Id attributes. | |
Protected Member Functions | |
Constructors and Destructors | |
DSIGSignature (XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *sigNode) | |
Contructor for use with existing XML signatures or templates. | |
~DSIGSignature () | |
Friends | |
class | XSECProvider |
|
Contructor for use with existing XML signatures or templates. Create a DSIGSignature object based on an already existing DSIG Signature XML node. It is assumed that the underlying DOM structure is in place and works correctly. It is required that the caller pass in the signature DOM Node as there may be more than one signature in a document. The caller needs to specify which signature tree is to be used.
|
|
|
|
Append a DSA KeyValue element. Add a new KeyInfo element for a DSA Value
|
|
Append a KeyName element. Add a new KeyInfo element for a key name.
|
|
Append a MgmtData element. Add a new KeyInfo element for Management Data
|
|
Append an object container. Create a new Object (i.e. a Signature <Object> which is a container element used to hold information that needs to be signed within the signature - i.e. in enveloping mode
|
|
Append a PGPData element. Add a new KeyInfo element for a PGP key.
|
|
Append a RSA KeyValue element. Add a new KeyInfo element for a RSA Value
|
|
Append a SPKIData element. Add a new KeyInfo element for a set of SPKI S-expressions
|
|
Append a X509Data element. Add a new KeyInfo element for X509 data.
|
|
Get the hash of the Signed Value. Function to calculate and return the hash of the <SignedInfo> structures (after the canonicalization defined by <CanonicalizationMethod> and the reference hashes have been performed).
|
|
Get the hash of the Signed Value. Function to calculate and return the hash of the <SignedInfo> structures (after the canonicalization defined by <CanonicalizationMethod> has been performed).
|
|
Clear out all KeyInfo elements in the signature. This function will delete all KeyInfo elements from both the DSIGSignature object and the associated DOM. |
|
Create a <Signature> DOM structure. The DOM structure created is still divorced from the document. The callee needs to take the returned <Signature> Element node and insert it at the appropriate place in their document. The signature is a skeleton only. There are no references or KeyInfo elements inserted. However the DSIGSignature structures are set up with the new information, so once an element has been created and a signing key has been set, a call to sign will sign appropriately.
|
|
Add a new reference to the end of the list of <Reference> nodes. Creates a new DSIGReference, adds it to the list of references handled by the owning DSIGSignature and also creates the skeleton DOM structure into the document.
|
|
Remove an attribute name to be searched for when looking for Id attributes. This allows a user to de-register a particular name to be used to identify Id attributes.
|
|
Remove an attribute name and ns to be searched for when looking for Id attributes. This allows a user to de-register a particular name to be used to identify Id attributes.
|
|
Get canonicalisation algorithm. Returns the canonicalisation algorithm that will be/is used to canonicalise the <SignedInfo> element prior to hash/sign
|
|
Get the NS Prefix being used for DSIG elements.
|
|
Get the NS being used for EC nodes.
|
|
Get the Error messages from the last verify. Returns a list of text error messages from the last Signature operation. Each error that occurred is in the buffer, separated by new-lines.
|
|
Get the hash method. Obtain the hash (digest) algorithm that is used to generate a hash of the canonicalised <SignedInfo> element.
|
|
Determine Id finding behaviour. Allows a caller to determine whether the library is currently searching for Id attributes by name
|
|
Get the list of <KeyInfo> elements. This function recovers list that contains the KeyInfo elements read in from the DOM document. This list should be used by calling applications to determine what key is appropriate for validating (or even signing) the Signature.
|
|
Return a pointer to the resolver being used.
|
|
Get a particular ds:Object from within the Signature.
|
|
Find the number of ds:Object nodes within the Signature.
|
|
Get the DOM_Document that this Signature is operating within. Mainly used by the library itself.
|
|
Tell caller whether PrettyPrinting is active.
|
|
Return the reference list for outside use. Returns a pointer to the list of references which can then be read by the caller.
|
|
Helper function for sub Classes. Returns the pointer to the formatter being used within the Signature |
|
Get the signature method. Obtain the algorithm that will be used to generate/check the signature of the canonicalised and hashed <SignedInfo> element.
|
|
Get the Signature Value. Returns the base64 string holding the signature value for this signature
|
|
Return a pointer to the resolver being used.
|
|
Get the NS being used for XPath Filter2 nodes.
|
|
Load the signature information from the DOM source. Used to tell the DSIGSignature object to read from the DOM tree into local structures. Will throw various exceptions if it finds that the DOM structure is not in line with the XML Signature standard. |
|
Create an input stream from SignedInfo. This method allows applications to read the fully canonicalised byte stream that is hashed and signed. All transforms are performed up to the point where they would normally be fed into the Digest function.
|
|
Add an attribute name to be searched for when looking for Id attributes. This allows a user to add an attribute name to be used to identify Id attributes when they are not set to be of Type=ID in the DOM
|
|
Add an attribute name within a particular Namespace to be searched for when looking for Id attributes. This allows a user to add an attribute name to be used to identify Id attributes when they are not set to be of Type=ID in the DOM
|
|
Set the prefix be used for the DSIG namespace. When the XSEC library creates XML Element nodes, it uses the prefix here for all nodes created. By default, the library assumes that the default namespace is used. The createBlankSignature function will use this prefix to setup the dsig namespace. E.g. (assuming a call has been made to set the prefix to "ds") the <Signature> element will have a namespace attribute added of xmlns:ds="http://www.w3.org/2000/09/xmldsig#" If no prefix has been set, this attribute will be set as the default namespace
|
|
Set the prefix be used for the Exclusive Canonicalisation namespace. The Exclusive Canonicalisation specification defines a new namespace for the InclusiveNamespaces node. This function can be used to set the prefix that the library will use when creating nodes within this namespace. xmlns:ds="http://www.w3.org/2001/10/xml-exc-c14n#" If no prefix is set, the default namespace will be used
|
|
Set Id finding behaviour. The library de-references "#obj" URI references to ID attributes within a DOM document. Currently, the library first uses DOM calls to find if the Id has been properly set within the document via the parser or one of the DOM Level 3 calls to set an Id. If no Id is found of the correct name, the library then starts searching for attributes of a given name with the required value. This list defaults to "id" and "Id", but can be modified via a call to addIdAttributeName() The setIdByAttributeName call enables or disables the second part of the Id search. I.e. when the Id doesn't exist as an attribute of Type=ID, whether or not to search for an attribute of a name in the list of names. By default this behaviour is enabled.
|
|
Register a KeyInfoResolver. Registers a KeyInfoResolver to be used by the Signature when it needs to find a key to be used to validate a signature |
|
Set Pretty Print. The pretty print functions controls whether the library will output CR/LF after the elements it adds to a document By default the library will do pretty printing (flag is true)
|
|
Externally set the signing/verification key. Used prior to a verify or sign operation to set the signature key (public or private respectively) to be used for the operation.
|
|
Register a URIResolver. Registers a URIResolver to be used by the Signature when dereferencing a URI in a Reference element |
|
Set the prefix be used for the XPath-Filter2 namespace. The XPathFilter definition uses its own namespace. This method can be used to set the prefix that the library will use when creating elements in this namespace xmlns:ds="http://www.w3.org/2002/06/xmldsig-filter2" If no prefix is set, the default namespace will be used
|
|
Sign a DSIGSignature DOM structure. The sign function will create the reference hash values and signature value in a DOM structure previously created via a load or createBlankSignature call It performs the following operations :
|
|
Verify that a signature is valid. The verify function will validate the signature of an XML document previously loaded into the DSIGSignature structure via a load. It performs the following operations :
|
|
Verify a signature is valid (skip references). This function is almost the same as verify except it will skip the reference checks.
|
|
|