pkeyutl: Fix regression with -kdflen option
@@ -463,17 +463,18 @@ int pkeyutl_main(int argc, char **argv)
}
goto end;
}
- if (kdflen != 0) {
- buf_outlen = kdflen;
- rv = 1;
- } else {
if (rawin) {
/* rawin allocates the buffer in do_raw_keyop() */
rv = do_raw_keyop(pkey_op, mctx, pkey, in, filesize, NULL, 0,
&buf_out, (size_t *)&buf_outlen);
+ } else {
+ if (kdflen != 0) {
+ buf_outlen = kdflen;
+ rv = 1;
} else {
rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
buf_in, (size_t)buf_inlen);
+ }
if (rv > 0 && buf_outlen != 0) {
buf_out = app_malloc(buf_outlen, "buffer output");
rv = do_keyop(ctx, pkey_op,
@@ -481,7 +482,6 @@ int pkeyutl_main(int argc, char **argv)
buf_in, (size_t)buf_inlen);
}
}
- }
if (rv <= 0) {
if (pkey_op != EVP_PKEY_OP_DERIVE) {
BIO_puts(bio_err, "Public Key operation error\n");
