Lines Matching refs:req
619 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req);
829 static int php_openssl_add_oid_section(struct php_x509_request * req) /* {{{ */ in php_openssl_add_oid_section() argument
836 str = php_openssl_conf_get_string(req->req_config, NULL, "oid_section"); in php_openssl_add_oid_section()
840 sktmp = CONF_get_section(req->req_config, str); in php_openssl_add_oid_section()
859 #define PHP_SSL_REQ_INIT(req) memset(req, 0, sizeof(*req)) argument
860 #define PHP_SSL_REQ_DISPOSE(req) php_openssl_dispose_config(req) argument
861 #define PHP_SSL_REQ_PARSE(req, zval) php_openssl_parse_config(req, zval) argument
863 #define PHP_SSL_CONFIG_SYNTAX_CHECK(var) if (req->var && php_openssl_config_check_syntax(#var, \
864 req->config_filename, req->var, req->req_config) == FAILURE) return FAILURE
904 static int php_openssl_parse_config(struct php_x509_request * req, zval * optional_args) /* {{{ */ in php_openssl_parse_config() argument
909 SET_OPTIONAL_STRING_ARG("config", req->config_filename, default_ssl_conf_filename); in php_openssl_parse_config()
910 SET_OPTIONAL_STRING_ARG("config_section_name", req->section_name, "req"); in php_openssl_parse_config()
911 req->global_config = CONF_load(NULL, default_ssl_conf_filename, NULL); in php_openssl_parse_config()
912 if (req->global_config == NULL) { in php_openssl_parse_config()
915 req->req_config = CONF_load(NULL, req->config_filename, NULL); in php_openssl_parse_config()
916 if (req->req_config == NULL) { in php_openssl_parse_config()
922 str = php_openssl_conf_get_string(req->req_config, NULL, "oid_file"); in php_openssl_parse_config()
931 if (php_openssl_add_oid_section(req) == FAILURE) { in php_openssl_parse_config()
934 SET_OPTIONAL_STRING_ARG("digest_alg", req->digest_name, in php_openssl_parse_config()
935 php_openssl_conf_get_string(req->req_config, req->section_name, "default_md")); in php_openssl_parse_config()
936 SET_OPTIONAL_STRING_ARG("x509_extensions", req->extensions_section, in php_openssl_parse_config()
937 php_openssl_conf_get_string(req->req_config, req->section_name, "x509_extensions")); in php_openssl_parse_config()
938 SET_OPTIONAL_STRING_ARG("req_extensions", req->request_extensions_section, in php_openssl_parse_config()
939 php_openssl_conf_get_string(req->req_config, req->section_name, "req_extensions")); in php_openssl_parse_config()
940 SET_OPTIONAL_LONG_ARG("private_key_bits", req->priv_key_bits, in php_openssl_parse_config()
941 CONF_get_number(req->req_config, req->section_name, "default_bits")); in php_openssl_parse_config()
943 SET_OPTIONAL_LONG_ARG("private_key_type", req->priv_key_type, OPENSSL_KEYTYPE_DEFAULT); in php_openssl_parse_config()
946 req->priv_key_encrypt = Z_TYPE_P(item) == IS_TRUE ? 1 : 0; in php_openssl_parse_config()
948 str = php_openssl_conf_get_string(req->req_config, req->section_name, "encrypt_rsa_key"); in php_openssl_parse_config()
950 str = php_openssl_conf_get_string(req->req_config, req->section_name, "encrypt_key"); in php_openssl_parse_config()
953 req->priv_key_encrypt = 0; in php_openssl_parse_config()
955 req->priv_key_encrypt = 1; in php_openssl_parse_config()
959 if (req->priv_key_encrypt && in php_openssl_parse_config()
970 req->priv_key_encrypt_cipher = cipher; in php_openssl_parse_config()
973 req->priv_key_encrypt_cipher = NULL; in php_openssl_parse_config()
977 if (req->digest_name == NULL) { in php_openssl_parse_config()
978 req->digest_name = php_openssl_conf_get_string(req->req_config, req->section_name, "default_md"); in php_openssl_parse_config()
980 if (req->digest_name != NULL) { in php_openssl_parse_config()
981 req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name); in php_openssl_parse_config()
983 if (req->md_alg == NULL) { in php_openssl_parse_config()
984 req->md_alg = req->digest = EVP_sha1(); in php_openssl_parse_config()
991 req->curve_name = NID_undef; in php_openssl_parse_config()
994 req->curve_name = OBJ_sn2nid(Z_STRVAL_P(item)); in php_openssl_parse_config()
995 if (req->curve_name == NID_undef) { in php_openssl_parse_config()
1003 str = php_openssl_conf_get_string(req->req_config, req->section_name, "string_mask"); in php_openssl_parse_config()
1015 static void php_openssl_dispose_config(struct php_x509_request * req) /* {{{ */ in php_openssl_dispose_config() argument
1017 if (req->priv_key) { in php_openssl_dispose_config()
1018 EVP_PKEY_free(req->priv_key); in php_openssl_dispose_config()
1019 req->priv_key = NULL; in php_openssl_dispose_config()
1021 if (req->global_config) { in php_openssl_dispose_config()
1022 CONF_free(req->global_config); in php_openssl_dispose_config()
1023 req->global_config = NULL; in php_openssl_dispose_config()
1025 if (req->req_config) { in php_openssl_dispose_config()
1026 CONF_free(req->req_config); in php_openssl_dispose_config()
1027 req->req_config = NULL; in php_openssl_dispose_config()
2944 static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, zval * dn, zval * at… in php_openssl_make_REQ() argument
2949 dn_sect = CONF_get_string(req->req_config, req->section_name, "distinguished_name"); in php_openssl_make_REQ()
2954 dn_sk = CONF_get_section(req->req_config, dn_sect); in php_openssl_make_REQ()
2959 attr_sect = php_openssl_conf_get_string(req->req_config, req->section_name, "attributes"); in php_openssl_make_REQ()
2963 attr_sk = CONF_get_section(req->req_config, attr_sect); in php_openssl_make_REQ()
3104 if (!X509_REQ_set_pubkey(csr, req->priv_key)) { in php_openssl_make_REQ()
3274 struct php_x509_request req; in PHP_FUNCTION() local
3294 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3317 if (PHP_SSL_REQ_PARSE(&req, args) == FAILURE) { in PHP_FUNCTION()
3374 if (req.extensions_section) { in PHP_FUNCTION()
3378 X509V3_set_conf_lhash(&ctx, req.req_config); in PHP_FUNCTION()
3379 if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) { in PHP_FUNCTION()
3386 if (!X509_sign(new_cert, priv_key, req.digest)) { in PHP_FUNCTION()
3402 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3417 struct php_x509_request req; in PHP_FUNCTION() local
3428 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3430 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3437 req.priv_key = php_openssl_pkey_from_zval(out_pkey_val, 0, NULL, 0, 2); in PHP_FUNCTION()
3439 if (req.priv_key == NULL) { in PHP_FUNCTION()
3440 php_openssl_generate_private_key(&req); in PHP_FUNCTION()
3443 if (req.priv_key == NULL) { in PHP_FUNCTION()
3448 if (php_openssl_make_REQ(&req, csr, dn, attribs) == SUCCESS) { in PHP_FUNCTION()
3452 X509V3_set_conf_lhash(&ext_ctx, req.req_config); in PHP_FUNCTION()
3455 if (req.request_extensions_section && !X509V3_EXT_REQ_add_conf(req.req_config, in PHP_FUNCTION()
3456 &ext_ctx, req.request_extensions_section, csr)) in PHP_FUNCTION()
3459 …php_error_docref(NULL, E_WARNING, "Error loading extension section %s", req.request_extensions_sec… in PHP_FUNCTION()
3463 if (X509_REQ_sign(csr, req.priv_key, req.digest)) { in PHP_FUNCTION()
3479 key_object->pkey = req.priv_key; in PHP_FUNCTION()
3482 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3495 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3772 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req) in php_openssl_generate_private_key() argument
3778 if (req->priv_key_bits < MIN_KEY_LENGTH) { in php_openssl_generate_private_key()
3780 MIN_KEY_LENGTH, req->priv_key_bits); in php_openssl_generate_private_key()
3784 randfile = php_openssl_conf_get_string(req->req_config, req->section_name, "RANDFILE"); in php_openssl_generate_private_key()
3787 if ((req->priv_key = EVP_PKEY_new()) != NULL) { in php_openssl_generate_private_key()
3788 switch(req->priv_key_type) { in php_openssl_generate_private_key()
3795 rsaparam = (RSA*)RSA_generate_key(req->priv_key_bits, RSA_F4, NULL, NULL); in php_openssl_generate_private_key()
3806 if (rsaparam == NULL || !RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL)) { in php_openssl_generate_private_key()
3814 if (rsaparam && EVP_PKEY_assign_RSA(req->priv_key, rsaparam)) { in php_openssl_generate_private_key()
3815 return_val = req->priv_key; in php_openssl_generate_private_key()
3826 …if (dsaparam && DSA_generate_parameters_ex(dsaparam, req->priv_key_bits, NULL, 0, NULL, NULL, NULL… in php_openssl_generate_private_key()
3829 if (EVP_PKEY_assign_DSA(req->priv_key, dsaparam)) { in php_openssl_generate_private_key()
3830 return_val = req->priv_key; in php_openssl_generate_private_key()
3850 if (dhparam && DH_generate_parameters_ex(dhparam, req->priv_key_bits, 2, NULL)) { in php_openssl_generate_private_key()
3853 if (EVP_PKEY_assign_DH(req->priv_key, dhparam)) { in php_openssl_generate_private_key()
3854 return_val = req->priv_key; in php_openssl_generate_private_key()
3872 if (req->curve_name == NID_undef) { in php_openssl_generate_private_key()
3876 eckey = EC_KEY_new_by_curve_name(req->curve_name); in php_openssl_generate_private_key()
3880 EVP_PKEY_assign_EC_KEY(req->priv_key, eckey)) { in php_openssl_generate_private_key()
3881 return_val = req->priv_key; in php_openssl_generate_private_key()
3899 EVP_PKEY_free(req->priv_key); in php_openssl_generate_private_key()
3900 req->priv_key = NULL; in php_openssl_generate_private_key()
4161 struct php_x509_request req; in PHP_FUNCTION() local
4369 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
4371 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
4372 if (php_openssl_generate_private_key(&req)) { in PHP_FUNCTION()
4376 key_object->pkey = req.priv_key; in PHP_FUNCTION()
4378 req.priv_key = NULL; in PHP_FUNCTION()
4381 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
4388 struct php_x509_request req; in PHP_FUNCTION() local
4418 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
4420 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
4427 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
4428 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
4429 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
4462 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
4471 struct php_x509_request req; in PHP_FUNCTION() local
4494 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
4496 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
4499 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
4500 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
4501 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
4538 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()