mirror of https://github.com/ericonr/get-otp.git
Compare commits
2 Commits
599b7f431e
...
cf9b0f6a7c
Author | SHA1 | Date |
---|---|---|
Érico Nogueira | cf9b0f6a7c | |
Érico Nogueira | 5c237bf3d6 |
13
cbc-file.c
13
cbc-file.c
|
@ -42,9 +42,18 @@ CHACHA20POLY1305 = 1,
|
|||
};
|
||||
const enum encryption_type default_enctype = CHACHA20POLY1305;
|
||||
|
||||
/* constant time */
|
||||
static int ct_memcmp(const void *va, const void *vb, size_t l)
|
||||
{
|
||||
const unsigned char *a = va, *b = vb;
|
||||
unsigned char rv = 0;
|
||||
for (size_t i=0; i<l; i++) rv |= a[i] ^ b[i];
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fputs("Usage: cbd-file lock|unlock <file>", stderr);
|
||||
fputs("Usage: cbd-file lock|unlock <file>\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -194,7 +203,7 @@ int main(int argc, char **argv)
|
|||
|
||||
uint8_t new_tag[TAG_LENGTH];
|
||||
br_poly1305_ctmul_run(key, iv, buffer, bytes, aad, AAD_LENGTH, new_tag, br_chacha20_ct_run, 0);
|
||||
if (memcmp(tag, new_tag, TAG_LENGTH)) {
|
||||
if (ct_memcmp(tag, new_tag, TAG_LENGTH)) {
|
||||
fputs("bad tag!\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue