I know that SHA256_Update() is implemented in libcrypto under openssl, yet, a simple grep can’t find its definition:
$ ack SHA256_Update
fips/fips_standalone_sha1.c
76: SHA256_Update(md_ctx,key,len);
87: SHA256_Update(md_ctx,pad,SHA256_CBLOCK);
92: SHA256_Update(o_ctx,pad,SHA256_CBLOCK);
100: SHA256_Update(o_ctx,buf,sizeof buf);
154: SHA256_Update(&md_ctx,buf,l);
evp/m_sha1.c
114: { return SHA256_Update(ctx->md_data,data,count); }
sha/sha256.c
58: SHA256_Update(&c,d,n);
71: SHA256_Update(&c,d,n);
78:{ return SHA256_Update (c,data,len); }
116:#define HASH_UPDATE SHA256_Update
All these instances are where the function gets called, but not its definition. Yet, if I do “nm libcrypto.so |grep SHA256_Update”, the entry can be found.
Weird…
Anyone could shed some light here?
md32_common.h is a “poor-man’s template” for C.
It defines the structure of a general update function for any hash algorithm. Each algorithm provides the name for this general structure.
So in md32_common.h you will find this:
And in sha/sha256.c you will find:
So that when md32_common.h is included, you get the function SHA256_Update defined.
At the beginning of md32_common.h you will find a more complete explanation with an example.