version 1.29, 2023/06/11 11:54:44 |
version 1.30, 2023/06/11 12:06:08 |
|
|
} |
} |
fclose(infile); |
fclose(infile); |
i = strlen(buf); |
i = strlen(buf); |
if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) |
if (i > 0 && (buf[i - 1] == '\n' || buf[i - 1] == '\r')) |
buf[--i] = '\0'; |
buf[--i] = '\0'; |
if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) |
if (i > 0 && (buf[i - 1] == '\n' || buf[i - 1] == '\r')) |
buf[--i] = '\0'; |
buf[--i] = '\0'; |
if (i < 1) { |
if (i < 1) { |
BIO_printf(bio_err, "zero length password\n"); |
BIO_printf(bio_err, "zero length password\n"); |
|
|
cfg.md); |
cfg.md); |
goto end; |
goto end; |
} |
} |
if (dgst == NULL) { |
if (dgst == NULL) |
dgst = EVP_sha256(); |
dgst = EVP_sha256(); |
} |
|
|
|
if (cfg.bufsize != NULL) { |
if (cfg.bufsize != NULL) { |
char *p = cfg.bufsize; |
char *p = cfg.bufsize; |
|
|
} |
} |
strbuf = malloc(SIZE); |
strbuf = malloc(SIZE); |
buff = malloc(EVP_ENCODE_LENGTH(bsize)); |
buff = malloc(EVP_ENCODE_LENGTH(bsize)); |
if ((buff == NULL) || (strbuf == NULL)) { |
if (buff == NULL || strbuf == NULL) { |
BIO_printf(bio_err, "malloc failure %ld\n", (long) EVP_ENCODE_LENGTH(bsize)); |
BIO_printf(bio_err, "malloc failure %ld\n", (long) EVP_ENCODE_LENGTH(bsize)); |
goto end; |
goto end; |
} |
} |
in = BIO_new(BIO_s_file()); |
in = BIO_new(BIO_s_file()); |
out = BIO_new(BIO_s_file()); |
out = BIO_new(BIO_s_file()); |
if ((in == NULL) || (out == NULL)) { |
if (in == NULL || out == NULL) { |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
goto end; |
goto end; |
} |
} |
|
|
} |
} |
|
|
if (!cfg.keystr && cfg.passarg) { |
if (!cfg.keystr && cfg.passarg) { |
if (!app_passwd(bio_err, cfg.passarg, NULL, |
if (!app_passwd(bio_err, cfg.passarg, NULL, &pass, NULL)) { |
&pass, NULL)) { |
|
BIO_printf(bio_err, "Error getting password\n"); |
BIO_printf(bio_err, "Error getting password\n"); |
goto end; |
goto end; |
} |
} |
cfg.keystr = pass; |
cfg.keystr = pass; |
} |
} |
if (cfg.keystr == NULL && cfg.cipher != NULL && |
if (cfg.keystr == NULL && cfg.cipher != NULL && cfg.hkey == NULL) { |
cfg.hkey == NULL) { |
|
for (;;) { |
for (;;) { |
char buf[200]; |
char buf[200]; |
int retval; |
int retval; |
|
|
explicit_bzero(cfg.keystr, |
explicit_bzero(cfg.keystr, |
strlen(cfg.keystr)); |
strlen(cfg.keystr)); |
} |
} |
if (cfg.hiv != NULL && |
if (cfg.hiv != NULL && !set_hex(cfg.hiv, iv, sizeof iv)) { |
!set_hex(cfg.hiv, iv, sizeof iv)) { |
|
BIO_printf(bio_err, "invalid hex iv value\n"); |
BIO_printf(bio_err, "invalid hex iv value\n"); |
goto end; |
goto end; |
} |
} |
|
|
BIO_printf(bio_err, "iv undefined\n"); |
BIO_printf(bio_err, "iv undefined\n"); |
goto end; |
goto end; |
} |
} |
if (cfg.hkey != NULL && |
if (cfg.hkey != NULL && !set_hex(cfg.hkey, key, sizeof key)) { |
!set_hex(cfg.hkey, key, sizeof key)) { |
|
BIO_printf(bio_err, "invalid hex key value\n"); |
BIO_printf(bio_err, "invalid hex key value\n"); |
goto end; |
goto end; |
} |
} |
|
|
if (cfg.nopad) |
if (cfg.nopad) |
EVP_CIPHER_CTX_set_padding(ctx, 0); |
EVP_CIPHER_CTX_set_padding(ctx, 0); |
|
|
if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, |
if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, cfg.enc)) { |
cfg.enc)) { |
|
BIO_printf(bio_err, "Error setting cipher %s\n", |
BIO_printf(bio_err, "Error setting cipher %s\n", |
EVP_CIPHER_name(cfg.cipher)); |
EVP_CIPHER_name(cfg.cipher)); |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
|
|
*(in++) = '\0'; |
*(in++) = '\0'; |
if (j == 0) |
if (j == 0) |
break; |
break; |
if ((j >= '0') && (j <= '9')) |
if (j >= '0' && j <= '9') |
j -= '0'; |
j -= '0'; |
else if ((j >= 'A') && (j <= 'F')) |
else if (j >= 'A' && j <= 'F') |
j = j - 'A' + 10; |
j = j - 'A' + 10; |
else if ((j >= 'a') && (j <= 'f')) |
else if (j >= 'a' && j <= 'f') |
j = j - 'a' + 10; |
j = j - 'a' + 10; |
else { |
else { |
BIO_printf(bio_err, "non-hex digit\n"); |
BIO_printf(bio_err, "non-hex digit\n"); |