CXmlSecEncrypt Class Reference

class CXmlSecEncrypt : public CBase

Class used to encrypt/decrypt data.

How to use:

Encryption:
        1. Create new object:
          CXmlSecEncrypt* enc =
        
         CXmlSecEncrypt::NewLC()
        
        ;      
  2. Set the key that should be used during encryption: 
          enc->SetKeyFromFileL(filename, keyname, CXmlSecEncrypt::E3DES);
  3. Set template for encryption: 
          enc->SetTemplateFromFileL(templatefile);
  4. Encrypt data from buffer:
          doc = enc->EncryptDataL(data);
     data will be added to template or encrypt xml node: 
	        enc->EncryptXmlNodeL(doc.DocumentElement()); 
     node will be replaced by template with encrypted data
       
Decryption:
        1. Create new object:
          CXmlSecEncrypt* enc =
        
         CXmlSecEncrypt::NewLC()
        
        ;
  2. Set the key that should be used during decryption:  
          enc->SetKeyFromFileL(keyfile,keyname,CXmlSecEncrypt::EAES256);
  3. Decrypt xml node:
          enc->DecryptXmlNodeL(doc.DocumentElement()); 
   Function will replace encryption template with encrypted data. If result of encryption will
   not be a document then result will be returned as HBufC8*.
       
Note:

Key should be set before encryption

XmlSecWrapper.dll
Since
S60 v3.2

Inherits from

