static int dh_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
{
+ DH *dh;
switch (op) {
case ASN1_PKEY_CTRL_SET1_TLS_ENCPT:
/* We should only be here if we have a legacy key */
if (!ossl_assert(evp_pkey_is_legacy(pkey)))
return 0;
- return ossl_dh_buf2key(evp_pkey_get0_DH_int(pkey), arg2, arg1);
+ dh = (DH *) evp_pkey_get0_DH_int(pkey);
+ if (dh == NULL)
+ return 0;
+ return ossl_dh_buf2key(dh, arg2, arg1);
case ASN1_PKEY_CTRL_GET1_TLS_ENCPT:
- return ossl_dh_key2buf(EVP_PKEY_get0_DH(pkey), arg2, 0, 1);
+ dh = (DH *) EVP_PKEY_get0_DH(pkey);
+ if (dh == NULL)
+ return 0;
+ return ossl_dh_key2buf(dh, arg2, 0, 1);
default:
return -2;
}
{
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (sig == NULL) {
*siglen = ED25519_SIGSIZE;
return 1;
{
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (sig == NULL) {
*siglen = ED448_SIGSIZE;
return 1;
{
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (siglen != ED25519_SIGSIZE)
return 0;
{
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (siglen != ED448_SIGSIZE)
return 0;
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
int rc;
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (sig == NULL) {
*siglen = ED25519_SIGSIZE;
return 1;
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
int rc;
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (sig == NULL) {
*siglen = ED448_SIGSIZE;
return 1;
} param;
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (siglen != ED25519_SIGSIZE)
return 0;
} param;
const ECX_KEY *edkey = evp_pkey_get_legacy(EVP_MD_CTX_get_pkey_ctx(ctx)->pkey);
+ if (edkey == NULL) {
+ ERR_raise(ERR_LIB_EC, EC_R_INVALID_KEY);
+ return 0;
+ }
+
if (siglen != ED448_SIGSIZE)
return 0;
EVP_PKEY *priv)
{
int ret = -1;
+ RSA *rsa = NULL;
if (EVP_PKEY_get_id(priv) != EVP_PKEY_RSA) {
ERR_raise(ERR_LIB_EVP, EVP_R_PUBLIC_KEY_NOT_RSA);
goto err;
}
+ rsa = evp_pkey_get0_RSA_int(priv);
+ if (rsa == NULL)
+ goto err;
+
ret =
- RSA_private_decrypt(ekl, ek, key, evp_pkey_get0_RSA_int(priv),
- RSA_PKCS1_PADDING);
+ RSA_private_decrypt(ekl, ek, key, rsa, RSA_PKCS1_PADDING);
err:
return ret;
}
int key_len, EVP_PKEY *pubk)
{
int ret = 0;
+ RSA *rsa = NULL;
if (EVP_PKEY_get_id(pubk) != EVP_PKEY_RSA) {
ERR_raise(ERR_LIB_EVP, EVP_R_PUBLIC_KEY_NOT_RSA);
goto err;
}
+ rsa = evp_pkey_get0_RSA_int(pubk);
+ if (rsa == NULL)
+ goto err;
+
ret =
- RSA_public_encrypt(key_len, key, ek, evp_pkey_get0_RSA_int(pubk),
- RSA_PKCS1_PADDING);
+ RSA_public_encrypt(key_len, key, ek, rsa, RSA_PKCS1_PADDING);
err:
return ret;
}