Я нашел решение очень простым.
После того, как документ был проанализирован, ниже будет генерировать оболочечную Подпись (как указано here):
// rootelem contains the root element of the parsed document
XSECProvider prov;
DSIGSignature * sig;
DOMElement * sigNode;
sig = prov.newSignature();
sigNode = sig->createBlankSignature(xercescdom, CANON_C14N_COM, SIGNATURE_HMAC, HASH_SHA1);
// append the signature node to the document's element which is being signed, here
// it is the root element
rootelem->appendChild(xercescdom->createTextNode(MAKE_UNICODE_STRING("\n")));
rootelem->appendChild(sigNode);
rootelem->appendChild(xercescdom->createTextNode(MAKE_UNICODE_STRING("\n")));
// create the envelope reference and the signing key (e.g. HMAC Key)
// set the signing key
sig->setSigningKey(hmackey);
// other steps... Serializing the rootelem will generate an XML document with Enveloped Signature
Ниже будет генерировать обертывающую Подпись:
XSECProvider prov;
DSIGSignature * sig;
DOMElement * sigNode;
sig = prov.newSignature();
sigNode = sig->createBlankSignature(xercescdom, CANON_C14N_COM, SIGNATURE_HMAC, HASH_SHA1);
// append an "Object" element to the signature object
DSIGObject * object = sig->appendObject();
// in an enveloping signature, the "Object" element contains the data being signed
// so the rootelem can be appended as a child to this object element
object->appendChild(rootelem);
// AND you are done!
// now create the envelope reference and the signing key (e.g. HMAC Key)
// set the signing key
sig->setSigningKey(hmackey);
// Serializing the signature node (sigNode) will give you the required XML with Enveloping Signature.
Аналогично Отдельной Подпись может быть сгенерирован с некоторым усилием.
Приведенные выше примеры охватывают очень простые случаи. Для подписи нескольких элементов данных и подмножеств документа потребуется немного усилий.