On Friday 08 January 2016 13:16:27 Niels Möller wrote:
Tim Ruehsen tim.ruehsen@gmx.de writes:
I meanwhile found the nettle docs on the web
I'm happy you found the documentation. The manual should also be included in debian's nettle-dev package, in info, html and pdf formats.
########### Function: void md5_digest (struct md5_ctx *ctx, size_t length, uint8_t *digest)
Performs final processing and extracts the message digest, writing it to digest. length may be smaller than MD5_DIGEST_SIZE, in which case only the first length octets of the digest are written. ###########
Sorry you find this unclear. Can you suggest a concise improvement?
Never said the text is unclear. It just misses the case when 'length' is too large. Citing my proposal from my previous email:
'If length is larger than MD5_DIGEST_SIZE the function does not return - it calls abort()'
Or more precise If length is larger than MD5_DIGEST_SIZE an assertion is generated and by that the program is terminated by abort(). To avoid this behavior nettle has to be compiled with -DNDEBUG (additional bytes will not be touched).
ctx = alloca(hash->context_size); hash->init(ctx); hash->update(ctx, length, msg); hash->digest(ctx, hash->digest_size, digest); return hash->digest_size;
}
I don't think that passing a valid digest size to hash->digest here should be a big deal.
Thanks Niels. This part is already up and running. My writing was for Amos to make clear that MD5_DIGEST_SIZE and the like are not needed from a higher level perspective.
Regards, Tim