Lines Matching refs:req

577 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req TSRMLS_DC);
762 static int add_oid_section(struct php_x509_request * req TSRMLS_DC) /* {{{ */ in add_oid_section()
769 str = CONF_get_string(req->req_config, NULL, "oid_section"); in add_oid_section()
773 sktmp = CONF_get_section(req->req_config, str); in add_oid_section()
789 #define PHP_SSL_REQ_INIT(req) memset(req, 0, sizeof(*req)) argument
790 #define PHP_SSL_REQ_DISPOSE(req) php_openssl_dispose_config(req TSRMLS_CC) argument
791 #define PHP_SSL_REQ_PARSE(req, zval) php_openssl_parse_config(req, zval TSRMLS_CC) argument
793 #define PHP_SSL_CONFIG_SYNTAX_CHECK(var) if (req->var && php_openssl_config_check_syntax(#var, \
794 req->config_filename, req->var, req->req_config TSRMLS_CC) == FAILURE) return FAILURE
811 static int php_openssl_parse_config(struct php_x509_request * req, zval * optional_args TSRMLS_DC) … in php_openssl_parse_config() argument
816 SET_OPTIONAL_STRING_ARG("config", req->config_filename, default_ssl_conf_filename); in php_openssl_parse_config()
817 SET_OPTIONAL_STRING_ARG("config_section_name", req->section_name, "req"); in php_openssl_parse_config()
818 req->global_config = CONF_load(NULL, default_ssl_conf_filename, NULL); in php_openssl_parse_config()
819 req->req_config = CONF_load(NULL, req->config_filename, NULL); in php_openssl_parse_config()
821 if (req->req_config == NULL) { in php_openssl_parse_config()
826 str = CONF_get_string(req->req_config, NULL, "oid_file"); in php_openssl_parse_config()
834 if (add_oid_section(req TSRMLS_CC) == FAILURE) { in php_openssl_parse_config()
837 SET_OPTIONAL_STRING_ARG("digest_alg", req->digest_name, in php_openssl_parse_config()
838 CONF_get_string(req->req_config, req->section_name, "default_md")); in php_openssl_parse_config()
839 SET_OPTIONAL_STRING_ARG("x509_extensions", req->extensions_section, in php_openssl_parse_config()
840 CONF_get_string(req->req_config, req->section_name, "x509_extensions")); in php_openssl_parse_config()
841 SET_OPTIONAL_STRING_ARG("req_extensions", req->request_extensions_section, in php_openssl_parse_config()
842 CONF_get_string(req->req_config, req->section_name, "req_extensions")); in php_openssl_parse_config()
843 SET_OPTIONAL_LONG_ARG("private_key_bits", req->priv_key_bits, in php_openssl_parse_config()
844 CONF_get_number(req->req_config, req->section_name, "default_bits")); in php_openssl_parse_config()
846 SET_OPTIONAL_LONG_ARG("private_key_type", req->priv_key_type, OPENSSL_KEYTYPE_DEFAULT); in php_openssl_parse_config()
849 req->priv_key_encrypt = Z_BVAL_PP(item); in php_openssl_parse_config()
851 str = CONF_get_string(req->req_config, req->section_name, "encrypt_rsa_key"); in php_openssl_parse_config()
853 str = CONF_get_string(req->req_config, req->section_name, "encrypt_key"); in php_openssl_parse_config()
856 req->priv_key_encrypt = 0; in php_openssl_parse_config()
858 req->priv_key_encrypt = 1; in php_openssl_parse_config()
862 …if (req->priv_key_encrypt && optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), "encrypt_k… in php_openssl_parse_config()
870 req->priv_key_encrypt_cipher = cipher; in php_openssl_parse_config()
873 req->priv_key_encrypt_cipher = NULL; in php_openssl_parse_config()
879 if (req->digest_name == NULL) { in php_openssl_parse_config()
880 req->digest_name = CONF_get_string(req->req_config, req->section_name, "default_md"); in php_openssl_parse_config()
882 if (req->digest_name) { in php_openssl_parse_config()
883 req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name); in php_openssl_parse_config()
885 if (req->md_alg == NULL) { in php_openssl_parse_config()
886 req->md_alg = req->digest = EVP_sha1(); in php_openssl_parse_config()
892 str = CONF_get_string(req->req_config, req->section_name, "string_mask"); in php_openssl_parse_config()
904 static void php_openssl_dispose_config(struct php_x509_request * req TSRMLS_DC) /* {{{ */ in php_openssl_dispose_config()
906 if (req->priv_key) { in php_openssl_dispose_config()
907 EVP_PKEY_free(req->priv_key); in php_openssl_dispose_config()
908 req->priv_key = NULL; in php_openssl_dispose_config()
910 if (req->global_config) { in php_openssl_dispose_config()
911 CONF_free(req->global_config); in php_openssl_dispose_config()
912 req->global_config = NULL; in php_openssl_dispose_config()
914 if (req->req_config) { in php_openssl_dispose_config()
915 CONF_free(req->req_config); in php_openssl_dispose_config()
916 req->req_config = NULL; in php_openssl_dispose_config()
2195 static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, zval * dn, zval * at… in php_openssl_make_REQ() argument
2200 dn_sect = CONF_get_string(req->req_config, req->section_name, "distinguished_name"); in php_openssl_make_REQ()
2204 dn_sk = CONF_get_section(req->req_config, dn_sect); in php_openssl_make_REQ()
2208 attr_sect = CONF_get_string(req->req_config, req->section_name, "attributes"); in php_openssl_make_REQ()
2212 attr_sk = CONF_get_section(req->req_config, attr_sect); in php_openssl_make_REQ()
2352 X509_REQ_set_pubkey(csr, req->priv_key); in php_openssl_make_REQ()
2503 struct php_x509_request req; in PHP_FUNCTION() local
2509 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
2533 if (PHP_SSL_REQ_PARSE(&req, args) == FAILURE) { in PHP_FUNCTION()
2580 if (req.extensions_section) { in PHP_FUNCTION()
2584 X509V3_set_conf_lhash(&ctx, req.req_config); in PHP_FUNCTION()
2585 if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) { in PHP_FUNCTION()
2591 if (!X509_sign(new_cert, priv_key, req.digest)) { in PHP_FUNCTION()
2605 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
2629 struct php_x509_request req; in PHP_FUNCTION() local
2641 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
2643 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
2646 req.priv_key = php_openssl_evp_from_zval(&out_pkey, 0, NULL, 0, &key_resource TSRMLS_CC); in PHP_FUNCTION()
2647 if (req.priv_key != NULL) { in PHP_FUNCTION()
2651 if (req.priv_key == NULL) { in PHP_FUNCTION()
2652 php_openssl_generate_private_key(&req TSRMLS_CC); in PHP_FUNCTION()
2654 if (req.priv_key == NULL) { in PHP_FUNCTION()
2659 if (php_openssl_make_REQ(&req, csr, dn, attribs TSRMLS_CC) == SUCCESS) { in PHP_FUNCTION()
2663 X509V3_set_conf_lhash(&ext_ctx, req.req_config); in PHP_FUNCTION()
2666 if (req.request_extensions_section && !X509V3_EXT_REQ_add_conf(req.req_config, in PHP_FUNCTION()
2667 &ext_ctx, req.request_extensions_section, csr)) in PHP_FUNCTION()
2669 …php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading extension section %s", req.request_exte… in PHP_FUNCTION()
2673 if (X509_REQ_sign(csr, req.priv_key, req.digest)) { in PHP_FUNCTION()
2683 ZVAL_RESOURCE(out_pkey, zend_list_insert(req.priv_key, le_key TSRMLS_CC)); in PHP_FUNCTION()
2684 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
2686 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
2693 req.priv_key = NULL; in PHP_FUNCTION()
2702 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
2936 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req TSRMLS_DC) in php_openssl_generate_private_key()
2942 if (req->priv_key_bits < MIN_KEY_LENGTH) { in php_openssl_generate_private_key()
2944 MIN_KEY_LENGTH, req->priv_key_bits); in php_openssl_generate_private_key()
2948 randfile = CONF_get_string(req->req_config, req->section_name, "RANDFILE"); in php_openssl_generate_private_key()
2951 if ((req->priv_key = EVP_PKEY_new()) != NULL) { in php_openssl_generate_private_key()
2952 switch(req->priv_key_type) { in php_openssl_generate_private_key()
2954 …if (EVP_PKEY_assign_RSA(req->priv_key, RSA_generate_key(req->priv_key_bits, 0x10001, NULL, NULL)))… in php_openssl_generate_private_key()
2955 return_val = req->priv_key; in php_openssl_generate_private_key()
2961 DSA *dsapar = DSA_generate_parameters(req->priv_key_bits, NULL, 0, NULL, NULL, NULL, NULL); in php_openssl_generate_private_key()
2965 if (EVP_PKEY_assign_DSA(req->priv_key, dsapar)) { in php_openssl_generate_private_key()
2966 return_val = req->priv_key; in php_openssl_generate_private_key()
2978 DH *dhpar = DH_generate_parameters(req->priv_key_bits, 2, NULL, NULL); in php_openssl_generate_private_key()
2984 if (EVP_PKEY_assign_DH(req->priv_key, dhpar)) { in php_openssl_generate_private_key()
2985 return_val = req->priv_key; in php_openssl_generate_private_key()
3002 EVP_PKEY_free(req->priv_key); in php_openssl_generate_private_key()
3003 req->priv_key = NULL; in php_openssl_generate_private_key()
3091 struct php_x509_request req; in PHP_FUNCTION() local
3177 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3179 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) in PHP_FUNCTION()
3181 if (php_openssl_generate_private_key(&req TSRMLS_CC)) { in PHP_FUNCTION()
3183 RETVAL_RESOURCE(zend_list_insert(req.priv_key, le_key TSRMLS_CC)); in PHP_FUNCTION()
3185 req.priv_key = NULL; in PHP_FUNCTION()
3188 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3196 struct php_x509_request req; in PHP_FUNCTION() local
3221 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3223 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3226 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
3227 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
3228 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
3241 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3256 struct php_x509_request req; in PHP_FUNCTION() local
3276 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3278 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3281 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
3282 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
3283 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
3303 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()