| class CXmlSecEncrypt : public CBase |
Class used to encrypt/decrypt data.
How to use:
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
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*.
Key should be set before encryption
| Private Member Functions | |
|---|---|
| CXmlSecEncrypt() | |
| void | ConstructL() |
| Public Member Enumerations | |
|---|---|
| enum | TXmlSecDataType { ENode = 0, ENodeContent, EData } |
| enum | TXmlSecKeyType { EAES256 = 0, E3DES } |
| Private Attributes | |
|---|---|
| void * | iEncCtx |
| CXmlSecKeyManager * | iMngr |
| RXmlEngDocument | iTemplate |
| 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.
S60 v3.2
template document
| TXmlSecKeyType aKeyType | Key algorithm |
| TXmlSecDataType aDataType = CXmlSecEncrypt::ENode | Type of encrypted data. It can be xml node or data. |
| IMPORT_C const RXmlEngDocument & | CurrentTemplate | ( | ) | const |
Return current encryption template.
S60 v3.2
template document
| IMPORT_C HBufC8 * | DecryptXmlDocumentKeyFromBufferL | ( | RXmlEngDocument & | aDocument, |
| const TDesC8 & | aKey, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Decrypts xml document.
S60 v3.2
Decryption result. If xml data will be a result then it will repleace aDocument content and null will be returned. If result type will be different then result will be returned in HBufC8 pointer.
| 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 |
| IMPORT_C HBufC8 * | DecryptXmlDocumentKeyFromFileL | ( | RXmlEngDocument & | aDocument, |
| const TDesC8 & | aKeyFile, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Decrypts xml document.
S60 v3.2
Decryption result. If xml data will be a result then it will replace aDocument content and null will be returned. If result type will be different then result will be returned in HBufC8 pointer.
| 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 |
| IMPORT_C HBufC8 * | DecryptXmlDocumentL | ( | RXmlEngDocument & | aDocument | ) |
Decrypts data contained in xml DOM tree.
S60 v3.2
Decryption result. If xml data will be a result then it will replace aDocument content and null will be returned. If result type will be different then result will be returned in HBufC8 pointer.
| RXmlEngDocument & aDocument | DOM tree with encrypted data |
| IMPORT_C HBufC8 * | DecryptXmlNodeKeyFromBufferL | ( | TXmlEngElement | aNode, |
| const TDesC8 & | aKey, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Decrypts xml node.
S60 v3.2
Decryption result. If xml data will be a result then it will replace aDocument content and null will be returned. If result type will be different then result will be returned in HBufC8 pointer.
| 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 |
| IMPORT_C HBufC8 * | DecryptXmlNodeKeyFromFileL | ( | TXmlEngElement | aNode, |
| const TDesC8 & | aKeyFile, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Decrypts xml node.
S60 v3.2
Decryption result. If xml data will be a result then it will replace aDocument content and null will be returned. If result type will be different then result will be returned in HBufC8 pointer.
| 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 |
| IMPORT_C HBufC8 * | DecryptXmlNodeL | ( | TXmlEngElement | aNode | ) |
Decrypts data contained in a node.
S60 v3.2
Decryption result. If xml data will be a result then it will replace aNode content and null will be returned. If result type will be different then result will be returned in HBufC8 pointer.
| TXmlEngElement aNode | <EncryptedData> element (see XML Encryption recommendation) |
| IMPORT_C RXmlEngDocument | EncryptDataL | ( | const TDesC8 & | aData | ) |
Encrypts data from buffer.
S60 v3.2
xml document with encrypted data
| const TDesC8 & aData | data that should be encrypted |
| IMPORT_C void | EncryptXmlDocumentKeyFromBufferL | ( | RXmlEngDocument & | aDoc, |
| RXmlEngDocument & | aTemplate, | |||
| const TDesC8 & | aKey, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Encrypts xml document.
S60 v3.2
Encrypted content will replace aNode. aNode contains the result.
| 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 |
| IMPORT_C void | EncryptXmlDocumentKeyFromFileL | ( | RXmlEngDocument & | aDoc, |
| RXmlEngDocument & | aTemplate, | |||
| const TDesC8 & | aKeyFile, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Encrypts xml document.
S60 v3.2
Encrypted content will replace aNode. aNode contains the result.
| 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 |
| IMPORT_C void | EncryptXmlDocumentL | ( | RXmlEngDocument & | aDocument | ) |
Encrypts xml document.
S60 v3.2
Encrypted content will replace aDocument content. aDocument contains the result.
| RXmlEngDocument & aDocument | xml document that should be encrypted. |
| IMPORT_C void | EncryptXmlNodeKeyFromBufferL | ( | TXmlEngElement | aNode, |
| RXmlEngDocument & | aTemplate, | |||
| const TDesC8 & | aKeyFile, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Encrypts xml node.
S60 v3.2
Encrypted content will replace aNode. aNode contains the result.
| 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 |
| IMPORT_C void | EncryptXmlNodeKeyFromFileL | ( | TXmlEngElement | aNode, |
| RXmlEngDocument & | aTemplate, | |||
| const TDesC8 & | aKeyFile, | |||
| const TDesC8 & | aKeyName, | |||
| TXmlSecKeyType | aKeyType | |||
| ) | ||||
Encrypts xml node.
S60 v3.2
Encrypted content will replace aNode. aNode contains the result.
| 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 |
| IMPORT_C void | EncryptXmlNodeL | ( | TXmlEngElement | aNode | ) |
Encrypts xml node.
S60 v3.2
Encrypted content will replace aNode. aNode contains the result.
| TXmlEngElement aNode | xml node that should be encrypted. |
| IMPORT_C CXmlSecEncrypt * | NewLC | ( | ) | [static] |
Creates new object and puts it on cleanup stack.
S60 v3.2
pointer to new object
| 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.
S60 v3.2
| 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) |
| 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.
S60 v3.2
| 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 |
| 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.
S60 v3.2
| const TDesC8 & aKeyName | Key name that should be set. |
| 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.
S60 v3.2
| TXmlEngElement aKeyProp | Element that should be set. |
| 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.
S60 v3.2
| const TDesC8 & aTemplate | template xml in buffer |
| IMPORT_C void | SetTemplateFromFileL | ( | const TDesC8 & | aTemplate | ) |
Sets encryption template (parses template file). This template will be used until new template will be set.
S60 v3.2
| const TDesC8 & aTemplate | template file |
| 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.
S60 v3.2
| 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.
S60 v3.2
| const RXmlEngDocument & aTemplate | DOM tree with template document |
Key types. Currently symmetric key (AES (256 bit) or 3DES)
| EAES256 = 0 | |
| E3DES |