I know how standard HMAC(key,msg) function works, and I want to write a Delphi port of HMAC class that implements Update function. The problem is that I don't understand how this Update function works (for example of Update function, see SSL definition here: https://www.openssl.org/docs/crypto/hmac.html).
If I understand this correctly, these two pieces of pseudocode should return the same HMAC (e.g. Result1 = Result2):
Code 1: HMAC.Init; HMAC.Update('key','abc'); HMAC.Update('key','def'); Result1 = HMAC.Digest;
Code 2: HMAC.Init; HMAC.Update('key','abcdef'); Result2 = HMAC.Digest;
I have found Python implementation here: https://hg.python.org/cpython/file/2.7/Lib/hmac.py but I have no knowledge of Python (I am Delphi programmer) and I don't undesrtand it. Could somebody explain it to me, or, possible provide an example of pseudocode/Delphi?
EDIT: Probably I should have given some more details about the reason I have asked this question. Basically, I need to calculate HMAC(key,msg) where msg is a content of a stream/file, which can be big - and therefore its contents can't be passed to HMAC function at once. Therefore I need to read blocks of the stream and continuously update the HMAC message, so that after whole stream/file was processed, HMAC digest contains HMAC of the whole stream.