mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
Add KEM dupctx test
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16495)
This commit is contained in:
parent
21a0d9f3ed
commit
d7b5f06ede
@ -525,7 +525,7 @@ static int kem_rsa_gen_recover(void)
|
||||
int ret = 0;
|
||||
EVP_PKEY *pub = NULL;
|
||||
EVP_PKEY *priv = NULL;
|
||||
EVP_PKEY_CTX *sctx = NULL, *rctx = NULL;
|
||||
EVP_PKEY_CTX *sctx = NULL, *rctx = NULL, *dctx = NULL;
|
||||
unsigned char secret[256] = { 0, };
|
||||
unsigned char ct[256] = { 0, };
|
||||
unsigned char unwrap[256] = { 0, };
|
||||
@ -536,11 +536,12 @@ static int kem_rsa_gen_recover(void)
|
||||
&& TEST_ptr(sctx = EVP_PKEY_CTX_new_from_pkey(libctx, pub, NULL))
|
||||
&& TEST_int_eq(EVP_PKEY_encapsulate_init(sctx, NULL), 1)
|
||||
&& TEST_int_eq(EVP_PKEY_CTX_set_kem_op(sctx, "RSASVE"), 1)
|
||||
&& TEST_int_eq(EVP_PKEY_encapsulate(sctx, NULL, &ctlen, NULL,
|
||||
&& TEST_ptr(dctx = EVP_PKEY_CTX_dup(sctx))
|
||||
&& TEST_int_eq(EVP_PKEY_encapsulate(dctx, NULL, &ctlen, NULL,
|
||||
&secretlen), 1)
|
||||
&& TEST_int_eq(ctlen, secretlen)
|
||||
&& TEST_int_eq(ctlen, bits / 8)
|
||||
&& TEST_int_eq(EVP_PKEY_encapsulate(sctx, ct, &ctlen, secret,
|
||||
&& TEST_int_eq(EVP_PKEY_encapsulate(dctx, ct, &ctlen, secret,
|
||||
&secretlen), 1)
|
||||
&& TEST_ptr(rctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL))
|
||||
&& TEST_int_eq(EVP_PKEY_decapsulate_init(rctx, NULL), 1)
|
||||
@ -553,6 +554,7 @@ static int kem_rsa_gen_recover(void)
|
||||
EVP_PKEY_free(pub);
|
||||
EVP_PKEY_free(priv);
|
||||
EVP_PKEY_CTX_free(rctx);
|
||||
EVP_PKEY_CTX_free(dctx);
|
||||
EVP_PKEY_CTX_free(sctx);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user