summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2024-12-20 20:05:29 +0000
committerschwarze <>2024-12-20 20:05:29 +0000
commitda25826c5f42d94ad45a4d01873ecfffa79a2a8c (patch)
treeac223576b2bc3306e4a017fb52725d751e2b3b4e /src
parent7c46ebaeccb994727790953a7fada0fd2e9bd324 (diff)
downloadopenbsd-da25826c5f42d94ad45a4d01873ecfffa79a2a8c.tar.gz
openbsd-da25826c5f42d94ad45a4d01873ecfffa79a2a8c.tar.bz2
openbsd-da25826c5f42d94ad45a4d01873ecfffa79a2a8c.zip
If EVP_CIPHER_CTX_ctrl(3) is called on EVP_chacha20_poly1305(3)
with an unsupported control command, return -1 rather than 0 to the caller to indicate the error because in general, these control hooks ought to return -1 for unsupported control commands and 0 for other errors, for example other invalid arguments. Not a big deal because this change does not change when operations succeed or fail, and because callers are unlikely to pass unsupported control commands in the first place. The only functional change is that if a calling program inspects the ERR(3) stack after this failure, it will now find the correct error code rather than nothing. Even that wasn't a huge problem because for most EVP_CIPHER control failures, getting no reason for the error is the usual situation. Then again, giving the reason when easily possible may occasionally be useful. OpenSSL also returns -1 in this case, so it also helps compatibility a tiny bit. Found while auditing the return values of all the EVP_CIPHER control hooks in our tree. This was the only fishy one i found. OK tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/e_chacha20poly1305.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/evp/e_chacha20poly1305.c b/src/lib/libcrypto/evp/e_chacha20poly1305.c
index 816a8aa218..d176569f90 100644
--- a/src/lib/libcrypto/evp/e_chacha20poly1305.c
+++ b/src/lib/libcrypto/evp/e_chacha20poly1305.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_chacha20poly1305.c,v 1.36 2024/05/22 14:02:08 tb Exp $ */ 1/* $OpenBSD: e_chacha20poly1305.c,v 1.37 2024/12/20 20:05:29 schwarze Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
@@ -592,7 +592,7 @@ chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
592 return 1; 592 return 1;
593 } 593 }
594 594
595 return 0; 595 return -1;
596} 596}
597 597
598static const EVP_CIPHER cipher_chacha20_poly1305 = { 598static const EVP_CIPHER cipher_chacha20_poly1305 = {