There are times when one needs to add to an existing hash, such as when calculating the HMAC hashes for TLS. With CAPI, the hash function could be easily split into separate functions; create the hash, add to the hash, and finish the hash. All you had to do was save the Hash Handle. Using CNG, it is a little more involved.
CNG uses objects extensively, and although the Hash Handle is the only element required for the BCryptFinishHash function, it is useless without the Hash Object. In the attached test program, the Hash Handle, the Hash Length, and the Hash Object are saved by the calling function. In reality, the Hash Object is the only thing that needs to be preserved, because the other two values are both contained within:
The Hash Length is in byte(0), and the Hash Handle starts at byte(12).
J.A. Coutts
CNG uses objects extensively, and although the Hash Handle is the only element required for the BCryptFinishHash function, it is useless without the Hash Object. In the attached test program, the Hash Handle, the Hash Length, and the Hash Object are saved by the calling function. In reality, the Hash Object is the only thing that needs to be preserved, because the other two values are both contained within:
Code:
Hash Object:
14 00 00 00 53 55 55 55 F0 D7 20 00 24 9D 52 04
00 00 00 00 70 00 00 00 48 48 53 4D 02 00 02 00
14 00 00 00 00 00 00 00 54 65 73 74 20 73 74 72
69 6E 67 20 74 6F 20 48 61 73 68 2E 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 01 23 45 67 89 AB CD EF
FE DC BA 98 76 54 32 10 F0 E1 D2 C3 00 00 00 00
14 00 00 00 00 00 00 00 00 00
J.A. Coutts