#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include "apps.h"
#include <openssl/bio.h>
#include <openssl/err.h>
{"d", OPT_D, '-', "Decrypt"},
{"p", OPT_P, '-', "Print the iv/key"},
{"P", OPT_UPPER_P, '-', "Print the iv/key and exit"},
- {"v", OPT_V, '-'},
+ {"v", OPT_V, '-', "Verbose output"},
{"nopad", OPT_NOPAD, '-', "Disable standard block padding"},
- {"salt", OPT_SALT, '-'},
- {"nosalt", OPT_NOSALT, '-'},
- {"debug", OPT_DEBUG, '-'},
- {"A", OPT_UPPER_A, '-'},
- {"a", OPT_A, '-', "base64 encode/decode, depending on encryption flag"},
- {"base64", OPT_A, '-', "Base64 output as a single line"},
+ {"salt", OPT_SALT, '-', "Use salt in the KDF (default)"},
+ {"nosalt", OPT_NOSALT, '-', "Do not use salt in the KDF"},
+ {"debug", OPT_DEBUG, '-', "Print debug info"},
+ {"a", OPT_A, '-', "Base64 encode/decode, depending on encryption flag"},
+ {"base64", OPT_A, '-', "Same as option -a"},
+ {"A", OPT_UPPER_A, '-',
+ "Used with -[base64|a] to specify base64 buffer as a single line"},
{"bufsize", OPT_BUFSIZE, 's', "Buffer size"},
{"k", OPT_K, 's', "Passphrase"},
{"kfile", OPT_KFILE, '<', "Fead passphrase from file"},
int ret = 1, inl, nopad = 0;
unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH];
unsigned char *buff = NULL, salt[PKCS5_SALT_LEN];
- unsigned long n;
+ long n;
#ifdef ZLIB
int do_zlib = 0;
BIO *bzl = NULL;
k = i >= 1 && p[i] == 'k';
if (k)
p[i] = '\0';
- if (!opt_ulong(opt_arg(), &n))
+ if (!opt_long(opt_arg(), &n)
+ || n < 0 || (k && n >= LONG_MAX / 1024))
goto opthelp;
if (k)
n *= 1024;
printf("%02X", salt[i]);
printf("\n");
}
- if (cipher->key_len > 0) {
+ if (EVP_CIPHER_key_length(cipher) > 0) {
printf("key=");
- for (i = 0; i < cipher->key_len; i++)
+ for (i = 0; i < EVP_CIPHER_key_length(cipher); i++)
printf("%02X", key[i]);
printf("\n");
}
- if (cipher->iv_len > 0) {
+ if (EVP_CIPHER_iv_length(cipher) > 0) {
printf("iv =");
- for (i = 0; i < cipher->iv_len; i++)
+ for (i = 0; i < EVP_CIPHER_iv_length(cipher); i++)
printf("%02X", iv[i]);
printf("\n");
}