xmltooling 3.2.4

Classes | Public Member Functions | Static Public Member Functions | List of all members
xmlencryption::Encrypter Class Reference

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.
EncryptedData * | encryptElementContent (xercesc::DOMElement *element, EncryptionParams &encParams, KeyEncryptionParams *kencParams=0)
| Encrypts the supplied element's children and returns the resulting object.
EncryptedData * | encryptStream (std::istream &input, EncryptionParams &encParams, KeyEncryptionParams *kencParams=0)
| Encrypts the supplied input stream and returns the resulting object.
EncryptedKey * | encryptKey (const unsigned char *keyBuffer, unsigned int keyBufferSize, KeyEncryptionParams &kencParams, bool compact=false)
| Encrypts the supplied key and returns the resulting object.

## 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.

## Detailed Description

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.

## Member Function Documentation

## ◆ encryptElement()

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.

Parameters

  element | the DOM element to encrypt
  encParams | primary encryption settings
  kencParams | key encryption settings, or nullptr

Returns
  a stand-alone EncryptedData object, unconnected to the source DOM

## ◆ encryptElementContent()

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.

Parameters

  element | parent element of children to encrypt
  encParams | primary encryption settings
  kencParams | key encryption settings, or nullptr

Returns
  a stand-alone EncryptedData object, unconnected to the source DOM

## ◆ encryptKey()

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.

Parameters

  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

Returns
  a stand-alone EncryptedKey object, unconnected to any DOM

## ◆ encryptStream()

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.

Parameters

  input | the stream to encrypt
  encParams | primary encryption settings
  kencParams | key encryption settings, or nullptr

Returns
  a stand-alone EncryptedData object, unconnected to any DOM

## ◆ getKeyTransportAlgorithm()

static const XMLCh * xmlencryption::Encrypter::getKeyTransportAlgorithm | ( | const xmltooling::Credential & | credential,
|  | const XMLCh * | encryptionAlg )
| static

Maps a data encryption algorithm to an appropriate key transport algorithm to use.

Parameters

  credential | the key encryption key
  encryptionAlg | data encryption algorithm

Returns
  a key transport algorithm

The documentation for this class was generated from the following file:

- xmltooling/encryption/Encrypter.h