in src/ecdh_support.c [189:208]
void KDF2(int sha,const octet *z,const octet *p,int olen,octet *key)
{
/* NOTE: the parameter olen is the length of the output k in bytes */
char h[64];
octet H= {0,sizeof(h),h};
int cthreshold;
int hlen=sha;
OCT_empty(key);
cthreshold=ROUNDUP(olen,hlen);
for (int counter=1; counter<=cthreshold; counter++)
{
ehashit(sha,z,counter,p,&H,0);
if (key->len+hlen>olen) OCT_jbytes(key,H.val,olen%hlen);
else OCT_joctet(key,&H);
}
}