Public Member Functions
~CXmlSecEncrypt ()
IMPORT_C const RXmlEngDocument & CreateTemplateL ( TXmlSecKeyType , TXmlSecDataType )
IMPORT_C const RXmlEngDocument & CurrentTemplate ()
IMPORT_C HBufC8 * DecryptXmlDocumentKeyFromBufferL ( RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C HBufC8 * DecryptXmlDocumentKeyFromFileL ( RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C HBufC8 * DecryptXmlDocumentL ( RXmlEngDocument &)
IMPORT_C HBufC8 * DecryptXmlNodeKeyFromBufferL ( TXmlEngElement , const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C HBufC8 * DecryptXmlNodeKeyFromFileL ( TXmlEngElement , const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C HBufC8 * DecryptXmlNodeL ( TXmlEngElement )
IMPORT_C void DestroyCurrentTemplate ()
IMPORT_C RXmlEngDocument EncryptDataL (const TDesC8 &)
IMPORT_C void EncryptXmlDocumentKeyFromBufferL ( RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C void EncryptXmlDocumentKeyFromFileL ( RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C void EncryptXmlDocumentL ( RXmlEngDocument &)
IMPORT_C void EncryptXmlNodeKeyFromBufferL ( TXmlEngElement , RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C void EncryptXmlNodeKeyFromFileL ( TXmlEngElement , RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C void EncryptXmlNodeL ( TXmlEngElement )
IMPORT_C CXmlSecEncrypt * NewL ()
IMPORT_C CXmlSecEncrypt * NewLC ()
IMPORT_C void SetKeyFromBufferL (const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C void SetKeyFromFileL (const TDesC8 &, const TDesC8 &, TXmlSecKeyType )
IMPORT_C void SetKeyInfoL (const TDesC8 &)
IMPORT_C void SetKeyInfoL ( TXmlEngElement )
IMPORT_C void SetTemplateFromBufferL (const TDesC8 &)
IMPORT_C void SetTemplateFromFileL (const TDesC8 &)
IMPORT_C void SetTemplateFromFileL ( RFs &, const TDesC8 &)
IMPORT_C void SetTemplateL (const RXmlEngDocument &)
Private Member Functions
CXmlSecEncrypt ()
void ConstructL ()
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enum TXmlSecDataType { ENode  = 0, ENodeContent , EData }
enum TXmlSecKeyType { EAES256  = 0, E3DES }
Private Attributes
void * iEncCtx
CXmlSecKeyManager * iMngr
RXmlEngDocument iTemplate

Constructor & Destructor Documentation

CXmlSecEncrypt()

CXmlSecEncrypt ( ) [private]

Default constructor.

Since
S60 v3.2

~CXmlSecEncrypt()

~CXmlSecEncrypt ( ) [virtual]

Destructor.

Since
S60 v3.2

Member Functions Documentation

ConstructL()

void ConstructL ( ) [private]

Second phase constructor.

Since
S60 v3.2

CreateTemplateL(TXmlSecKeyType, TXmlSecDataType)

IMPORT_C const RXmlEngDocument & CreateTemplateL ( TXmlSecKeyType aKeyType,
TXmlSecDataType aDataType = CXmlSecEncrypt::ENode
)

Creates encryption template. Template will be created for specific key algorithm. This template will be used until new template will be set.

Since
S60 v3.2

Parameters

TXmlSecKeyType aKeyType Key algorithm
TXmlSecDataType aDataType = CXmlSecEncrypt::ENode Type of encrypted data. It can be xml node or data.

CurrentTemplate()

IMPORT_C const RXmlEngDocument & CurrentTemplate ( ) const

Return current encryption template.

Since
S60 v3.2

DecryptXmlDocumentKeyFromBufferL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C HBufC8 * DecryptXmlDocumentKeyFromBufferL ( RXmlEngDocument & aDocument,
const TDesC8 & aKey,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Decrypts xml document.

Since
S60 v3.2

Parameters

RXmlEngDocument & aDocument xml document that should be decrypted.
const TDesC8 & aKey buffer with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

DecryptXmlDocumentKeyFromFileL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C HBufC8 * DecryptXmlDocumentKeyFromFileL ( RXmlEngDocument & aDocument,
const TDesC8 & aKeyFile,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Decrypts xml document.

Since
S60 v3.2

Parameters

RXmlEngDocument & aDocument xml document that should be decrypted.
const TDesC8 & aKeyFile name of the file with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

DecryptXmlDocumentL(RXmlEngDocument &)

IMPORT_C HBufC8 * DecryptXmlDocumentL ( RXmlEngDocument & aDocument )

Decrypts data contained in xml DOM tree.

Since
S60 v3.2

Parameters

RXmlEngDocument & aDocument DOM tree with encrypted data

DecryptXmlNodeKeyFromBufferL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C HBufC8 * DecryptXmlNodeKeyFromBufferL ( TXmlEngElement aNode,
const TDesC8 & aKey,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Decrypts xml node.

Since
S60 v3.2

Parameters

TXmlEngElement aNode xml node that should be decrypted.
const TDesC8 & aKey buffer with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

DecryptXmlNodeKeyFromFileL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C HBufC8 * DecryptXmlNodeKeyFromFileL ( TXmlEngElement aNode,
const TDesC8 & aKeyFile,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Decrypts xml node.

Since
S60 v3.2

Parameters

TXmlEngElement aNode xml node that should be decrypted.
const TDesC8 & aKeyFile name of the file with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

DecryptXmlNodeL(TXmlEngElement)

IMPORT_C HBufC8 * DecryptXmlNodeL ( TXmlEngElement aNode )

Decrypts data contained in a node.

Since
S60 v3.2

Parameters

TXmlEngElement aNode <EncryptedData> element (see XML Encryption recommendation)

DestroyCurrentTemplate()

IMPORT_C void DestroyCurrentTemplate ( )

Destroys current template.

Since
S60 v3.2

EncryptDataL(const TDesC8 &)

IMPORT_C RXmlEngDocument EncryptDataL ( const TDesC8 & aData )

Encrypts data from buffer.

Since
S60 v3.2

Parameters

const TDesC8 & aData data that should be encrypted

EncryptXmlDocumentKeyFromBufferL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C void EncryptXmlDocumentKeyFromBufferL ( RXmlEngDocument & aDoc,
RXmlEngDocument & aTemplate,
const TDesC8 & aKey,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Encrypts xml document.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

RXmlEngDocument & aDoc
RXmlEngDocument & aTemplate DOM tree with template document
const TDesC8 & aKey buffer with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

EncryptXmlDocumentKeyFromFileL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C void EncryptXmlDocumentKeyFromFileL ( RXmlEngDocument & aDoc,
RXmlEngDocument & aTemplate,
const TDesC8 & aKeyFile,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Encrypts xml document.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

RXmlEngDocument & aDoc
RXmlEngDocument & aTemplate DOM tree with template document
const TDesC8 & aKeyFile name of the file with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

EncryptXmlDocumentL(RXmlEngDocument &)

IMPORT_C void EncryptXmlDocumentL ( RXmlEngDocument & aDocument )

Encrypts xml document.

Since
S60 v3.2
Note:

Encrypted content will replace aDocument content. aDocument contains the result.

Parameters

RXmlEngDocument & aDocument xml document that should be encrypted.

EncryptXmlNodeKeyFromBufferL(TXmlEngElement, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C void EncryptXmlNodeKeyFromBufferL ( TXmlEngElement aNode,
RXmlEngDocument & aTemplate,
const TDesC8 & aKeyFile,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Encrypts xml node.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

TXmlEngElement aNode xml node that should be encrypted.
RXmlEngDocument & aTemplate DOM tree with template document
const TDesC8 & aKeyFile
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

EncryptXmlNodeKeyFromFileL(TXmlEngElement, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C void EncryptXmlNodeKeyFromFileL ( TXmlEngElement aNode,
RXmlEngDocument & aTemplate,
const TDesC8 & aKeyFile,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Encrypts xml node.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

TXmlEngElement aNode xml node that should be encrypted.
RXmlEngDocument & aTemplate DOM tree with template document
const TDesC8 & aKeyFile name of the file with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

EncryptXmlNodeL(TXmlEngElement)

IMPORT_C void EncryptXmlNodeL ( TXmlEngElement aNode )

Encrypts xml node.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

TXmlEngElement aNode xml node that should be encrypted.

NewL()

IMPORT_C CXmlSecEncrypt * NewL ( ) [static]

Creates new object.

Since
S60 v3.2

NewLC()

IMPORT_C CXmlSecEncrypt * NewLC ( ) [static]

Creates new object and puts it on cleanup stack.

Since
S60 v3.2

SetKeyFromBufferL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C void SetKeyFromBufferL ( const TDesC8 & aKey,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Reads key from buffer. Key will be used during encrypt/decrypt action until new key will be set.

Since
S60 v3.2

Parameters

const TDesC8 & aKey buffer with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType key algorithm (i.e. AES)

SetKeyFromFileL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)

IMPORT_C void SetKeyFromFileL ( const TDesC8 & aKeyFile,
const TDesC8 & aKeyName,
TXmlSecKeyType aKeyType
)

Reads key from file. Key will be used during encrypt/decrypt action until new key will be set.

Since
S60 v3.2

Parameters

const TDesC8 & aKeyFile name of the file with key inside
const TDesC8 & aKeyName name of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

SetKeyInfoL(const TDesC8 &)

IMPORT_C void SetKeyInfoL ( const TDesC8 & aKeyName )

Adds <KeyName> element to <KeyInfo> node and sets the value of it. The element will be added to current template.

Since
S60 v3.2

Parameters

const TDesC8 & aKeyName Key name that should be set.

SetKeyInfoL(TXmlEngElement)

IMPORT_C void SetKeyInfoL ( TXmlEngElement aKeyProp )

Adds element to <KeyInfo> node. This method allows to add specific data to <KeyInfo> element. The element will be added to current template.

Since
S60 v3.2

Parameters

TXmlEngElement aKeyProp Element that should be set.

SetTemplateFromBufferL(const TDesC8 &)

IMPORT_C void SetTemplateFromBufferL ( const TDesC8 & aTemplate )

Sets encryption template (parses buffer that contains template xml). This template will be used until new template will be set.

Since
S60 v3.2

Parameters

const TDesC8 & aTemplate template xml in buffer

SetTemplateFromFileL(const TDesC8 &)

IMPORT_C void SetTemplateFromFileL ( const TDesC8 & aTemplate )

Sets encryption template (parses template file). This template will be used until new template will be set.

Since
S60 v3.2

Parameters

const TDesC8 & aTemplate template file

SetTemplateFromFileL(RFs &, const TDesC8 &)

IMPORT_C void SetTemplateFromFileL ( RFs & aRFs,
const TDesC8 & aTemplate
)

Sets encryption template (parses template file). This template will be used until new template will be set.

Since
S60 v3.2

Parameters

RFs & aRFs handle to a file server session.
const TDesC8 & aTemplate template file

SetTemplateL(const RXmlEngDocument &)

IMPORT_C void SetTemplateL ( const RXmlEngDocument & aTemplate )

Set copy of the argument as a encryption template. This template will be used until new template will be set.

Since
S60 v3.2

Parameters

const RXmlEngDocument & aTemplate DOM tree with template document

Member Enumerations Documentation

Enum TXmlSecDataType

Encryption data types

Enumerators

ENode = 0
ENodeContent
EData

Enum TXmlSecKeyType

Key types. Currently symmetric key (AES (256 bit) or 3DES)

Enumerators

EAES256 = 0
E3DES

Member Data Documentation

void * iEncCtx

void * iEncCtx [private]

Encryption context

CXmlSecKeyManager * iMngr

CXmlSecKeyManager * iMngr [private]

Key manager

RXmlEngDocument iTemplate

RXmlEngDocument iTemplate [private]

DOM tree with template