I see in tlshand.c in libsec:

        // get current hash value, but allow further messages to be hashed in
        sha2_256(nil, 0, seed, &hsh.sha2_256);

I assume passing nil and 0 allows the hashing function to just dump the current 
hash in seed in our case.

I also assume multiple calls with nil and 0 will return the same value.

It doesn't!

Calling sha2_256 with nil and 0 again returns a different value.

Am I misunderstanding the behavior or is this just incomplete?

Test program:

#include <u.h>
#include <libc.h>
#include <libsec.h>

void
main(void)
{
uchar d1[SHA2_256dlen], d2[SHA2_256dlen], d3[SHA2_256dlen], s1[] = "hello,", 
s2[] = "world";
DigestState s;
int i;

sha2_256(s1, 6, nil, &s);
sha2_256(s2, 5, d1, &s);
print( "main: 1st call: d1: \n");
for(i = 0; i < SHA2_256dlen; i++) {
print("%02x", d1[i]);
}
print("\n");
sha2_256(nil, 0, d2, &s);
print( "main: 2st call: d2: \n");
for(i = 0; i < SHA2_256dlen; i++) {
print("%02x", d2[i]);
}
print("\n");
sha2_256(nil, 0, d3, &s);
print( "main: 3rd call: d3: \n");
for(i = 0; i < SHA2_256dlen; i++) {
print("%02x", d3[i]);
}
print("\n");
exits(0);
}
------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T47e5e753bbea6149-Md6163eb2b0836a5b4c8ebcbe
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to