class CXmlSecSign : public CBase |
Class used to sign data.
How to use:
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);
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.
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
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.
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
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 ) |
Private Member Functions | |
---|---|
CXmlSecSign () | |
void | ConstructL () |
TXmlEngElement | SignXmlNodeL ( TXmlEngElement , TBool ) |
Public Member Enumerations | |
---|---|
enum | TXmlSecKeyType { ERSAPrivate = 0, ERSAPublic , EHMAC } |
enum | TXmlSecVerificationKeyRepository { EThisObject = 0, ECertStore , ERootCertChain } |
Public Attributes | |
---|---|
const TUint | KC14N |
const TUint | KEnvelopedSignature |
const TUint | KExclusiveC14N |
Private Attributes | |
---|---|
CXmlSecKeyManager * | iMngr |
void * | iSigCtx |
TBool | iSkipTmplLookUp |
RXmlEngDocument | iTemplate |
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.
const TDesC8 & aCert | Buffer with certificate. |
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.
const TDesC8 & aCertFile | Name of the file with certificate. |
IMPORT_C const RXmlEngDocument & | CreateTemplateL | ( | TXmlSecKeyType | aKeyType, |
TBool | aCert = EFalse, | |||
TUint | aTransforms = KEnvelopedSignature , | |||
const TDesC8 & | aPref = KNullDesC8 (), | |||
TBool | aNewLine = TRUE | |||
) |
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.
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 |
IMPORT_C const RXmlEngDocument & | CreateTemplateL | ( | TXmlSecKeyType | aKeyType, |
RArray < TXmlEngElement > & | aNodes, | |||
const TDesC8 & | aId, | |||
TBool | aCert = EFalse, | |||
TUint | aTransforms = KEnvelopedSignature , | |||
const TDesC8 & | aPref = KNullDesC8 (), | |||
TBool | aNewLine = TRUE | |||
) |
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.
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 |
IMPORT_C const RXmlEngDocument & | CurrentTemplate | ( | ) | const |
Gets current template.
IMPORT_C void | DestroyCurrentTemplate | ( | ) |
Destroys current template.
IMPORT_C CXmlSecSign * | NewLC | ( | ) | [static] |
Creates new object and puts it on cleanup stack.
IMPORT_C void | SetCertFromBufferL | ( | const TDesC8 & | aCert | ) |
Reads certificate from buffer. This certificate will be added to current key.
const TDesC8 & aCert | Buffer with certificate inside |
IMPORT_C void | SetCertFromFileL | ( | const TDesC8 & | aCertFile | ) |
Reads certificate from file. This certificate will be added to current key.
const TDesC8 & aCertFile | Name of the file with certificate inside |
IMPORT_C void | SetKeyFromBufferL | ( | const TDesC8 & | aKey, |
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Reads key from buffer and puts it to the SymbianKeyStore. Key will be used during signing/verification action until new key will be set.
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 |
IMPORT_C void | SetKeyFromFileL | ( | const TDesC8 & | aKeyFile, |
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Reads key from file and puts it to the SymbianKeyStore. Key will be used during signing/verification action until new key will be set.
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 |
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.
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.
TXmlEngElement aKeyProp | Element that should be set. |
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.
const TDesC8 & aTemplate | template xml in buffer |
IMPORT_C void | SetTemplateFromFileL | ( | const TDesC8 & | aTemplate | ) |
Sets signing template (parses template file). This template will be used until new template will be set.
const TDesC8 & aTemplate | template file |
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.
IMPORT_C void | SetTemplateL | ( | const RXmlEngDocument & | aTemplate | ) |
Set copy of the argument as a sign template. This template will be used until new template will be set.
const RXmlEngDocument & aTemplate | DOM tree with template document |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromBufferL | ( | RXmlEngDocument & | aDocument, |
RXmlEngDocument & | aTemplate, | |||
const TDesC8 & | aKey, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Signs xml document.
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)
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) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromBufferL | ( | RXmlEngDocument & | aDocument, |
const TDesC8 & | aKey, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Signs xml document.
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)
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) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromFileL | ( | RXmlEngDocument & | aDocument, |
RXmlEngDocument & | aTemplate, | |||
const TDesC8 & | aKeyFile, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Signs xml document.
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)
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) |
IMPORT_C TXmlEngElement | SignXmlDocumentKeyFromFileL | ( | RXmlEngDocument & | aDocument, |
const TDesC8 & | aKeyFile, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Signs xml document.
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)
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) |
IMPORT_C TXmlEngElement | SignXmlDocumentL | ( | RXmlEngDocument & | aDocument, |
TBool | aUseCurrentKey = ETrue | |||
) |
Signs xml document.
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)
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. |
TXmlEngElement | SignXmlNodeL | ( | TXmlEngElement | aNode, |
TBool | aUseCurrentKey | |||
) | [private] |
Signs the xml node.
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. |
IMPORT_C TXmlEngElement | SignXmlNodesL | ( | RArray < TXmlEngElement > & | aNodes, |
TBool | aUseCurrentKey = ETrue | |||
) |
Signs xml nodes.
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)
IMPORT_C TBool | VerifyXmlDocumentKeyFromBufferL | ( | const RXmlEngDocument & | aDocument, |
const TDesC8 & | aKey, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Verifies xml document.
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) |
IMPORT_C TBool | VerifyXmlDocumentKeyFromFileL | ( | const RXmlEngDocument & | aDocument, |
const TDesC8 & | aKeyFile, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Verifies xml document.
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) |
IMPORT_C TBool | VerifyXmlDocumentL | ( | const RXmlEngDocument & | aDocument, |
TXmlSecVerificationKeyRepository | aKeyRepository = EThisObject | |||
) |
Verifies xml document.
const RXmlEngDocument & aDocument | Document that should be verified. |
TXmlSecVerificationKeyRepository aKeyRepository = EThisObject |
IMPORT_C TBool | VerifyXmlNodeKeyFromBufferL | ( | TXmlEngElement | aNode, |
const TDesC8 & | aKey, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Verifies xml node.
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) |
IMPORT_C TBool | VerifyXmlNodeKeyFromFileL | ( | TXmlEngElement | aNode, |
const TDesC8 & | aKeyFile, | |||
const TDesC8 & | aKeyName, | |||
TXmlSecKeyType | aKeyType | |||
) |
Verifies xml node.
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) |
IMPORT_C TBool | VerifyXmlNodeL | ( | TXmlEngElement | aNode, |
TXmlSecVerificationKeyRepository | aKeyRepository = EThisObject | |||
) |
Verifies xml node.
TXmlEngElement aNode | Node that should be verified (<Signature> element). |
TXmlSecVerificationKeyRepository aKeyRepository = EThisObject |
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)
ERSAPrivate = 0 | |
ERSAPublic | |
EHMAC |
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
EThisObject = 0 | |
ECertStore | |
ERootCertChain |
const TUint | KEnvelopedSignature | [static] |
Use Enveloped Signature Transform
TBool | iSkipTmplLookUp | [private] |
Flag to skip searching for Template in document
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.