CXmlSecSign Class Reference
class CXmlSecSign : public CBase |
Class used to sign data.
How to use:
Signing with key from
file:
1. Create new object:
CXmlSecSign* sign = CXmlSecSign::NewLC();
2. Set template for signing:
sign->SetTemplateFromFileL(doc);
3. Set the key that should be used during signing:
sign->SetKeyFromFileL(keyfilename,keyname,CXmlSecSign::ERSA_PRIVATE);
4. Sign xml node:
element = sign->SignXmlDocumentL(doc);
Signing with key from SymbianKeyStore:
1. Create new object:
CXmlSecSign* sign = CXmlSecSign::NewLC();
2. Set template for signing:
sign->SetTemplateFromFileL(doc);
3. Set the name of the key that should be used during signing:
sign->SetKeyInfoL(keyname);
4. Sign xml node:
element = sign->SignXmlDocumentL(doc,FALSE);
second parameter sets to FALSE determine using keys from SymbianKeyStore.
Verification with key:
1. Create new object:
CXmlSecSign* sign = CXmlSecSign::NewLC();
3. Set the key that should be used during verification (it should be set before verification):
sign->SetKeyFromFileL(keyfilename, keyname, CXmlSecSign::ERSA_PUBLIC);
3. Verify the signature
ver=sign->VerifyXmlNodeL(element);
function will return true if sign is correct
Verification with certificate from root's cert chain:
1. Create new object:
CXmlSecSign* sign = CXmlSecSign::NewLC();
2. Add trusted root certificate from file:
sign->AddTrustedCertFromFileL(trustedCert);
3. Verify the signature:
ver=sign->VerifyXmlNodeL(element, CXmlSecSign::ERootCertChain);
Function will return true if sign is correct.
Verification with certificate from SymbianCertStore:
1. Create new object:
CXmlSecSign* sign = CXmlSecSign::NewLC();
2. Verify the signature:
ver=sign->VerifyXmlNodeL(element, CXmlSecSign::ECertStore);
Function will return true if sign is correct
XmlSecWrapper.dll
- Since
- S60 v3.2
Public Member Functions |
---|
| ~CXmlSecSign() |
IMPORT_C void | AddTrustedCertFromBufferL(const TDesC8 &) |
IMPORT_C void | AddTrustedCertFromFileL(const TDesC8 &) |
IMPORT_C const RXmlEngDocument & | CreateTemplateL(TXmlSecKeyType, TBool, TUint, const TDesC8 &, TBool) |
IMPORT_C const RXmlEngDocument & | CreateTemplateL(TXmlSecKeyType, RArray< TXmlEngElement > &, const TDesC8 &, TBool, TUint, const TDesC8 &, TBool) |
IMPORT_C const RXmlEngDocument & | CurrentTemplate() |
IMPORT_C void | DestroyCurrentTemplate() |
IMPORT_C CXmlSecSign * | NewL() |
IMPORT_C CXmlSecSign * | NewLC() |
IMPORT_C void | SetCertFromBufferL(const TDesC8 &) |
IMPORT_C void | SetCertFromFileL(const TDesC8 &) |
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 &) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromBufferL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromBufferL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromFileL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromFileL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TXmlEngElement | SignXmlDocumentL(RXmlEngDocument &, TBool) |
IMPORT_C TXmlEngElement | SignXmlNodesL(RArray< TXmlEngElement > &, TBool) |
IMPORT_C TBool | VerifyXmlDocumentKeyFromBufferL(const RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TBool | VerifyXmlDocumentKeyFromFileL(const RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TBool | VerifyXmlDocumentL(const RXmlEngDocument &, TXmlSecVerificationKeyRepository) |
IMPORT_C TBool | VerifyXmlNodeKeyFromBufferL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TBool | VerifyXmlNodeKeyFromFileL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType) |
IMPORT_C TBool | VerifyXmlNodeL(TXmlEngElement, TXmlSecVerificationKeyRepository) |
Constructor & Destructor Documentation
Member Functions Documentation
AddTrustedCertFromBufferL(const TDesC8 &)
IMPORT_C void | AddTrustedCertFromBufferL | ( | const TDesC8 & | aCert | ) | |
Reads X509 certificate from buffer and adds it to root's cert chain handled in memory (destroyed after session). This certificate IS NOT added to SymbianCertStore.
Parameters
const TDesC8 & aCert | Buffer with certificate. |
AddTrustedCertFromFileL(const TDesC8 &)
IMPORT_C void | AddTrustedCertFromFileL | ( | const TDesC8 & | aCertFile | ) | |
Reads X509 certificate from file and adds it to root's cert chain handled in memory (destroyed after session). This certificate IS NOT added to SymbianCertStore.
Parameters
const TDesC8 & aCertFile | Name of the file with certificate. |
ConstructL()
void | ConstructL | ( | ) | [private] |
Second phase constructor.
CreateTemplateL(TXmlSecKeyType, TBool, TUint, const TDesC8 &, TBool)
Creates template for singning. Template is created for specific key algorithm. This templete will sign whole xml document.
This template will be used until new template will be set. Only SHA1 digest method is supported.
Parameters
TXmlSecKeyType aKeyType | Key type determine signatureMethod. |
TBool aCert = EFalse | If sets to TRUE then element <X509Certificate> will be added to template. |
TUint aTransforms =
KEnvelopedSignature
| |
const TDesC8 & aPref =
KNullDesC8() | prefix that will be used for signature namespace |
TBool aNewLine = TRUE | should new line be used in template |
CreateTemplateL(TXmlSecKeyType, RArray< TXmlEngElement > &, const TDesC8 &, TBool, TUint, const TDesC8 &, TBool)
Creates template for signing. Template is created for specific key algorithm. Templete allows to sign element(s) identified by id.
This template will be used until new template will be set. Only SHA1 digest method is supported.
Parameters
TXmlSecKeyType aKeyType | Key type determine signatureMethod. |
RArray< TXmlEngElement > & aNodes | Array with nodes that should be signed |
const TDesC8 & aId | Id name that should be used in Reference (i.e."ns:Id") |
TBool aCert = EFalse | If sets to TRUE then element <X509Certificate> will be added to template. |
TUint aTransforms =
KEnvelopedSignature
| |
const TDesC8 & aPref =
KNullDesC8() | prefix that will be used for signature namespace |
TBool aNewLine = TRUE | should new line be used in template |
DestroyCurrentTemplate()
IMPORT_C void | DestroyCurrentTemplate | ( | ) | |
Destroys current template.
NewLC()
Creates new object and puts it on cleanup stack.
SetCertFromBufferL(const TDesC8 &)
IMPORT_C void | SetCertFromBufferL | ( | const TDesC8 & | aCert | ) | |
Reads certificate from buffer. This certificate will be added to current key.
Parameters
const TDesC8 & aCert | Buffer with certificate inside |
SetCertFromFileL(const TDesC8 &)
IMPORT_C void | SetCertFromFileL | ( | const TDesC8 & | aCertFile | ) | |
Reads certificate from file. This certificate will be added to current key.
Parameters
const TDesC8 & aCertFile | Name of the file with certificate inside |
SetKeyFromBufferL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Reads key from buffer and puts it to the SymbianKeyStore. Key will be used during signing/verification action until new key will be set.
Parameters
const TDesC8 & aKey | Buffer with key (only binary format. In case of RSA private key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key (it can be null descriptor when HMAC key is used) |
TXmlSecKeyType aKeyType | |
SetKeyFromFileL(const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Reads key from file and puts it to the SymbianKeyStore. Key will be used during signing/verification action until new key will be set.
Parameters
const TDesC8 & aKeyFile | File with key (only binary format. In case of RSA private key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key (it can be null descriptor when HMAC key is used) |
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)
Adds element to <KeyInfo> node. This method allows to add specific data to <KeyInfo> element. The element will be added to current template.
SetTemplateFromBufferL(const TDesC8 &)
IMPORT_C void | SetTemplateFromBufferL | ( | const TDesC8 & | aTemplate | ) | |
Sets signing 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 signing 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 signing 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 &)
Set copy of the argument as a sign template. This template will be used until new template will be set.
SignXmlDocumentKeyFromBufferL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Signs xml document.
- Since
- S60 v3.2
Note:
If signature template was used, result should be added by user to correct node in the document. If signature context was in document previously, no action is needed (signature is in place where it was before signing)
Parameters
RXmlEngDocument & aDocument | DOM tree that should be signed. |
RXmlEngDocument & aTemplate | Template document |
const TDesC8 & aKey | Buffer with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
SignXmlDocumentKeyFromBufferL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Signs xml document.
- Since
- S60 v3.2
Note:
Signature context should be in the document that should be sign
If signature template was used, result should be added by user to correct node in the document. If signature context was in document previously, no action is needed (signature is in place where it was before signing)
Parameters
RXmlEngDocument & aDocument | DOM tree that should be signed. |
const TDesC8 & aKey | Buffer with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
SignXmlDocumentKeyFromFileL(RXmlEngDocument &, RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Signs xml document.
- Since
- S60 v3.2
Note:
If signature template was used, result should be added by user to correct node in the document. If signature context was in document previously, no action is needed (signature is in place where it was before signing)
Parameters
RXmlEngDocument & aDocument | DOM tree that should be signed. |
RXmlEngDocument & aTemplate | Template document |
const TDesC8 & aKeyFile | File with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
SignXmlDocumentKeyFromFileL(RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Signs xml document.
- Since
- S60 v3.2
Note:
Signature context should be in the document that should be sign
If signature template was used, result should be added by user to correct node in the document. If signature context was in document previously, no action is needed (signature is in place where it was before signing)
Parameters
RXmlEngDocument & aDocument | DOM tree that should be signed. |
const TDesC8 & aKeyFile | File with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
SignXmlDocumentL(RXmlEngDocument &, TBool)
Signs xml document.
- Since
- S60 v3.2
Note:
If signature template was used, result should be added by user to correct node in the document. If signature context was in document previously, no action is needed (signature is in place where it was before signing)
Parameters
RXmlEngDocument & aDocument | DOM tree that should be signed. |
TBool aUseCurrentKey = ETrue | Current key (sets by SetKey function) will be used. If sets to FALSE then key manager will be used. |
SignXmlNodeL(TXmlEngElement, TBool)
Parameters
TXmlEngElement aNode | TElement Node that should be sign. |
TBool aUseCurrentKey | Current key (set by SetKey method) will be used. If sets to FALSE then key manager will be used. |
SignXmlNodesL(RArray< TXmlEngElement > &, TBool)
Signs xml nodes.
- Since
- S60 v3.2
Note:
If signature template was used, result should be added by user to correct node in the document. If signature context was in document previously, no action is needed (signature is in place where it was before signing)
Parameters
RArray< TXmlEngElement > & aNodes | Nodes that should be signed. |
TBool aUseCurrentKey = ETrue | Current key (sets by SetKey method) will be used. If sets to FALSE then key manager will be used. |
VerifyXmlDocumentKeyFromBufferL(const RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Parameters
const RXmlEngDocument & aDocument | DOM tree that should be verified. |
const TDesC8 & aKey | Buffer with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
VerifyXmlDocumentKeyFromFileL(const RXmlEngDocument &, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Parameters
const RXmlEngDocument & aDocument | DOM tree that should be verified. |
const TDesC8 & aKeyFile | File with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
VerifyXmlDocumentL(const RXmlEngDocument &, TXmlSecVerificationKeyRepository)
VerifyXmlNodeKeyFromBufferL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Parameters
TXmlEngElement aNode | Node that should be verified (<Signature> element). |
const TDesC8 & aKey | Buffer with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
VerifyXmlNodeKeyFromFileL(TXmlEngElement, const TDesC8 &, const TDesC8 &, TXmlSecKeyType)
Parameters
TXmlEngElement aNode | Node that should be verified (<Signature> element). |
const TDesC8 & aKeyFile | File with key (only binary format. In case of RSA key type - PKCS#8 syntax, DER encoding) |
const TDesC8 & aKeyName | name of the key |
TXmlSecKeyType aKeyType | key type (i.e. HMAC) |
VerifyXmlNodeL(TXmlEngElement, TXmlSecVerificationKeyRepository)
Member Enumerations Documentation
Enum TXmlSecKeyType
Key types. Currently simmetric key (used by HMAC algorithm) and asimmetric key (used by RSA algorithm) is supported. RSAPrivate is for private key (PKCS#8 syntax, DER encoding) RSAPrivate is for public key (DER encoding)
Enumerators
ERSAPrivate = 0 | |
ERSAPublic | |
EHMAC | |
Enum TXmlSecVerificationKeyRepository
Verification key repository. A place where is key to use in verification. EThisObject - Key can set by SetKey method ECertStore - Symbian certificate store (CUnifiedCertStore) ERootCertChain - Trusted root cert set can be add by AddTrustedCertFrom(File/Buffer)L method
Enumerators
EThisObject = 0 | |
ECertStore | |
ERootCertChain | |
Member Data Documentation
const TUint KEnvelopedSignature
const TUint | KEnvelopedSignature | [static] |
Use Enveloped Signature Transform
const TUint KExclusiveC14N
const TUint | KExclusiveC14N | [static] |
Use Exclusive c14n Transform
CXmlSecKeyManager * iMngr
TBool
iSkipTmplLookUp
TBool
| iSkipTmplLookUp | [private] |
Flag to skip searching for Template in document
RXmlEngDocument
iTemplate
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.