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 voidDestroyCurrentTemplate()
IMPORT_C RXmlEngDocumentEncryptDataL(const TDesC8 &)
IMPORT_C voidEncryptXmlDocumentKeyFromBufferL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
IMPORT_C voidEncryptXmlDocumentKeyFromFileL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
IMPORT_C voidEncryptXmlDocumentL(RXmlEngDocument &)
IMPORT_C voidEncryptXmlNodeKeyFromBufferL(TXmlEngElement, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
IMPORT_C voidEncryptXmlNodeKeyFromFileL(TXmlEngElement, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
IMPORT_C voidEncryptXmlNodeL(TXmlEngElement)
IMPORT_C CXmlSecEncrypt *NewL()
IMPORT_C CXmlSecEncrypt *NewLC()
IMPORT_C voidSetKeyFromBufferL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
IMPORT_C voidSetKeyFromFileL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
IMPORT_C voidSetKeyInfoL(const TDesC8 &)
IMPORT_C voidSetKeyInfoL(TXmlEngElement)
IMPORT_C voidSetTemplateFromBufferL(const TDesC8 &)
IMPORT_C voidSetTemplateFromFileL(const TDesC8 &)
IMPORT_C voidSetTemplateFromFileL(RFs &, const TDesC8 &)
IMPORT_C voidSetTemplateL(const RXmlEngDocument &)
Private Member Functions
CXmlSecEncrypt()
voidConstructL()
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
enumTXmlSecDataType { ENode = 0, ENodeContent, EData }
enumTXmlSecKeyType { 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()

voidConstructL()[private]

Second phase constructor.

Since
S60 v3.2

CreateTemplateL(TXmlSecKeyType, TXmlSecDataType)

IMPORT_C const RXmlEngDocument &CreateTemplateL(TXmlSecKeyTypeaKeyType,
TXmlSecDataTypeaDataType = 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 aKeyTypeKey algorithm
TXmlSecDataType aDataType = CXmlSecEncrypt::ENodeType 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,
TXmlSecKeyTypeaKeyType
)

Decrypts xml document.

Since
S60 v3.2

Parameters

RXmlEngDocument & aDocumentxml document that should be decrypted.
const TDesC8 & aKeybuffer with key inside
const TDesC8 & aKeyNamename 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,
TXmlSecKeyTypeaKeyType
)

Decrypts xml document.

Since
S60 v3.2

Parameters

RXmlEngDocument & aDocumentxml document that should be decrypted.
const TDesC8 & aKeyFilename of the file with key inside
const TDesC8 & aKeyNamename 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 & aDocumentDOM tree with encrypted data

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

IMPORT_C HBufC8 *DecryptXmlNodeKeyFromBufferL(TXmlEngElementaNode,
const TDesC8 &aKey,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

Decrypts xml node.

Since
S60 v3.2

Parameters

TXmlEngElement aNodexml node that should be decrypted.
const TDesC8 & aKeybuffer with key inside
const TDesC8 & aKeyNamename 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(TXmlEngElementaNode,
const TDesC8 &aKeyFile,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

Decrypts xml node.

Since
S60 v3.2

Parameters

TXmlEngElement aNodexml node that should be decrypted.
const TDesC8 & aKeyFilename of the file with key inside
const TDesC8 & aKeyNamename of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

DecryptXmlNodeL(TXmlEngElement)

IMPORT_C HBufC8 *DecryptXmlNodeL(TXmlEngElementaNode)

Decrypts data contained in a node.

Since
S60 v3.2

Parameters

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

DestroyCurrentTemplate()

IMPORT_C voidDestroyCurrentTemplate()

Destroys current template.

Since
S60 v3.2

EncryptDataL(const TDesC8 &)

IMPORT_C RXmlEngDocumentEncryptDataL(const TDesC8 &aData)

Encrypts data from buffer.

Since
S60 v3.2

Parameters

const TDesC8 & aDatadata that should be encrypted

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

IMPORT_C voidEncryptXmlDocumentKeyFromBufferL(RXmlEngDocument &aDoc,
RXmlEngDocument &aTemplate,
const TDesC8 &aKey,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

Encrypts xml document.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

RXmlEngDocument & aDoc
RXmlEngDocument & aTemplateDOM tree with template document
const TDesC8 & aKeybuffer with key inside
const TDesC8 & aKeyNamename 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 voidEncryptXmlDocumentKeyFromFileL(RXmlEngDocument &aDoc,
RXmlEngDocument &aTemplate,
const TDesC8 &aKeyFile,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

Encrypts xml document.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

RXmlEngDocument & aDoc
RXmlEngDocument & aTemplateDOM tree with template document
const TDesC8 & aKeyFilename of the file with key inside
const TDesC8 & aKeyNamename of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

EncryptXmlDocumentL(RXmlEngDocument &)

IMPORT_C voidEncryptXmlDocumentL(RXmlEngDocument &aDocument)

Encrypts xml document.

Since
S60 v3.2
Note:

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

Parameters

RXmlEngDocument & aDocumentxml document that should be encrypted.

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

IMPORT_C voidEncryptXmlNodeKeyFromBufferL(TXmlEngElementaNode,
RXmlEngDocument &aTemplate,
const TDesC8 &aKeyFile,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

Encrypts xml node.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

TXmlEngElement aNodexml node that should be encrypted.
RXmlEngDocument & aTemplateDOM tree with template document
const TDesC8 & aKeyFile
const TDesC8 & aKeyNamename 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 voidEncryptXmlNodeKeyFromFileL(TXmlEngElementaNode,
RXmlEngDocument &aTemplate,
const TDesC8 &aKeyFile,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

Encrypts xml node.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

TXmlEngElement aNodexml node that should be encrypted.
RXmlEngDocument & aTemplateDOM tree with template document
const TDesC8 & aKeyFilename of the file with key inside
const TDesC8 & aKeyNamename of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

EncryptXmlNodeL(TXmlEngElement)

IMPORT_C voidEncryptXmlNodeL(TXmlEngElementaNode)

Encrypts xml node.

Since
S60 v3.2
Note:

Encrypted content will replace aNode. aNode contains the result.

Parameters

TXmlEngElement aNodexml 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 voidSetKeyFromBufferL(const TDesC8 &aKey,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

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 & aKeybuffer with key inside
const TDesC8 & aKeyNamename of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyTypekey algorithm (i.e. AES)

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

IMPORT_C voidSetKeyFromFileL(const TDesC8 &aKeyFile,
const TDesC8 &aKeyName,
TXmlSecKeyTypeaKeyType
)

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 & aKeyFilename of the file with key inside
const TDesC8 & aKeyNamename of the key. In case of AES and 3DES it can be null.
TXmlSecKeyType aKeyType

SetKeyInfoL(const TDesC8 &)

IMPORT_C voidSetKeyInfoL(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 & aKeyNameKey name that should be set.

SetKeyInfoL(TXmlEngElement)

IMPORT_C voidSetKeyInfoL(TXmlEngElementaKeyProp)

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 aKeyPropElement that should be set.

SetTemplateFromBufferL(const TDesC8 &)

IMPORT_C voidSetTemplateFromBufferL(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 & aTemplatetemplate xml in buffer

SetTemplateFromFileL(const TDesC8 &)

IMPORT_C voidSetTemplateFromFileL(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 & aTemplatetemplate file

SetTemplateFromFileL(RFs &, const TDesC8 &)

IMPORT_C voidSetTemplateFromFileL(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 & aRFshandle to a file server session.
const TDesC8 & aTemplatetemplate file

SetTemplateL(const RXmlEngDocument &)

IMPORT_C voidSetTemplateL(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 & aTemplateDOM 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