EVP_PKEY_CHECK(3ossl)
π EVP_PKEY_CHECK(3ossl) π
okay bestie, sit DOWN, because today we're talking about key validation in OpenSSL β and this is the 3ossl manual page so you know it's the real deal. seven whole functions that check whether your keys and params are actually valid, not just β¨vibingβ¨ and hoping for the best. let's get into it π«Ά
πΈ SYNOPSIS πΈ
#include <openssl/evp.h>
int EVP_PKEY_check(EVP_PKEY_CTX *ctx);
int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
int EVP_PKEY_param_check_quick(EVP_PKEY_CTX *ctx);
int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);
int EVP_PKEY_public_check_quick(EVP_PKEY_CTX *ctx);
int EVP_PKEY_private_check(EVP_PKEY_CTX *ctx);
int EVP_PKEY_pairwise_check(EVP_PKEY_CTX *ctx);
β¨ DESCRIPTION β¨
okay so every single one of these takes an EVP_PKEY_CTX *ctx and vibes off it. here's the breakdown, one function at a time, no skipping π
EVP_PKEY_param_check()β validates the parameters component of the key thatctxis holding. and here's the tea: for key types that don't even have parameters, this check will always succeed. free win, we love that for you πEVP_PKEY_param_check_quick()β does the same thing asEVP_PKEY_param_check(), validating the parameters component of the key given byctx. BUT. some algorithm implementations may offer a quicker form of validation that omits some checks in order to do a lightweight sanity check of the key. and if a quicker form isn't provided? then this call just does the exact same thing asEVP_PKEY_param_check(). no cap.EVP_PKEY_public_check()β validates the public component of the key given byctx. that's it, that's the function π¦EVP_PKEY_public_check_quick()β same deal asEVP_PKEY_public_check(), validating the public component of the key given byctx. but again, some algorithm implementations may offer a quicker form of validation that omits some checks for a lightweight sanity check. and if there's no quicker form available, this function call does the same thing asEVP_PKEY_public_check(). iconic behavior honestly.EVP_PKEY_private_check()β validates the private component of the key given byctx. keep that one secret bestie πEVP_PKEY_pairwise_check()β validates that the public and private components have the correct mathematical relationship to each other, for the key given byctx. it's giving "are these two actually a matched set or are they lying to me" energy πEVP_PKEY_check()β plot twist: this is literally just an alias for theEVP_PKEY_pairwise_check()function. same function, different name, main character energy β
π NOTES π
Key validation used by the OpenSSL FIPS provider complies with the rules within SP800-56A and SP800-56B. but for backwards compatibility reasons, the OpenSSL default provider may use checks that are not as restrictive for certain key types. π for further info, go read "DSA key validation" in EVP_PKEY-DSA(7), "DH key validation" in EVP_PKEY-DH(7), "EC key validation" in EVP_PKEY-EC(7) and "RSA key validation" in EVP_PKEY-RSA(7).
Refer to SP800-56A and SP800-56B for the rules about when these functions should be called during key establishment. and here's the practical bit: it is not necessary to call these functions after locally calling an approved key generation method β but it may be required for assurance purposes when you're receiving keys from a third party. so like, trust but verify, yk? π§
β οΈ ok important warning time:EVP_PKEY_pairwise_check()andEVP_PKEY_private_check()might not be bounded by any key size limits, because private keys are not expected to be supplied by attackers. for that reason, they might take an unbounded time if you run them on arbitrarily large keys. π so don't be out here feeding them chaos keys and then wondering why you're waiting forever.
π RETURN VALUES π
all of these functions return 1 for success, or others for failure. and specifically, they return -2 if the operation is not supported for the specific algorithm. that's the whole vibe check, right there.
π SEE ALSO π
EVP_PKEY_CTX_new(3), EVP_PKEY_fromdata(3), EVP_PKEY-DH(7), EVP_PKEY-FFC(7), EVP_PKEY-DSA(7), EVP_PKEY-EC(7), EVP_PKEY-RSA(7),
β HISTORY β
EVP_PKEY_check(),EVP_PKEY_public_check()andEVP_PKEY_param_check()were added in OpenSSL 1.1.1.EVP_PKEY_param_check_quick(),EVP_PKEY_public_check_quick(),EVP_PKEY_private_check()andEVP_PKEY_pairwise_check()were added in OpenSSL 3.0.
so like, the quicks are the new kids on the block, and they ate π₯
π COPYRIGHT π
Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page bestie π
this was 3.5.9, dated 2026-09-29, and it's the EVP_PKEY_CHECK(3ossl) manual β go forth and validate your keys, periodt. π¦β¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms