X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fpkeyutl.c;h=55394e1883483927462027574cdf64d482b7218d;hb=85c6749216f47bcefc916d4b0331794dac0a5db7;hp=6f2abcf54839e16ca258eac6182199549e3523a8;hpb=b010b7c43478bef11b936475d89b87b4144e7d29;p=oweals%2Fopenssl.git diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index 6f2abcf548..55394e1883 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -80,8 +80,8 @@ static int setup_peer(BIO *err, EVP_PKEY_CTX *ctx, int peerform, const char *file); static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op, - unsigned char *out, int *poutlen, - unsigned char *in, int inlen); + unsigned char *out, size_t *poutlen, + unsigned char *in, size_t inlen); int MAIN(int argc, char **); @@ -99,7 +99,8 @@ int MAIN(int argc, char **argv) int keysize = -1; unsigned char *buf_in = NULL, *buf_out = NULL, *sig = NULL; - int buf_inlen, buf_outlen, siglen = -1; + size_t buf_outlen; + int buf_inlen = 0, siglen = -1; int ret = 1, rv = -1; @@ -314,20 +315,22 @@ int MAIN(int argc, char **argv) } if(rev) { - int i; + size_t i; unsigned char ctmp; - for(i = 0; i < buf_inlen/2; i++) + size_t l = (size_t)buf_inlen; + for(i = 0; i < l/2; i++) { ctmp = buf_in[i]; - buf_in[i] = buf_in[buf_inlen - 1 - i]; - buf_in[buf_inlen - 1 - i] = ctmp; + buf_in[i] = buf_in[l - 1 - i]; + buf_in[l - 1 - i] = ctmp; } } } if(pkey_op == EVP_PKEY_OP_VERIFY) { - rv = EVP_PKEY_verify(ctx, sig, siglen, buf_in, buf_inlen); + rv = EVP_PKEY_verify(ctx, sig, (size_t)siglen, + buf_in, (size_t)buf_inlen); if (rv == 0) BIO_puts(out, "Signature Verification Failure\n"); else if (rv == 1) @@ -337,8 +340,8 @@ int MAIN(int argc, char **argv) } else { - rv = do_keyop(ctx, pkey_op, NULL, &buf_outlen, - buf_in, buf_inlen); + rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen, + buf_in, (size_t)buf_inlen); if (rv > 0) { buf_out = OPENSSL_malloc(buf_outlen); @@ -346,8 +349,8 @@ int MAIN(int argc, char **argv) rv = -1; else rv = do_keyop(ctx, pkey_op, - buf_out, &buf_outlen, - buf_in, buf_inlen); + buf_out, (size_t *)&buf_outlen, + buf_in, (size_t)buf_inlen); } } @@ -387,20 +390,23 @@ static void usage() BIO_printf(bio_err, "Usage: pkeyutl [options]\n"); BIO_printf(bio_err, "-in file input file\n"); BIO_printf(bio_err, "-out file output file\n"); + BIO_printf(bio_err, "-signature file signature file (verify operation only)\n"); BIO_printf(bio_err, "-inkey file input key\n"); BIO_printf(bio_err, "-keyform arg private key format - default PEM\n"); - BIO_printf(bio_err, "-pubin input is an RSA public\n"); - BIO_printf(bio_err, "-certin input is a certificate carrying an RSA public key\n"); - BIO_printf(bio_err, "-ctrl X:Y control parameters\n"); + BIO_printf(bio_err, "-pubin input is a public key\n"); + BIO_printf(bio_err, "-certin input is a certificate carrying a public key\n"); + BIO_printf(bio_err, "-pkeyopt X:Y public key options\n"); BIO_printf(bio_err, "-sign sign with private key\n"); BIO_printf(bio_err, "-verify verify with public key\n"); + BIO_printf(bio_err, "-verifyrecover verify with public key, recover original data\n"); BIO_printf(bio_err, "-encrypt encrypt with public key\n"); BIO_printf(bio_err, "-decrypt decrypt with private key\n"); + BIO_printf(bio_err, "-derive derive shared secret\n"); BIO_printf(bio_err, "-hexdump hex dump output\n"); #ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); - BIO_printf(bio_err, "-passin arg pass phrase source\n"); #endif + BIO_printf(bio_err, "-passin arg pass phrase source\n"); } @@ -533,10 +539,10 @@ static int setup_peer(BIO *err, EVP_PKEY_CTX *ctx, int peerform, } static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op, - unsigned char *out, int *poutlen, - unsigned char *in, int inlen) + unsigned char *out, size_t *poutlen, + unsigned char *in, size_t inlen) { - int rv; + int rv = 0; switch(pkey_op) { case EVP_PKEY_OP_VERIFYRECOVER: