projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move supportedgroup ext-block fields out of NO_EC
[openssl.git]
/
apps
/
enc.c
diff --git
a/apps/enc.c
b/apps/enc.c
index db5d3a2991effb0c74c41d2ea071fe40265294f1..4b861640bf5c9eb0130cb4f2ae316622b45297f5 100644
(file)
--- a/
apps/enc.c
+++ b/
apps/enc.c
@@
-29,7
+29,7
@@
#define SIZE (512)
#define BSIZE (8*1024)
#define SIZE (512)
#define BSIZE (8*1024)
-static int set_hex(char *in, unsigned char *out, int size);
+static int set_hex(c
onst c
har *in, unsigned char *out, int size);
static void show_ciphers(const OBJ_NAME *name, void *bio_);
struct doall_enc_ciphers {
static void show_ciphers(const OBJ_NAME *name, void *bio_);
struct doall_enc_ciphers {
@@
-263,6
+263,10
@@
int enc_main(int argc, char **argv)
break;
}
}
break;
}
}
+ if (opt_num_rest() != 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
+ goto opthelp;
+ }
if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
@@
-457,7
+461,7
@@
int enc_main(int argc, char **argv)
int siz = EVP_CIPHER_iv_length(cipher);
if (siz == 0) {
BIO_printf(bio_err, "warning: iv not use by this cipher\n");
int siz = EVP_CIPHER_iv_length(cipher);
if (siz == 0) {
BIO_printf(bio_err, "warning: iv not use by this cipher\n");
- } else if (!set_hex(hiv, iv, siz
eof iv
)) {
+ } else if (!set_hex(hiv, iv, siz)) {
BIO_printf(bio_err, "invalid hex iv value\n");
goto end;
}
BIO_printf(bio_err, "invalid hex iv value\n");
goto end;
}
@@
-597,22
+601,23
@@
static void show_ciphers(const OBJ_NAME *name, void *arg)
BIO_printf(dec->bio, " ");
}
BIO_printf(dec->bio, " ");
}
-static int set_hex(char *in, unsigned char *out, int size)
+static int set_hex(c
onst c
har *in, unsigned char *out, int size)
{
int i, n;
unsigned char j;
{
int i, n;
unsigned char j;
+ i = size * 2;
n = strlen(in);
n = strlen(in);
- if (n > (size * 2)) {
- BIO_printf(bio_err, "hex string is too long\n");
- return 0;
+ if (n > i) {
+ BIO_printf(bio_err, "hex string is too long, ignoring excess\n");
+ n = i; /* ignore exceeding part */
+ } else if (n < i) {
+ BIO_printf(bio_err, "hex string is too short, padding with zero bytes to length\n");
}
}
+
memset(out, 0, size);
for (i = 0; i < n; i++) {
memset(out, 0, size);
for (i = 0; i < n; i++) {
- j = (unsigned char)*in;
- *(in++) = '\0';
- if (j == 0)
- break;
+ j = (unsigned char)*in++;
if (!isxdigit(j)) {
BIO_printf(bio_err, "non-hex digit\n");
return 0;
if (!isxdigit(j)) {
BIO_printf(bio_err, "non-hex digit\n");
return 0;