Extracts a key from a binary HMAC secret value for use by C/C++ applications.
IXMLDSigKeyPtr objKey= oXMLDigitalSignature->createKeyFromHMACSecretBinary( (byte*)secret, (LONG)lSecretLen, (LONG)lHMACOutputLength);
HRESULT createKeyFromHMACSecretBinary( CONST byte* secret, LONG lSecretLen, LONG lHMACOutputLength, IXMLDSigKey** keyObj);
<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. |
IXMLDSigKey
interface. In C/C++ with smart pointer class wrappers, this is the resultant key object.The method returns the standard HRESULT values defined in the CryptoAPI, including the following:
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.
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.
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.
createKeyFromHMACSecret Method