From: tb Date: Fri, 15 Dec 2023 13:28:30 +0000 (+0000) Subject: Move EVP_Cipher() from evp_lib.c to evp_enc.c X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0dfd48690b2782a97b4f1f7262d7c148deb79271;p=openbsd Move EVP_Cipher() from evp_lib.c to evp_enc.c EVP_Cipher() is a dangerous thin wrapper of the do_cipher() method set on the EVP_CIPHER_CTX's cipher. It implements (part of) the update and final step of the EVP_Cipher* API. Its behavior is nuts and will be documented in a comment in a subsequent commit. schwarze has a manpage diff that will fix the incorrect documentation. --- diff --git a/lib/libcrypto/evp/evp_enc.c b/lib/libcrypto/evp/evp_enc.c index 7c3f8c86489..4c00b0ee0ac 100644 --- a/lib/libcrypto/evp/evp_enc.c +++ b/lib/libcrypto/evp/evp_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_enc.c,v 1.58 2023/12/03 11:18:30 tb Exp $ */ +/* $OpenBSD: evp_enc.c,v 1.59 2023/12/15 13:28:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -246,6 +246,13 @@ EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0); } +int +EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, + unsigned int inl) +{ + return ctx->cipher->do_cipher(ctx, out, in, inl); +} + int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) diff --git a/lib/libcrypto/evp/evp_lib.c b/lib/libcrypto/evp/evp_lib.c index 55573b21db5..622d40dbdff 100644 --- a/lib/libcrypto/evp/evp_lib.c +++ b/lib/libcrypto/evp/evp_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_lib.c,v 1.29 2023/11/18 09:37:15 tb Exp $ */ +/* $OpenBSD: evp_lib.c,v 1.30 2023/12/15 13:28:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -197,13 +197,6 @@ EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) return ctx->cipher->block_size; } -int -EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, - unsigned int inl) -{ - return ctx->cipher->do_cipher(ctx, out, in, inl); -} - const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) {