Lines Matching refs:pkey
229 EVP_PKEY *pkey; member
253 static void php_openssl_pkey_object_init(zval *zv, EVP_PKEY *pkey, bool is_private) { in php_openssl_pkey_object_init() argument
256 obj->pkey = pkey; in php_openssl_pkey_object_init()
269 EVP_PKEY_free(key_object->pkey); in php_openssl_pkey_free_obj()
310 #define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa in ZEND_GET_MODULE()
311 #define EVP_PKEY_get0_DH(_pkey) _pkey->pkey.dh in ZEND_GET_MODULE()
312 #define EVP_PKEY_get0_DSA(_pkey) _pkey->pkey.dsa in ZEND_GET_MODULE()
313 #define EVP_PKEY_get0_EC_KEY(_pkey) _pkey->pkey.ec in ZEND_GET_MODULE()
426 static int EVP_PKEY_up_ref(EVP_PKEY *pkey) in EVP_PKEY_up_ref() argument
428 return CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY); in EVP_PKEY_up_ref()
1605 EVP_PKEY *pkey = NULL; in PHP_FUNCTION() local
1616 pkey = php_openssl_pkey_from_zval(zpkey, 0, challenge, challenge_len, 1); in PHP_FUNCTION()
1617 if (pkey == NULL) { in PHP_FUNCTION()
1645 if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) { in PHP_FUNCTION()
1651 if (!NETSCAPE_SPKI_sign(spki, pkey, mdtype)) { in PHP_FUNCTION()
1671 EVP_PKEY_free(pkey); in PHP_FUNCTION()
1689 EVP_PKEY *pkey = NULL; in PHP_FUNCTION() local
1712 pkey = X509_PUBKEY_get(spki->spkac->pubkey); in PHP_FUNCTION()
1713 if (pkey == NULL) { in PHP_FUNCTION()
1719 i = NETSCAPE_SPKI_verify(spki, pkey); in PHP_FUNCTION()
1726 EVP_PKEY_free(pkey); in PHP_FUNCTION()
1746 EVP_PKEY *pkey = NULL; in PHP_FUNCTION() local
1770 pkey = X509_PUBKEY_get(spki->spkac->pubkey); in PHP_FUNCTION()
1771 if (pkey == NULL) { in PHP_FUNCTION()
1778 if (out && PEM_write_bio_PUBKEY(out, pkey)) { in PHP_FUNCTION()
1794 EVP_PKEY_free(pkey); in PHP_FUNCTION()
2797 EVP_PKEY * pkey = NULL; in PHP_FUNCTION() local
2818 if (d2i_PKCS12_bio(bio_in, &p12) && PKCS12_parse(p12, pass, &pkey, &cert, &ca)) { in PHP_FUNCTION()
2840 if (pkey) { in PHP_FUNCTION()
2842 if (PEM_write_bio_PrivateKey(bio_out, pkey, NULL, NULL, 0, 0, NULL)) { in PHP_FUNCTION()
2885 EVP_PKEY_free(pkey); in PHP_FUNCTION()
3651 key = obj->pkey; in php_openssl_pkey_from_zval()
3973 EVP_PKEY *pkey = NULL; in php_openssl_pkey_init_rsa() local
4018 EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, params) <= 0) { in php_openssl_pkey_init_rsa()
4035 return pkey; in php_openssl_pkey_init_rsa()
4037 EVP_PKEY *pkey = EVP_PKEY_new(); in php_openssl_pkey_init_rsa()
4038 if (!pkey) { in php_openssl_pkey_init_rsa()
4046 EVP_PKEY_free(pkey); in php_openssl_pkey_init_rsa()
4051 || !EVP_PKEY_assign_RSA(pkey, rsa)) { in php_openssl_pkey_init_rsa()
4053 EVP_PKEY_free(pkey); in php_openssl_pkey_init_rsa()
4058 return pkey; in php_openssl_pkey_init_rsa()
4105 EVP_PKEY *param_key = NULL, *pkey = NULL; in php_openssl_pkey_init_dsa() local
4146 pkey = param_key; in php_openssl_pkey_init_dsa()
4152 if (EVP_PKEY_keygen_init(ctx) <= 0 || EVP_PKEY_keygen(ctx, &pkey) <= 0) { in php_openssl_pkey_init_dsa()
4168 return pkey; in php_openssl_pkey_init_dsa()
4170 EVP_PKEY *pkey = EVP_PKEY_new(); in php_openssl_pkey_init_dsa()
4171 if (!pkey) { in php_openssl_pkey_init_dsa()
4179 EVP_PKEY_free(pkey); in php_openssl_pkey_init_dsa()
4184 || !EVP_PKEY_assign_DSA(pkey, dsa)) { in php_openssl_pkey_init_dsa()
4186 EVP_PKEY_free(pkey); in php_openssl_pkey_init_dsa()
4191 return pkey; in php_openssl_pkey_init_dsa()
4278 EVP_PKEY *param_key = NULL, *pkey = NULL; in php_openssl_pkey_init_dh() local
4326 pkey = param_key; in php_openssl_pkey_init_dh()
4332 if (EVP_PKEY_keygen_init(ctx) <= 0 || EVP_PKEY_keygen(ctx, &pkey) <= 0) { in php_openssl_pkey_init_dh()
4348 return pkey; in php_openssl_pkey_init_dh()
4350 EVP_PKEY *pkey = EVP_PKEY_new(); in php_openssl_pkey_init_dh()
4351 if (!pkey) { in php_openssl_pkey_init_dh()
4358 EVP_PKEY_free(pkey); in php_openssl_pkey_init_dh()
4363 || !EVP_PKEY_assign_DH(pkey, dh)) { in php_openssl_pkey_init_dh()
4365 EVP_PKEY_free(pkey); in php_openssl_pkey_init_dh()
4370 return pkey; in php_openssl_pkey_init_dh()
4531 EVP_PKEY *param_key = NULL, *pkey = NULL; in php_openssl_pkey_init_ec() local
4684 pkey = param_key; in php_openssl_pkey_init_ec()
4690 EVP_PKEY_generate(ctx, &pkey) != 1) { in php_openssl_pkey_init_ec()
4717 return pkey; in php_openssl_pkey_init_ec()
4719 EVP_PKEY *pkey = EVP_PKEY_new(); in php_openssl_pkey_init_ec()
4720 if (!pkey) { in php_openssl_pkey_init_ec()
4727 EVP_PKEY_free(pkey); in php_openssl_pkey_init_ec()
4732 || !EVP_PKEY_assign_EC_KEY(pkey, ec)) { in php_openssl_pkey_init_ec()
4734 EVP_PKEY_free(pkey); in php_openssl_pkey_init_ec()
4739 return pkey; in php_openssl_pkey_init_ec()
4746 EVP_PKEY *pkey = NULL; in php_openssl_pkey_object_curve_25519_448() local
4780 EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, params) <= 0) { in php_openssl_pkey_object_curve_25519_448()
4787 if (EVP_PKEY_keygen_init(ctx) <= 0 || EVP_PKEY_keygen(ctx, &pkey) <= 0) { in php_openssl_pkey_object_curve_25519_448()
4792 if (pkey) { in php_openssl_pkey_object_curve_25519_448()
4793 php_openssl_pkey_object_init(return_value, pkey, is_private); in php_openssl_pkey_object_curve_25519_448()
4817 EVP_PKEY *pkey; in PHP_FUNCTION() local
4821 pkey = php_openssl_pkey_init_rsa(data); in PHP_FUNCTION()
4822 if (!pkey) { in PHP_FUNCTION()
4825 php_openssl_pkey_object_init(return_value, pkey, /* is_private */ true); in PHP_FUNCTION()
4830 pkey = php_openssl_pkey_init_dsa(data, &is_private); in PHP_FUNCTION()
4831 if (!pkey) { in PHP_FUNCTION()
4834 php_openssl_pkey_object_init(return_value, pkey, is_private); in PHP_FUNCTION()
4839 pkey = php_openssl_pkey_init_dh(data, &is_private); in PHP_FUNCTION()
4840 if (!pkey) { in PHP_FUNCTION()
4843 php_openssl_pkey_object_init(return_value, pkey, is_private); in PHP_FUNCTION()
4849 pkey = php_openssl_pkey_init_ec(data, &is_private); in PHP_FUNCTION()
4850 if (!pkey) { in PHP_FUNCTION()
4853 php_openssl_pkey_object_init(return_value, pkey, is_private); in PHP_FUNCTION()
5031 EVP_PKEY *pkey; in PHP_FUNCTION() local
5036 pkey = php_openssl_pkey_from_zval(cert, 1, NULL, 0, 1); in PHP_FUNCTION()
5037 if (pkey == NULL) { in PHP_FUNCTION()
5041 php_openssl_pkey_object_init(return_value, pkey, /* is_private */ false); in PHP_FUNCTION()
5060 EVP_PKEY *pkey; in PHP_FUNCTION() local
5072 pkey = php_openssl_pkey_from_zval(cert, 0, passphrase, passphrase_len, 1); in PHP_FUNCTION()
5073 if (pkey == NULL) { in PHP_FUNCTION()
5077 php_openssl_pkey_object_init(return_value, pkey, /* is_private */ true); in PHP_FUNCTION()
5084 zval *ary, EVP_PKEY *pkey, const char *param, const char *name) { in php_openssl_copy_bn_param() argument
5086 if (EVP_PKEY_get_bn_param(pkey, param, &bn) > 0) { in php_openssl_copy_bn_param()
5094 EVP_PKEY *pkey, const char *param, const char *name) { in php_openssl_get_utf8_param() argument
5097 if (EVP_PKEY_get_utf8_string_param(pkey, param, buf, sizeof(buf), &len) > 0) { in php_openssl_get_utf8_param()
5108 zval *ary, EVP_PKEY *pkey, const char *param, const char *name) { in php_openssl_copy_octet_string_param() argument
5111 if (EVP_PKEY_get_octet_string_param(pkey, param, buf, sizeof(buf), &len) > 0) { in php_openssl_copy_octet_string_param()
5120 zval *return_value, const char *assoc_name, EVP_PKEY *pkey) { in php_openssl_copy_curve_25519_448_params() argument
5124 php_openssl_copy_octet_string_param(&ary, pkey, OSSL_PKEY_PARAM_PRIV_KEY, "priv_key"); in php_openssl_copy_curve_25519_448_params()
5125 php_openssl_copy_octet_string_param(&ary, pkey, OSSL_PKEY_PARAM_PUB_KEY, "pub_key"); in php_openssl_copy_curve_25519_448_params()
5141 EVP_PKEY *pkey = Z_OPENSSL_PKEY_P(key)->pkey; in PHP_FUNCTION() local
5144 if (!PEM_write_bio_PUBKEY(out, pkey)) { in PHP_FUNCTION()
5152 add_assoc_long(return_value, "bits", EVP_PKEY_bits(pkey)); in PHP_FUNCTION()
5161 if (EVP_PKEY_id(pkey) != EVP_PKEY_KEYMGMT) { in PHP_FUNCTION()
5162 base_id = EVP_PKEY_base_id(pkey); in PHP_FUNCTION()
5164 const char *type_name = EVP_PKEY_get0_type_name(pkey); in PHP_FUNCTION()
5178 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_N, "n"); in PHP_FUNCTION()
5179 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_E, "e"); in PHP_FUNCTION()
5180 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_D, "d"); in PHP_FUNCTION()
5181 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_FACTOR1, "p"); in PHP_FUNCTION()
5182 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_FACTOR2, "q"); in PHP_FUNCTION()
5183 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_EXPONENT1, "dmp1"); in PHP_FUNCTION()
5184 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_EXPONENT2, "dmq1"); in PHP_FUNCTION()
5185 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_RSA_COEFFICIENT1, "iqmp"); in PHP_FUNCTION()
5191 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_FFC_P, "p"); in PHP_FUNCTION()
5192 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_FFC_Q, "q"); in PHP_FUNCTION()
5193 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_FFC_G, "g"); in PHP_FUNCTION()
5194 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_PRIV_KEY, "priv_key"); in PHP_FUNCTION()
5195 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_PUB_KEY, "pub_key"); in PHP_FUNCTION()
5201 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_FFC_P, "p"); in PHP_FUNCTION()
5202 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_FFC_G, "g"); in PHP_FUNCTION()
5203 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_PRIV_KEY, "priv_key"); in PHP_FUNCTION()
5204 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_PUB_KEY, "pub_key"); in PHP_FUNCTION()
5213 pkey, OSSL_PKEY_PARAM_GROUP_NAME, "curve_name"); in PHP_FUNCTION()
5230 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_EC_PUB_X, "x"); in PHP_FUNCTION()
5231 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_EC_PUB_Y, "y"); in PHP_FUNCTION()
5232 php_openssl_copy_bn_param(&ary, pkey, OSSL_PKEY_PARAM_PRIV_KEY, "d"); in PHP_FUNCTION()
5239 php_openssl_copy_curve_25519_448_params(return_value, "x25519", pkey); in PHP_FUNCTION()
5244 php_openssl_copy_curve_25519_448_params(return_value, "ed25519", pkey); in PHP_FUNCTION()
5249 php_openssl_copy_curve_25519_448_params(return_value, "x448", pkey); in PHP_FUNCTION()
5254 php_openssl_copy_curve_25519_448_params(return_value, "ed448", pkey); in PHP_FUNCTION()
5263 switch (EVP_PKEY_base_id(pkey)) { in PHP_FUNCTION()
5267 RSA *rsa = EVP_PKEY_get0_RSA(pkey); in PHP_FUNCTION()
5296 DSA *dsa = EVP_PKEY_get0_DSA(pkey); in PHP_FUNCTION()
5318 DH *dh = EVP_PKEY_get0_DH(pkey); in PHP_FUNCTION()
5340 if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { in PHP_FUNCTION()
5349 const EC_KEY *ec_key = EVP_PKEY_get0_EC_KEY(pkey); in PHP_FUNCTION()
5383 if ((d = EC_KEY_get0_private_key(EVP_PKEY_get0_EC_KEY(pkey))) != NULL) { in PHP_FUNCTION()
5433 static zend_string *php_openssl_dh_compute_key(EVP_PKEY *pkey, char *pub_str, size_t pub_len) { in php_openssl_dh_compute_key() argument
5436 if (!peer_key || EVP_PKEY_copy_parameters(peer_key, pkey) <= 0 || in php_openssl_dh_compute_key()
5443 zend_string *result = php_openssl_pkey_derive(pkey, peer_key, 0); in php_openssl_dh_compute_key()
5447 DH *dh = EVP_PKEY_get0_DH(pkey); in php_openssl_dh_compute_key()
5482 EVP_PKEY *pkey = Z_OPENSSL_PKEY_P(key)->pkey; in PHP_FUNCTION() local
5483 if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH) { in PHP_FUNCTION()
5487 zend_string *result = php_openssl_dh_compute_key(pkey, pub_str, pub_len); in PHP_FUNCTION()
5512 EVP_PKEY *pkey = php_openssl_pkey_from_zval(priv_key, 0, "", 0, 2); in PHP_FUNCTION() local
5513 if (!pkey) { in PHP_FUNCTION()
5519 EVP_PKEY_free(pkey); in PHP_FUNCTION()
5523 zend_string *result = php_openssl_pkey_derive(pkey, peer_key, key_len); in PHP_FUNCTION()
5524 EVP_PKEY_free(pkey); in PHP_FUNCTION()
6915 EVP_PKEY *pkey = php_openssl_pkey_from_zval(key, 0, "", 0, 3); in PHP_FUNCTION() local
6916 if (pkey == NULL) { in PHP_FUNCTION()
6924 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
6948 EVP_PKEY_free(pkey); in PHP_FUNCTION()
6964 EVP_PKEY *pkey = php_openssl_pkey_from_zval(key, 0, "", 0, 3); in PHP_FUNCTION() local
6965 if (pkey == NULL) { in PHP_FUNCTION()
6973 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
6998 EVP_PKEY_free(pkey); in PHP_FUNCTION()
7014 EVP_PKEY *pkey = php_openssl_pkey_from_zval(key, 1, NULL, 0, 3); in PHP_FUNCTION() local
7015 if (pkey == NULL) { in PHP_FUNCTION()
7023 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
7047 EVP_PKEY_free(pkey); in PHP_FUNCTION()
7063 EVP_PKEY *pkey = php_openssl_pkey_from_zval(key, 1, NULL, 0, 3); in PHP_FUNCTION() local
7064 if (pkey == NULL) { in PHP_FUNCTION()
7072 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
7097 EVP_PKEY_free(pkey); in PHP_FUNCTION()
7133 EVP_PKEY *pkey; local
7151 pkey = php_openssl_pkey_from_zval(key, 0, "", 0, 3);
7152 if (pkey == NULL) {
7173 EVP_DigestSignInit(md_ctx, NULL, mdtype, NULL, pkey) &&
7181 (siglen = EVP_PKEY_size(pkey)) &&
7183 EVP_SignFinal(md_ctx, (unsigned char*)ZSTR_VAL(sigbuf), (unsigned int*)&siglen, pkey)) {
7195 EVP_PKEY_free(pkey);
7203 EVP_PKEY *pkey; local
7235 pkey = php_openssl_pkey_from_zval(key, 1, NULL, 0, 3);
7236 if (pkey == NULL) {
7246 !EVP_DigestVerifyInit(md_ctx, NULL, mdtype, NULL, pkey) ||
7251 …(err = EVP_VerifyFinal(md_ctx, (unsigned char *)signature, (unsigned int)signature_len, pkey)) < 0…
7256 EVP_PKEY_free(pkey);
7391 EVP_PKEY *pkey; local
7410 pkey = php_openssl_pkey_from_zval(privkey, 0, "", 0, 4);
7412 if (pkey == NULL) {
7443 if (ctx != NULL && EVP_OpenInit(ctx, cipher, (unsigned char *)ekey, (int)ekey_len, iv_buf, pkey) &&
7455 EVP_PKEY_free(pkey);