instance method
OpenSSL::PKey::EC#check_key
() -> true
key.check_key => true
ext/openssl/ossl_pkey_ec.c
View on GitHub ↗
static VALUE ossl_ec_key_check_key(VALUE self)
{
#ifdef HAVE_EVP_PKEY_CHECK
EVP_PKEY *pkey;
EVP_PKEY_CTX *pctx;
const EC_KEY *ec;
GetPKey(self, pkey);
GetEC(self, ec);
pctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL);
if (!pctx)
ossl_raise(ePKeyError, "EVP_PKEY_CTX_new");
if (EC_KEY_get0_private_key(ec) != NULL) {
if (EVP_PKEY_check(pctx) != 1) {
EVP_PKEY_CTX_free(pctx);
ossl_raise(ePKeyError, "EVP_PKEY_check");
}
}
else {
if (EVP_PKEY_public_check(pctx) != 1) {
EVP_PKEY_CTX_free(pctx);
ossl_raise(ePKeyError, "EVP_PKEY_public_check");
}
}
EVP_PKEY_CTX_free(pctx);
#else
EC_KEY *ec;
GetEC(self, ec);
if (EC_KEY_check_key(ec) != 1)
ossl_raise(ePKeyError, "EC_KEY_check_key");
#endif
return Qtrue;
}
Raises an exception if the key is invalid.
See also the man page EVP_PKEY_public_check(3).