Lines Matching refs:req

800 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req);
1000 static int add_oid_section(struct php_x509_request * req) /* {{{ */ in add_oid_section() argument
1007 str = CONF_get_string(req->req_config, NULL, "oid_section"); in add_oid_section()
1011 sktmp = CONF_get_section(req->req_config, str); in add_oid_section()
1028 #define PHP_SSL_REQ_INIT(req) memset(req, 0, sizeof(*req)) argument
1029 #define PHP_SSL_REQ_DISPOSE(req) php_openssl_dispose_config(req) argument
1030 #define PHP_SSL_REQ_PARSE(req, zval) php_openssl_parse_config(req, zval) argument
1032 #define PHP_SSL_CONFIG_SYNTAX_CHECK(var) if (req->var && php_openssl_config_check_syntax(#var, \
1033 req->config_filename, req->var, req->req_config) == FAILURE) return FAILURE
1068 static int php_openssl_parse_config(struct php_x509_request * req, zval * optional_args) /* {{{ */ in php_openssl_parse_config() argument
1073 SET_OPTIONAL_STRING_ARG("config", req->config_filename, default_ssl_conf_filename); in php_openssl_parse_config()
1074 SET_OPTIONAL_STRING_ARG("config_section_name", req->section_name, "req"); in php_openssl_parse_config()
1075 req->global_config = CONF_load(NULL, default_ssl_conf_filename, NULL); in php_openssl_parse_config()
1076 req->req_config = CONF_load(NULL, req->config_filename, NULL); in php_openssl_parse_config()
1078 if (req->req_config == NULL) { in php_openssl_parse_config()
1083 str = CONF_get_string(req->req_config, NULL, "oid_file"); in php_openssl_parse_config()
1091 if (add_oid_section(req) == FAILURE) { in php_openssl_parse_config()
1094 SET_OPTIONAL_STRING_ARG("digest_alg", req->digest_name, in php_openssl_parse_config()
1095 CONF_get_string(req->req_config, req->section_name, "default_md")); in php_openssl_parse_config()
1096 SET_OPTIONAL_STRING_ARG("x509_extensions", req->extensions_section, in php_openssl_parse_config()
1097 CONF_get_string(req->req_config, req->section_name, "x509_extensions")); in php_openssl_parse_config()
1098 SET_OPTIONAL_STRING_ARG("req_extensions", req->request_extensions_section, in php_openssl_parse_config()
1099 CONF_get_string(req->req_config, req->section_name, "req_extensions")); in php_openssl_parse_config()
1100 SET_OPTIONAL_LONG_ARG("private_key_bits", req->priv_key_bits, in php_openssl_parse_config()
1101 CONF_get_number(req->req_config, req->section_name, "default_bits")); in php_openssl_parse_config()
1103 SET_OPTIONAL_LONG_ARG("private_key_type", req->priv_key_type, OPENSSL_KEYTYPE_DEFAULT); in php_openssl_parse_config()
1106 req->priv_key_encrypt = Z_TYPE_P(item) == IS_TRUE ? 1 : 0; in php_openssl_parse_config()
1108 str = CONF_get_string(req->req_config, req->section_name, "encrypt_rsa_key"); in php_openssl_parse_config()
1110 str = CONF_get_string(req->req_config, req->section_name, "encrypt_key"); in php_openssl_parse_config()
1113 req->priv_key_encrypt = 0; in php_openssl_parse_config()
1115 req->priv_key_encrypt = 1; in php_openssl_parse_config()
1119 …if (req->priv_key_encrypt && optional_args && (item = zend_hash_str_find(Z_ARRVAL_P(optional_args)… in php_openssl_parse_config()
1127 req->priv_key_encrypt_cipher = cipher; in php_openssl_parse_config()
1130 req->priv_key_encrypt_cipher = NULL; in php_openssl_parse_config()
1136 if (req->digest_name == NULL) { in php_openssl_parse_config()
1137 req->digest_name = CONF_get_string(req->req_config, req->section_name, "default_md"); in php_openssl_parse_config()
1139 if (req->digest_name) { in php_openssl_parse_config()
1140 req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name); in php_openssl_parse_config()
1142 if (req->md_alg == NULL) { in php_openssl_parse_config()
1143 req->md_alg = req->digest = EVP_sha1(); in php_openssl_parse_config()
1149 str = CONF_get_string(req->req_config, req->section_name, "string_mask"); in php_openssl_parse_config()
1161 static void php_openssl_dispose_config(struct php_x509_request * req) /* {{{ */ in php_openssl_dispose_config() argument
1163 if (req->priv_key) { in php_openssl_dispose_config()
1164 EVP_PKEY_free(req->priv_key); in php_openssl_dispose_config()
1165 req->priv_key = NULL; in php_openssl_dispose_config()
1167 if (req->global_config) { in php_openssl_dispose_config()
1168 CONF_free(req->global_config); in php_openssl_dispose_config()
1169 req->global_config = NULL; in php_openssl_dispose_config()
1171 if (req->req_config) { in php_openssl_dispose_config()
1172 CONF_free(req->req_config); in php_openssl_dispose_config()
1173 req->req_config = NULL; in php_openssl_dispose_config()
2883 static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, zval * dn, zval * at… in php_openssl_make_REQ() argument
2888 dn_sect = CONF_get_string(req->req_config, req->section_name, "distinguished_name"); in php_openssl_make_REQ()
2892 dn_sk = CONF_get_section(req->req_config, dn_sect); in php_openssl_make_REQ()
2896 attr_sect = CONF_get_string(req->req_config, req->section_name, "attributes"); in php_openssl_make_REQ()
2900 attr_sk = CONF_get_section(req->req_config, attr_sect); in php_openssl_make_REQ()
3028 X509_REQ_set_pubkey(csr, req->priv_key); in php_openssl_make_REQ()
3183 struct php_x509_request req; in PHP_FUNCTION() local
3189 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3213 if (PHP_SSL_REQ_PARSE(&req, args) == FAILURE) { in PHP_FUNCTION()
3261 if (req.extensions_section) { in PHP_FUNCTION()
3265 X509V3_set_conf_lhash(&ctx, req.req_config); in PHP_FUNCTION()
3266 if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) { in PHP_FUNCTION()
3272 if (!X509_sign(new_cert, priv_key, req.digest)) { in PHP_FUNCTION()
3286 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3310 struct php_x509_request req; in PHP_FUNCTION() local
3322 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
3324 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
3327 req.priv_key = php_openssl_evp_from_zval(out_pkey, 0, NULL, 0, 0, &key_resource); in PHP_FUNCTION()
3328 if (req.priv_key != NULL) { in PHP_FUNCTION()
3332 if (req.priv_key == NULL) { in PHP_FUNCTION()
3333 php_openssl_generate_private_key(&req); in PHP_FUNCTION()
3335 if (req.priv_key == NULL) { in PHP_FUNCTION()
3340 if (php_openssl_make_REQ(&req, csr, dn, attribs) == SUCCESS) { in PHP_FUNCTION()
3344 X509V3_set_conf_lhash(&ext_ctx, req.req_config); in PHP_FUNCTION()
3347 if (req.request_extensions_section && !X509V3_EXT_REQ_add_conf(req.req_config, in PHP_FUNCTION()
3348 &ext_ctx, req.request_extensions_section, csr)) in PHP_FUNCTION()
3350 …php_error_docref(NULL, E_WARNING, "Error loading extension section %s", req.request_extensions_sec… in PHP_FUNCTION()
3354 if (X509_REQ_sign(csr, req.priv_key, req.digest)) { in PHP_FUNCTION()
3364 ZVAL_RES(out_pkey, zend_register_resource(req.priv_key, le_key)); in PHP_FUNCTION()
3365 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3367 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3374 req.priv_key = NULL; in PHP_FUNCTION()
3383 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
3667 static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req) in php_openssl_generate_private_key() argument
3673 if (req->priv_key_bits < MIN_KEY_LENGTH) { in php_openssl_generate_private_key()
3675 MIN_KEY_LENGTH, req->priv_key_bits); in php_openssl_generate_private_key()
3679 randfile = CONF_get_string(req->req_config, req->section_name, "RANDFILE"); in php_openssl_generate_private_key()
3682 if ((req->priv_key = EVP_PKEY_new()) != NULL) { in php_openssl_generate_private_key()
3683 switch(req->priv_key_type) { in php_openssl_generate_private_key()
3690 rsaparam = (RSA*)RSA_generate_key(req->priv_key_bits, RSA_F4, NULL, NULL); in php_openssl_generate_private_key()
3701 RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL); in php_openssl_generate_private_key()
3705 if (rsaparam && EVP_PKEY_assign_RSA(req->priv_key, rsaparam)) { in php_openssl_generate_private_key()
3706 return_val = req->priv_key; in php_openssl_generate_private_key()
3715 …if (dsaparam && DSA_generate_parameters_ex(dsaparam, req->priv_key_bits, NULL, 0, NULL, NULL, NULL… in php_openssl_generate_private_key()
3718 if (EVP_PKEY_assign_DSA(req->priv_key, dsaparam)) { in php_openssl_generate_private_key()
3719 return_val = req->priv_key; in php_openssl_generate_private_key()
3734 if (dhparam && DH_generate_parameters_ex(dhparam, req->priv_key_bits, 2, NULL)) { in php_openssl_generate_private_key()
3737 if (EVP_PKEY_assign_DH(req->priv_key, dhparam)) { in php_openssl_generate_private_key()
3738 return_val = req->priv_key; in php_openssl_generate_private_key()
3755 EVP_PKEY_free(req->priv_key); in php_openssl_generate_private_key()
3756 req->priv_key = NULL; in php_openssl_generate_private_key()
4017 struct php_x509_request req; in PHP_FUNCTION() local
4079 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
4081 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) in PHP_FUNCTION()
4083 if (php_openssl_generate_private_key(&req)) { in PHP_FUNCTION()
4085 RETVAL_RES(zend_register_resource(req.priv_key, le_key)); in PHP_FUNCTION()
4087 req.priv_key = NULL; in PHP_FUNCTION()
4090 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
4098 struct php_x509_request req; in PHP_FUNCTION() local
4127 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
4129 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
4132 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
4133 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
4134 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
4159 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()
4174 struct php_x509_request req; in PHP_FUNCTION() local
4196 PHP_SSL_REQ_INIT(&req); in PHP_FUNCTION()
4198 if (PHP_SSL_REQ_PARSE(&req, args) == SUCCESS) { in PHP_FUNCTION()
4201 if (passphrase && req.priv_key_encrypt) { in PHP_FUNCTION()
4202 if (req.priv_key_encrypt_cipher) { in PHP_FUNCTION()
4203 cipher = req.priv_key_encrypt_cipher; in PHP_FUNCTION()
4235 PHP_SSL_REQ_DISPOSE(&req); in PHP_FUNCTION()