wycheproof_aead: divide by 8 at parse time

This commit is contained in:
Lucas Gabriel Vuotto 2024-05-31 11:47:42 +00:00
parent 7bc527c769
commit eedaa46831
1 changed files with 3 additions and 4 deletions

View File

@ -201,6 +201,7 @@ main(int argc, char *argv[])
ivlenarg = strtonum(optarg, 0, LLONG_MAX, &errstr); ivlenarg = strtonum(optarg, 0, LLONG_MAX, &errstr);
if (errstr != NULL) if (errstr != NULL)
errx(1, "ivlen is %s: %s", errstr, optarg); errx(1, "ivlen is %s: %s", errstr, optarg);
ivlenarg /= 8;
break; break;
case 'i': case 'i':
iflag = 1; iflag = 1;
@ -221,6 +222,7 @@ main(int argc, char *argv[])
errx(1, "keylen is %s: %s", errstr, optarg); errx(1, "keylen is %s: %s", errstr, optarg);
if (keylenarg % 8 != 0) if (keylenarg % 8 != 0)
errx(1, "unsupport K value: %zu", keylenarg); errx(1, "unsupport K value: %zu", keylenarg);
keylenarg /= 8;
break; break;
case 'k': case 'k':
kflag = 1; kflag = 1;
@ -251,6 +253,7 @@ main(int argc, char *argv[])
taglenarg = strtonum(optarg, 0, LLONG_MAX, &errstr); taglenarg = strtonum(optarg, 0, LLONG_MAX, &errstr);
if (errstr != NULL) if (errstr != NULL)
errx(1, "taglen is %s: %s", errstr, optarg); errx(1, "taglen is %s: %s", errstr, optarg);
taglenarg /= 8;
break; break;
case 't': case 't':
tflag = 1; tflag = 1;
@ -282,10 +285,6 @@ main(int argc, char *argv[])
return 1; return 1;
} }
ivlenarg /= 8;
keylenarg /= 8;
taglenarg /= 8;
out = malloc(outlen); out = malloc(outlen);
if (out == NULL) if (out == NULL)
err(1, "out of memory"); err(1, "out of memory");