Freigeben über


createKeyFromCSP Method

 

[This feature was implemented for MSXML 5.0 for Microsoft Office Applications. XML digital signatures are not supported in MXSML 6.0 and later.]

Extracts a key from a specified cryptographic service provider (CSP) and a specified key container. The resultant key can be used to sign or verify a signature.

Script Syntax

var objKey = objXMLDigitalSignature.createKeyFromCSP(  
      cspType,   
      cspName,   
      keyContainerName,   
      flag);   

Visual Basic Syntax

var objKey = objXMLDigitalSignature.createKeyFromCSP( _  
      cspType, _   
      cspName, _   
      keyContainerName, _   
      flag)  

C/C++ Syntax Using Smart Pointers

IXMLDSigKeyPtr objKey =   
   objXMLDigitalSignature->createKeyFromCSP(  
      long cspType,   
      _bstr_t cspName,   
      _bstr_t keyContainerName,   
      DWORD flag  
   );   

C/C++ Syntax

HRESULT createKeyFromCSP(  
    long cspType,   
    BSTR cspName,  
    BSTR keyContainerName,  
    long flag,  
    IXMLDSigKey** objKey);  

Parameters

cspType
A cryptographic service provider (CSP) type as defined in CryptoAPI. Only PROV_RSA_FULL and PROV_DSS_DH are supported.

cspName
The name of the CSP. To use the default provider, set this to an empty string ("").

keyContainerName
The name of the key container within the specified CSP. The container holds the key or keys issued by a certificate authority.

flag
Reserved. Must be zero.

objKey[out, retval]
In C/C++ this points to a key object implementing the IXMLDSigKey interface. In JScript, Visual Basic, and C/C++ with smart pointer class wrappers, this is the key object itself. The resultant key object can then be used in the call to the sign method or the verifiy method.

Return Values

This methods returns the standard CryptoAPI return values, including the following:

S_OK
The value returned if successful.

E_FAIL
The value returned if there was insufficient information, if the method call was not authorize, etc.

E_ACCESSDENIED
The value returned if the user does not have access to the security item.

Remarks

A digital certificate must have been installed locally for the createKeyFromCSP method to work properly.

Example

This example illustrates how to use the createKeyFromCSP method to generate a cryptographic key from the installed CSP, and uses this key to sign a document.

We've provided source files for the sample in three languages: JScript, Visual Basic, and C++. The output is the same in each language.

Applies to

IXMLDigitalSignature | IXMLDigitalSignatureEx

Versioning

MSXML 5.0 for Microsoft Office Applications and later

See Also

IXMLDigitalSignatureEx
createKeyFromCertContext Method
createKeyFromHMACSecret Method
createKeyFromHMACSecretBinary Method
createKeyFromNode Method
sign Method
verify Method