=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/enc.c,v retrieving revision 1.29 retrieving revision 1.30 diff -c -r1.29 -r1.30 *** src/usr.bin/openssl/enc.c 2023/06/11 11:54:44 1.29 --- src/usr.bin/openssl/enc.c 2023/06/11 12:06:08 1.30 *************** *** 1,4 **** ! /* $OpenBSD: enc.c,v 1.29 2023/06/11 11:54:44 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * --- 1,4 ---- ! /* $OpenBSD: enc.c,v 1.30 2023/06/11 12:06:08 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * *************** *** 391,399 **** } fclose(infile); i = strlen(buf); ! if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) buf[--i] = '\0'; ! if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) buf[--i] = '\0'; if (i < 1) { BIO_printf(bio_err, "zero length password\n"); --- 391,399 ---- } fclose(infile); i = strlen(buf); ! if (i > 0 && (buf[i - 1] == '\n' || buf[i - 1] == '\r')) buf[--i] = '\0'; ! if (i > 0 && (buf[i - 1] == '\n' || buf[i - 1] == '\r')) buf[--i] = '\0'; if (i < 1) { BIO_printf(bio_err, "zero length password\n"); *************** *** 421,429 **** cfg.md); goto end; } ! if (dgst == NULL) { dgst = EVP_sha256(); - } if (cfg.bufsize != NULL) { char *p = cfg.bufsize; --- 421,428 ---- cfg.md); goto end; } ! if (dgst == NULL) dgst = EVP_sha256(); if (cfg.bufsize != NULL) { char *p = cfg.bufsize; *************** *** 454,466 **** } strbuf = malloc(SIZE); buff = malloc(EVP_ENCODE_LENGTH(bsize)); ! if ((buff == NULL) || (strbuf == NULL)) { BIO_printf(bio_err, "malloc failure %ld\n", (long) EVP_ENCODE_LENGTH(bsize)); goto end; } in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); ! if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } --- 453,465 ---- } strbuf = malloc(SIZE); buff = malloc(EVP_ENCODE_LENGTH(bsize)); ! if (buff == NULL || strbuf == NULL) { BIO_printf(bio_err, "malloc failure %ld\n", (long) EVP_ENCODE_LENGTH(bsize)); goto end; } in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); ! if (in == NULL || out == NULL) { ERR_print_errors(bio_err); goto end; } *************** *** 482,496 **** } if (!cfg.keystr && cfg.passarg) { ! if (!app_passwd(bio_err, cfg.passarg, NULL, ! &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } cfg.keystr = pass; } ! if (cfg.keystr == NULL && cfg.cipher != NULL && ! cfg.hkey == NULL) { for (;;) { char buf[200]; int retval; --- 481,493 ---- } if (!cfg.keystr && cfg.passarg) { ! if (!app_passwd(bio_err, cfg.passarg, NULL, &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } cfg.keystr = pass; } ! if (cfg.keystr == NULL && cfg.cipher != NULL && cfg.hkey == NULL) { for (;;) { char buf[200]; int retval; *************** *** 640,647 **** explicit_bzero(cfg.keystr, strlen(cfg.keystr)); } ! if (cfg.hiv != NULL && ! !set_hex(cfg.hiv, iv, sizeof iv)) { BIO_printf(bio_err, "invalid hex iv value\n"); goto end; } --- 637,643 ---- explicit_bzero(cfg.keystr, strlen(cfg.keystr)); } ! if (cfg.hiv != NULL && !set_hex(cfg.hiv, iv, sizeof iv)) { BIO_printf(bio_err, "invalid hex iv value\n"); goto end; } *************** *** 655,662 **** BIO_printf(bio_err, "iv undefined\n"); goto end; } ! if (cfg.hkey != NULL && ! !set_hex(cfg.hkey, key, sizeof key)) { BIO_printf(bio_err, "invalid hex key value\n"); goto end; } --- 651,657 ---- BIO_printf(bio_err, "iv undefined\n"); goto end; } ! if (cfg.hkey != NULL && !set_hex(cfg.hkey, key, sizeof key)) { BIO_printf(bio_err, "invalid hex key value\n"); goto end; } *************** *** 680,687 **** if (cfg.nopad) EVP_CIPHER_CTX_set_padding(ctx, 0); ! if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, ! cfg.enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", EVP_CIPHER_name(cfg.cipher)); ERR_print_errors(bio_err); --- 675,681 ---- if (cfg.nopad) EVP_CIPHER_CTX_set_padding(ctx, 0); ! if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, cfg.enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", EVP_CIPHER_name(cfg.cipher)); ERR_print_errors(bio_err); *************** *** 772,782 **** *(in++) = '\0'; if (j == 0) break; ! if ((j >= '0') && (j <= '9')) j -= '0'; ! else if ((j >= 'A') && (j <= 'F')) j = j - 'A' + 10; ! else if ((j >= 'a') && (j <= 'f')) j = j - 'a' + 10; else { BIO_printf(bio_err, "non-hex digit\n"); --- 766,776 ---- *(in++) = '\0'; if (j == 0) break; ! if (j >= '0' && j <= '9') j -= '0'; ! else if (j >= 'A' && j <= 'F') j = j - 'A' + 10; ! else if (j >= 'a' && j <= 'f') j = j - 'a' + 10; else { BIO_printf(bio_err, "non-hex digit\n");