createKeyFromHMACSecretBinary Method
[This feature was first implemented for MSXML 5.0.]Extracts a key from a binary HMAC secret value for use by C/C++ applications.
C/C++ Syntax Using Smart Pointers
IXMLDSigKeyPtr objKey= oXMLDigitalSignature->createKeyFromHMACSecretBinary( (byte*)secret, (LONG)lSecretLen, (LONG)lHMACOutputLength);
C/C++ Syntax
HRESULT createKeyFromHMACSecretBinary( CONST byte* secret, LONG lSecretLen, LONG lHMACOutputLength, IXMLDSigKey** keyObj);
Parameters
- secret [in]
- Binary HMAC secret value.
- lSecretLen [in]
- Length of the binary HMAC secret value in bytes.
- lHMACOutputLength [in]
- Number of bits used to represent the secret value for signing or verify. The value of this parameter corresponds to the content of the
<ds:HMACOutputLength>
element in<ds:Signature>
. It can be a positive number in multiples of eight (8), or negative one (-1).The following table explains the meanings of the different possible values of
lHMACOutputLength
.value Meaning Positive number Bit length of the secret value. Must be in multiples of eight (8). If the length of the given secret value is longer than this number, it will be truncated to this number when signing. -1 Use the content of <ds:HMACOutputLength>
element from the containing<ds:SignatureMethod>
element. - objKey [out, retval]
- In C/C++ this is the reference to the resultant key object that implements the
IXMLDSigKey
interface. In C/C++ with smart pointer class wrappers, this is the resultant key object.
Return Values
The method returns the standard HRESULT values defined in the CryptoAPI, 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.
Remarks
This method has the same behavior as the createKeyFromHMACSecret
method, except that it takes a binary as the HMAC secret value and it can only called from a C/C++ application.
Example
This example illustrates how to use the createKeyFromHMACSecretBinary
method to generate a key for signing and verifying data referenced in an XML digital signature. This example is similar to the createKeyFromHMACSecretBinary Method example. The difference is that the binary value of the HMAC secret ("secret"
) is used, instead of the base64 encoded value ("c2VjcmV0"
). The two examples use the same resource file, and their output is identical.
- Resource File (signature-template-enveloping-hmac-sha1.xml)
- C/C++ Code (KeyFromHMACSecretBinary.cpp)
- Output for the KeyFromHMACSecretBinary Example
Applies To
Versioning
MSXML 5.0 and later
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
See Also
createKeyFromHMACSecret Method