Add tests to verify that `EVP_MD_CTX_serialize` and
`EVP_MD_CTX_deserialize` fail when called on a finalized `EVP_MD_CTX`.
A finalized context is in a terminal state and should not be serializable for
resumption or have a new state deserialized into it. These tests confirm the
expected failure behavior.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28837)
EVP_MD *md = NULL;
unsigned char *buf = NULL;
size_t buflen;
+ size_t tmplen;
unsigned char d1[EVP_MAX_MD_SIZE], d2[EVP_MAX_MD_SIZE];
unsigned int d1_len, d2_len;
int ret = 0;
|| !TEST_mem_eq(d1, d1_len, d2, d2_len))
goto end;
+ /* Check that serialization fails on finalized contexts */
+ if (!TEST_false(EVP_MD_CTX_serialize(mdctx1, NULL, &tmplen))
+ || !TEST_false(EVP_MD_CTX_deserialize(mdctx1, buf, buflen)))
+ goto end;
+
ret = 1;
end: