]> git.ipfire.org Git - thirdparty/openssl.git/commit
poly1305: prevent crash on final without a key
author007bsd <22483432+007bsd@users.noreply.github.com>
Tue, 26 May 2026 18:11:27 +0000 (21:11 +0300)
committerNorbert Pocs <norbertp@openssl.org>
Mon, 1 Jun 2026 07:34:47 +0000 (09:34 +0200)
commit07485b844a0689354c2c17163604860a82d281bb
treee9ed140bd56c5b6b29c483f549e2ac4f1f193d08
parentb084b6ebbf642f237c9f40d9b242aed90482bf20
poly1305: prevent crash on final without a key

EVP_MAC_init with a NULL key followed by EVP_MAC_final on a
Poly1305 context crashed with a NULL function-pointer dispatch
because poly1305_init accepted the no-key case as success, and
poly1305_final had no guard before dispatching through the
uninitialised Poly1305 state.

Add a key_set field to struct poly1305_data_st (matching
OCB/CCM/GCM), set it in poly1305_setkey, and refuse init and
final if no key has been installed.

Added a regression test asserting EVP_MAC_init with a NULL key
returns 0.

##### Checklist
- [ ] documentation is added or updated
- [x] tests are added or updated

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Jun  1 07:35:02 2026
(Merged from https://github.com/openssl/openssl/pull/31298)
providers/implementations/macs/poly1305_prov.c
test/evp_extra_test.c