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
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
&)
|
Constructor & Destructor Documentation
CXmlSecEncrypt()
CXmlSecEncrypt
|
(
|
)
|
[private]
|
~CXmlSecEncrypt()
~CXmlSecEncrypt
|
(
|
)
|
[virtual]
|
Member Functions Documentation
ConstructL()
void
|
ConstructL
|
(
|
)
|
[private]
|
Second phase constructor.
CreateTemplateL(TXmlSecKeyType, TXmlSecDataType)
Creates encryption template. Template will be created for specific key algorithm. This template will be used until new template will be set.
CurrentTemplate()
IMPORT_C const
RXmlEngDocument
&
|
CurrentTemplate
|
(
|
)
|
const
|
Return current encryption template.
DecryptXmlDocumentKeyFromBufferL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
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)
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.
Parameters
RXmlEngDocument
& aDocument
|
DOM tree with encrypted data
|
DecryptXmlNodeKeyFromBufferL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
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)
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.
Parameters
TXmlEngElement
aNode
|
<EncryptedData> element (see XML Encryption recommendation)
|
DestroyCurrentTemplate()
IMPORT_C void
|
DestroyCurrentTemplate
|
(
|
)
|
|
Destroys current template.
EncryptDataL(const TDesC8 &)
IMPORT_C
RXmlEngDocument
|
EncryptDataL
|
(
|
const
TDesC8
&
|
aData
|
)
|
|
Encrypts data from buffer.
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.
|
NewLC()
Creates new object and puts it on cleanup stack.
SetKeyFromBufferL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Reads key from buffer. Key will be used during encrypt/decrypt action until new key will be set.
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)
Reads key from file. Key will be used during encrypt/decrypt action until new key will be set.
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.
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.
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.
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.
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.
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.
Parameters
const
RXmlEngDocument
& aTemplate
|
DOM tree with template document
|
Member Enumerations Documentation
Enum TXmlSecDataType
Enumerators
ENode = 0
|
|
ENodeContent
|
|
EData
|
|
Enum TXmlSecKeyType
Key types. Currently symmetric key (AES (256 bit) or 3DES)
Member Data Documentation
CXmlSecKeyManager * iMngr
RXmlEngDocument
iTemplate
RXmlEngDocument
|
iTemplate
|
[private]
|
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.