-/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
/* ====================================================================
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 **);
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;
if (!strcmp(*argv,"-in"))
{
if (--argc < 1) badarg = 1;
- infile= *(++argv);
+ else infile= *(++argv);
}
else if (!strcmp(*argv,"-out"))
{
if (--argc < 1) badarg = 1;
- outfile= *(++argv);
+ else outfile= *(++argv);
}
else if (!strcmp(*argv,"-sigfile"))
{
if (--argc < 1) badarg = 1;
- sigfile= *(++argv);
+ else sigfile= *(++argv);
}
else if(!strcmp(*argv, "-inkey"))
{
else if (!strcmp(*argv,"-passin"))
{
if (--argc < 1) badarg = 1;
- passargin= *(++argv);
+ else passargin= *(++argv);
}
else if (strcmp(*argv,"-peerform") == 0)
{
if (--argc < 1) badarg = 1;
- peerform=str2fmt(*(++argv));
+ else peerform=str2fmt(*(++argv));
}
else if (strcmp(*argv,"-keyform") == 0)
{
if (--argc < 1) badarg = 1;
- keyform=str2fmt(*(++argv));
+ else keyform=str2fmt(*(++argv));
}
#ifndef OPENSSL_NO_ENGINE
else if(!strcmp(*argv, "-engine"))
}
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)
}
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);
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);
}
}
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, "-sigfile 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");
}
}
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: