dcsimg
Results 1 to 1 of 1

Thread: VB6 - Add to Hash using CNG

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    810

    VB6 - Add to Hash using CNG

    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:
    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
    The Hash Length is in byte(0), and the Hash Handle starts at byte(12).

    J.A. Coutts
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width