* Check the IV length during option parsing, rather than at the end.
* Don't accumulate IV material because we don't do that with keys.
break;
case 'i': {
char *p;
break;
case 'i': {
char *p;
unhex(optarg, &p, &iv);
if (*p)
die(EXIT_FAILURE, "bad hex IV `%s'", optarg);
unhex(optarg, &p, &iv);
if (*p)
die(EXIT_FAILURE, "bad hex IV `%s'", optarg);
+ if (iv.len != ciphertab[i].blksz) {
+ die(EXIT_FAILURE, "bad IV length %lu (must be %lu)",
+ (unsigned long)iv.len, (unsigned long)ciphertab[i].blksz);
+ }
} break;
default:
return (0);
} break;
default:
return (0);
if (!d.len)
randkey(&d, ciphertab[i].keysz);
r = ciphertab[i].ofb(d.buf, d.len);
if (!d.len)
randkey(&d, ciphertab[i].keysz);
r = ciphertab[i].ofb(d.buf, d.len);
- if (iv.len) {
- if (iv.len != ciphertab[i].blksz) {
- die(EXIT_FAILURE, "bad IV length %lu (must be %lu)",
- (unsigned long)iv.len, (unsigned long)ciphertab[i].blksz);
- }
r->ops->misc(r, GRAND_SEEDBLOCK, iv.buf);
r->ops->misc(r, GRAND_SEEDBLOCK, iv.buf);
dstr_destroy(&d);
dstr_destroy(&iv);
dstr_destroy(&d);
dstr_destroy(&iv);
break;
case 'i': {
char *p;
break;
case 'i': {
char *p;
unhex(optarg, &p, &iv);
if (*p)
die(EXIT_FAILURE, "bad hex IV `%s'", optarg);
unhex(optarg, &p, &iv);
if (*p)
die(EXIT_FAILURE, "bad hex IV `%s'", optarg);
+ if (iv.len != ciphertab[i].blksz) {
+ die(EXIT_FAILURE, "bad IV length %lu (must be %lu)",
+ (unsigned long)iv.len, (unsigned long)ciphertab[i].blksz);
+ }
} break;
default:
return (0);
} break;
default:
return (0);
if (!d.len)
randkey(&d, ciphertab[i].keysz);
r = ciphertab[i].counter(d.buf, d.len);
if (!d.len)
randkey(&d, ciphertab[i].keysz);
r = ciphertab[i].counter(d.buf, d.len);
- if (iv.len) {
- if (iv.len != ciphertab[i].blksz) {
- die(EXIT_FAILURE, "bad IV length %lu (must be %lu)",
- (unsigned long)iv.len, (unsigned long)ciphertab[i].blksz);
- }
r->ops->misc(r, GRAND_SEEDBLOCK, iv.buf);
r->ops->misc(r, GRAND_SEEDBLOCK, iv.buf);
dstr_destroy(&d);
dstr_destroy(&iv);
dstr_destroy(&d);
dstr_destroy(&iv);