libtomcrypt icon indicating copy to clipboard operation
libtomcrypt copied to clipboard

Polish API `unsigned long outlen` vs. `unsigned long *outlen`

Open karel-m opened this issue 7 years ago • 3 comments

based on discussion in #171 I have found the following places where we IMO handle incosistently outlen

pelican_done(pelican_state *pelmac, unsigned char *out);  /* missing outlen*/
crc32_finish(.... void *hash, unsigned long size);        /* should be: unsigned long *size */
adler32_finish(.... void *hash, unsigned long size);      /* should be: unsigned long *size */

karel-m avatar Mar 23 '17 19:03 karel-m

Looking at these it also became obvious to me that there's different paradigms used for different classes of algorithms... like the XXhash_done() functions always use the same signature as pelican_done() and TBH I'm not sure yet how much I (dis)like that type of signature...

sjaeckel avatar Mar 23 '17 23:03 sjaeckel

well i suppose in the case of crc32_finish it's clear that the result len will be 4 bytes, so there's no need to pass a pointer-to where the size is being written to by the callee.

rofl0r avatar Mar 23 '17 23:03 rofl0r

well i suppose in the case of crc32_finish it's clear that the result len will be 4 bytes, so there's no need to pass a pointer-to where the size is being written to by the callee.

But it is exactly the same case in many mac/authenc functions returning a tag of fixed length (where we utilize unsigned long *outlen parameter)

karel-m avatar Mar 24 '17 06:03 karel-m