Lines Matching refs:req

625 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req TSRMLS_DC);
810 static int add_oid_section(struct php_x509_request * req TSRMLS_DC) /* {{{ */ in add_oid_section()
817 str = CONF_get_string(req->req_config, NULL, "oid_section"); in add_oid_section()
821 sktmp = CONF_get_section(req->req_config, str); in add_oid_section()
837 #define PHP_SSL_REQ_INIT(req) memset(req, 0, sizeof(*req)) argument
838 #define PHP_SSL_REQ_DISPOSE(req) php_openssl_dispose_config(req TSRMLS_CC) argument
839 #define PHP_SSL_REQ_PARSE(req, zval) php_openssl_parse_config(req, zval TSRMLS_CC) argument
841 #define PHP_SSL_CONFIG_SYNTAX_CHECK(var) if (req->var && php_openssl_config_check_syntax(#var, \
842 req->config_filename, req->var, req->req_config TSRMLS_CC) == FAILURE) return FAILURE
860 static int php_openssl_parse_config(struct php_x509_request * req, zval * optional_args TSRMLS_DC) … in php_openssl_parse_config() argument
865 SET_OPTIONAL_STRING_ARG("config", req->config_filename, default_ssl_conf_filename); in php_openssl_parse_config()
866 SET_OPTIONAL_STRING_ARG("config_section_name", req->section_name, "req"); in php_openssl_parse_config()
867 req->global_config = CONF_load(NULL, default_ssl_conf_filename, NULL); in php_openssl_parse_config()
868 req->req_config = CONF_load(NULL, req->config_filename, NULL); in php_openssl_parse_config()
870 if (req->req_config == NULL) { in php_openssl_parse_config()
875 str = CONF_get_string(req->req_config, NULL, "oid_file"); in php_openssl_parse_config()
883 if (add_oid_section(req TSRMLS_CC) == FAILURE) { in php_openssl_parse_config()
886 SET_OPTIONAL_STRING_ARG("digest_alg", req->digest_name, in php_openssl_parse_config()
887 CONF_get_string(req->req_config, req->section_name, "default_md")); in php_openssl_parse_config()
888 SET_OPTIONAL_STRING_ARG("x509_extensions", req->extensions_section, in php_openssl_parse_config()
889 CONF_get_string(req->req_config, req->section_name, "x509_extensions")); in php_openssl_parse_config()
890 SET_OPTIONAL_STRING_ARG("req_extensions", req->request_extensions_section, in php_openssl_parse_config()
891 CONF_get_string(req->req_config, req->section_name, "req_extensions")); in php_openssl_parse_config()
892 SET_OPTIONAL_LONG_ARG("private_key_bits", req->priv_key_bits, in php_openssl_parse_config()
893 CONF_get_number(req->req_config, req->section_name, "default_bits")); in php_openssl_parse_config()
895 SET_OPTIONAL_LONG_ARG("private_key_type", req->priv_key_type, OPENSSL_KEYTYPE_DEFAULT); in php_openssl_parse_config()
898 req->priv_key_encrypt = Z_BVAL_PP(item); in php_openssl_parse_config()
900 str = CONF_get_string(req->req_config, req->section_name, "encrypt_rsa_key"); in php_openssl_parse_config()
902 str = CONF_get_string(req->req_config, req->section_name, "encrypt_key"); in php_openssl_parse_config()
905 req->priv_key_encrypt = 0; in php_openssl_parse_config()
907 req->priv_key_encrypt = 1; in php_openssl_parse_config()
911 …if (req->priv_key_encrypt && optional_args && zend_hash_find(Z_ARRVAL_P(optional_args), "encrypt_k… in php_openssl_parse_config()
919 req->priv_key_encrypt_cipher = cipher; in php_openssl_parse_config()
922 req->priv_key_encrypt_cipher = NULL; in php_openssl_parse_config()
928 if (req->digest_name == NULL) { in php_openssl_parse_config()
929 req->digest_name = CONF_get_string(req->req_config, req->section_name, "default_md"); in php_openssl_parse_config()
931 if (req->digest_name) { in php_openssl_parse_config()
932 req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name); in php_openssl_parse_config()
934 if (req->md_alg == NULL) { in php_openssl_parse_config()
935 req->md_alg = req->digest = EVP_sha1(); in php_openssl_parse_config()
941 str = CONF_get_string(req->req_config, req->section_name, "string_mask"); in php_openssl_parse_config()
953 static void php_openssl_dispose_config(struct php_x509_request * req TSRMLS_DC) /* {{{ */ in php_openssl_dispose_config()
955 if (req->priv_key) { in php_openssl_dispose_config()
956 EVP_PKEY_free(req->priv_key); in php_openssl_dispose_config()
957 req->priv_key = NULL; in php_openssl_dispose_config()
959 if (req->global_config) { in php_openssl_dispose_config()
960 CONF_free(req->global_config); in php_openssl_dispose_config()
961 req->global_config = NULL; in php_openssl_dispose_config()
963 if (req->req_config) { in php_openssl_dispose_config()
964 CONF_free(req->req_config); in php_openssl_dispose_config()
965 req->req_config = NULL; in php_openssl_dispose_config()
2660 static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, zval * dn, zval * at… in php_openssl_make_REQ() argument
2665 dn_sect = CONF_get_string(req->req_config, req->section_name, "distinguished_name"); in php_openssl_make_REQ()
2669 dn_sk = CONF_get_section(req->req_config, dn_sect); in php_openssl_make_REQ()
2673 attr_sect = CONF_get_string(req->req_config, req->section_name, "attributes"); in php_openssl_make_REQ()
2677 attr_sk = CONF_get_section(req->req_config, attr_sect); in php_openssl_make_REQ()
2817 X509_REQ_set_pubkey(csr, req->priv_key); in php_openssl_make_REQ()
2968 struct php_x509_request req; in PHP_FUNCTION() local
2974 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
2998 if (PHP_SSL_REQ_PARSE(&req, args) == FAILURE) { in PHP_FUNCTION()
3045 if (req.extensions_section) { in PHP_FUNCTION()
3049 X509V3_set_conf_lhash(&ctx, req.req_config); in PHP_FUNCTION()
3050 if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) { in PHP_FUNCTION()
3056 if (!X509_sign(new_cert, priv_key, req.digest)) { in PHP_FUNCTION()
3070 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3094 struct php_x509_request req; in PHP_FUNCTION() local
3106 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3108 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3111 req.priv_key = php_openssl_evp_from_zval(&out_pkey, 0, NULL, 0, &key_resource TSRMLS_CC); in PHP_FUNCTION()
3112 if (req.priv_key != NULL) { in PHP_FUNCTION()
3116 if (req.priv_key == NULL) { in PHP_FUNCTION()
3117 php_openssl_generate_private_key(&req TSRMLS_CC); in PHP_FUNCTION()
3119 if (req.priv_key == NULL) { in PHP_FUNCTION()
3124 if (php_openssl_make_REQ(&req, csr, dn, attribs TSRMLS_CC) == SUCCESS) { in PHP_FUNCTION()
3128 X509V3_set_conf_lhash(&ext_ctx, req.req_config); in PHP_FUNCTION()
3131 if (req.request_extensions_section && !X509V3_EXT_REQ_add_conf(req.req_config, in PHP_FUNCTION()
3132 &ext_ctx, req.request_extensions_section, csr)) in PHP_FUNCTION()
3134 …php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading extension section %s", req.request_exte… in PHP_FUNCTION()
3138 if (X509_REQ_sign(csr, req.priv_key, req.digest)) { in PHP_FUNCTION()
3148 ZVAL_RESOURCE(out_pkey, zend_list_insert(req.priv_key, le_key TSRMLS_CC)); in PHP_FUNCTION()
3149 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3151 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3158 req.priv_key = NULL; in PHP_FUNCTION()
3167 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3401 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req TSRMLS_DC) in php_openssl_generate_private_key()
3407 if (req->priv_key_bits < MIN_KEY_LENGTH) { in php_openssl_generate_private_key()
3409 MIN_KEY_LENGTH, req->priv_key_bits); in php_openssl_generate_private_key()
3413 randfile = CONF_get_string(req->req_config, req->section_name, "RANDFILE"); in php_openssl_generate_private_key()
3416 if ((req->priv_key = EVP_PKEY_new()) != NULL) { in php_openssl_generate_private_key()
3417 switch(req->priv_key_type) { in php_openssl_generate_private_key()
3420 …if (EVP_PKEY_assign_RSA(req->priv_key, RSA_generate_key(req->priv_key_bits, 0x10001, NULL, NULL)))… in php_openssl_generate_private_key()
3421 return_val = req->priv_key; in php_openssl_generate_private_key()
3428 DSA *dsapar = DSA_generate_parameters(req->priv_key_bits, NULL, 0, NULL, NULL, NULL, NULL); in php_openssl_generate_private_key()
3432 if (EVP_PKEY_assign_DSA(req->priv_key, dsapar)) { in php_openssl_generate_private_key()
3433 return_val = req->priv_key; in php_openssl_generate_private_key()
3446 DH *dhpar = DH_generate_parameters(req->priv_key_bits, 2, NULL, NULL); in php_openssl_generate_private_key()
3452 if (EVP_PKEY_assign_DH(req->priv_key, dhpar)) { in php_openssl_generate_private_key()
3453 return_val = req->priv_key; in php_openssl_generate_private_key()
3470 EVP_PKEY_free(req->priv_key); in php_openssl_generate_private_key()
3471 req->priv_key = NULL; in php_openssl_generate_private_key()
3599 struct php_x509_request req; in PHP_FUNCTION() local
3679 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3681 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) in PHP_FUNCTION()
3683 if (php_openssl_generate_private_key(&req TSRMLS_CC)) { in PHP_FUNCTION()
3685 RETVAL_RESOURCE(zend_list_insert(req.priv_key, le_key TSRMLS_CC)); in PHP_FUNCTION()
3687 req.priv_key = NULL; in PHP_FUNCTION()
3690 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3698 struct php_x509_request req; in PHP_FUNCTION() local
3726 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3728 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3731 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
3732 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
3733 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
3758 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3773 struct php_x509_request req; in PHP_FUNCTION() local
3795 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3797 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3800 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
3801 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
3802 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
3834 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()