Where is SHA256_Update () defined in openssl / crypto?

I know that SHA256_Update () is implemented in libcrypto under opensl, but simple grep cannot 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 of these instances are where the function is called, but not its definition. However, if I do "nm libcrypto.so | grep SHA256_Update", the entry can be found.

Weird ...

Can anyone shed some light here?

+4
source share
1 answer

md32_common.h is the "template for the weak person" for C. It defines the structure of the general update function for any hash algorithm. Each algorithm provides a name for this general structure.

So in md32_common.h you will find this:

 int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len) 

And in sha / sha256.c you will find:

 #define HASH_UPDATE SHA256_Update 

So, when md32_common.h is enabled, you get a specific SHA256_Update function.

At the beginning of md32_common.h you will find a more complete explanation with an example.

+5
source

Source: https://habr.com/ru/post/1403544/


All Articles