xmltooling
1.6.4
|
Wrapper API for XML Encryption functionality. More...
#include <xmltooling/encryption/Encrypter.h>
Classes | |
struct | EncryptionParams |
Structure to collect encryption requirements. More... | |
struct | KeyEncryptionParams |
Structure to collect key wrapping/transport requirements. More... | |
Public Member Functions | |
EncryptedData * | encryptElement (xercesc::DOMElement *element, EncryptionParams &encParams, KeyEncryptionParams *kencParams=0) |
Encrypts the supplied element and returns the resulting object. More... | |
EncryptedData * | encryptElementContent (xercesc::DOMElement *element, EncryptionParams &encParams, KeyEncryptionParams *kencParams=0) |
Encrypts the supplied element's children and returns the resulting object. More... | |
EncryptedData * | encryptStream (std::istream &input, EncryptionParams &encParams, KeyEncryptionParams *kencParams=0) |
Encrypts the supplied input stream and returns the resulting object. More... | |
EncryptedKey * | encryptKey (const unsigned char *keyBuffer, unsigned int keyBufferSize, KeyEncryptionParams &kencParams, bool compact=false) |
Encrypts the supplied key and returns the resulting object. More... | |
Static Public Member Functions | |
static const XMLCh * | getKeyTransportAlgorithm (const xmltooling::Credential &credential, const XMLCh *encryptionAlg) |
Maps a data encryption algorithm to an appropriate key transport algorithm to use. More... | |
Wrapper API for XML Encryption functionality.
Designed to allow both external and internal key generation as follows:
If no keying material is supplied, then the algorithm MAY be recognized and a key can be generated internally. This is only done if a KeyEncryptionParams structure is also supplied to the operation (otherwise the key would be lost).
If an XSECCryptoKey is supplied, then it is used directly, but if KeyEncryptionParams are supplied, an exception will result unless the raw key buffer is also supplied.
If a raw key is provided, then a key object can also be created internally if the algorithm is recognized.
Summing up, if KeyEncryptionParams are used, a raw key must be available or the key can be generated when the encryption algorithm itself is a standard one. If no KeyEncryptionParams are supplied, then the key must be supplied either in raw or object form.
Finally, when encrypting data, the key transport algorithm can be left blank to derive it from the data encryption algorithm.
EncryptedData* xmlencryption::Encrypter::encryptElement | ( | xercesc::DOMElement * | element, |
EncryptionParams & | encParams, | ||
KeyEncryptionParams * | kencParams = 0 |
||
) |
Encrypts the supplied element and returns the resulting object.
If an encryption algorithm is set, but no key, a random key will be generated iff kencParams is non-NULL and the algorithm is known.
If key encryption parameters are supplied, then the encryption key is wrapped and the result placed into an EncryptedKey object in the KeyInfo of the returned EncryptedData.
element | the DOM element to encrypt |
encParams | primary encryption settings |
kencParams | key encryption settings, or nullptr |
EncryptedData* xmlencryption::Encrypter::encryptElementContent | ( | xercesc::DOMElement * | element, |
EncryptionParams & | encParams, | ||
KeyEncryptionParams * | kencParams = 0 |
||
) |
Encrypts the supplied element's children and returns the resulting object.
If an encryption algorithm is set, but no key, a random key will be generated iff kencParams is non-NULL and the algorithm is known.
If key encryption parameters are supplied, then the encryption key is wrapped and the result placed into an EncryptedKey object in the KeyInfo of the returned EncryptedData.
element | parent element of children to encrypt |
encParams | primary encryption settings |
kencParams | key encryption settings, or nullptr |
EncryptedKey* xmlencryption::Encrypter::encryptKey | ( | const unsigned char * | keyBuffer, |
unsigned int | keyBufferSize, | ||
KeyEncryptionParams & | kencParams, | ||
bool | compact = false |
||
) |
Encrypts the supplied key and returns the resulting object.
keyBuffer | raw key material to encrypt |
keyBufferSize | size in bytes of raw key material |
kencParams | key encryption settings |
compact | true iff the encrypted representation should be made as small as possible |
EncryptedData* xmlencryption::Encrypter::encryptStream | ( | std::istream & | input, |
EncryptionParams & | encParams, | ||
KeyEncryptionParams * | kencParams = 0 |
||
) |
Encrypts the supplied input stream and returns the resulting object.
If an encryption algorithm is set, but no key, a random key will be generated iff kencParams is non-NULL and the algorithm is known.
If key encryption parameters are supplied, then the encryption key is wrapped and the result placed into an EncryptedKey object in the KeyInfo of the returned EncryptedData.
input | the stream to encrypt |
encParams | primary encryption settings |
kencParams | key encryption settings, or nullptr |
|
static |
Maps a data encryption algorithm to an appropriate key transport algorithm to use.
credential | the key encryption key |
encryptionAlg | data encryption algorithm |