-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Aloha!
Niels Möller wrote:
There are lots of authentication functions which end by comparing two digests. The recent ccm_decrypt_message is typical, ending with
return (memcmp(tag, src + mlength, tlength) == 0);
int mem_equal (const void *ap, const void *bp, size_t n) { volatile const unsigned char *a = ap; volatile const unsigned char *b = bp
Missing semicolon for bp.
volatile unsigned char d; size_t i; for (i = d = 0; i < n; i++) d |= a[i] ^ b[i]; return d == 0;
You should return d here if you want the behaviour to match memcmp.
FWIW I implemented the function above (minus changes to stdint types) in my umactests. And for 100M messages, each 1024 Bytes I see something like a few second total increase in performance in comparison to using the memcmp provided in OSX. I can live with that.
- -- Med vänlig hälsning, Yours
Joachim Strömbergson - Alltid i harmonisk svängning. ======================================================================== Joachim Strömbergson Secworks AB joachim@secworks.se ========================================================================