Lines Matching refs:NULL

565 	NULL,
566 NULL,
572 NULL,
721 php_error_docref(NULL, E_WARNING, #_name" is too long"); \
729 php_error_docref(NULL, E_WARNING, #_name" is too long"); \
730 return NULL; \
792 assert(pkey != NULL); in php_openssl_pkey_free()
878 ASN1_STRING * str = NULL; in php_openssl_add_assoc_name_entry()
881 if (key != NULL) { in php_openssl_add_assoc_name_entry()
888 const unsigned char *to_add = NULL; in php_openssl_add_assoc_name_entry()
890 unsigned char *to_add_buf = NULL; in php_openssl_add_assoc_name_entry()
914 if ((data = zend_hash_str_find(Z_ARRVAL(subitem), sname, strlen(sname))) != NULL) { in php_openssl_add_assoc_name_entry()
933 if (to_add_buf != NULL) { in php_openssl_add_assoc_name_entry()
938 if (key != NULL) { in php_openssl_add_assoc_name_entry()
967 php_error_docref(NULL, E_WARNING, "illegal ASN1 data type for timestamp"); in php_openssl_asn1_time_to_time_t()
974 php_error_docref(NULL, E_WARNING, "illegal length in timestamp"); in php_openssl_asn1_time_to_time_t()
979 php_error_docref(NULL, E_WARNING, "unable to parse time string %s correctly", timestr->data); in php_openssl_asn1_time_to_time_t()
984 php_error_docref(NULL, E_WARNING, "unable to parse time string %s correctly", timestr->data); in php_openssl_asn1_time_to_time_t()
1055 if (!X509V3_EXT_add_conf(config, &ctx, (char *)section, NULL)) { in php_openssl_config_check_syntax()
1057 php_error_docref(NULL, E_WARNING, "Error loading %s section %s of %s", in php_openssl_config_check_syntax()
1070 if (str == NULL) { in php_openssl_conf_get_string()
1085 str = php_openssl_conf_get_string(req->req_config, NULL, "oid_section"); in php_openssl_add_oid_section()
1086 if (str == NULL) { in php_openssl_add_oid_section()
1090 if (sktmp == NULL) { in php_openssl_add_oid_section()
1092 php_error_docref(NULL, E_WARNING, "problem loading oid section %s", str); in php_openssl_add_oid_section()
1100 php_error_docref(NULL, E_WARNING, "problem creating object %s=%s", cnf->name, cnf->value); in php_openssl_add_oid_section()
1117 …m = zend_hash_str_find(Z_ARRVAL_P(optional_args), key, sizeof(key)-1)) != NULL && Z_TYPE_P(item) =…
1121 if (varname == NULL) { \
1128 …m = zend_hash_str_find(Z_ARRVAL_P(optional_args), key, sizeof(key)-1)) != NULL && Z_TYPE_P(item) =…
1160 req->global_config = CONF_load(NULL, default_ssl_conf_filename, NULL); in php_openssl_parse_config()
1161 if (req->global_config == NULL) { in php_openssl_parse_config()
1164 req->req_config = CONF_load(NULL, req->config_filename, NULL); in php_openssl_parse_config()
1165 if (req->req_config == NULL) { in php_openssl_parse_config()
1171 str = php_openssl_conf_get_string(req->req_config, NULL, "oid_file"); in php_openssl_parse_config()
1172 if (str != NULL && !php_openssl_open_base_dir_chk(str)) { in php_openssl_parse_config()
1194 …= zend_hash_str_find(Z_ARRVAL_P(optional_args), "encrypt_key", sizeof("encrypt_key")-1)) != NULL) { in php_openssl_parse_config()
1198 if (str == NULL) { in php_openssl_parse_config()
1201 if (str != NULL && strcmp(str, "no") == 0) { in php_openssl_parse_config()
1210 …r_find(Z_ARRVAL_P(optional_args), "encrypt_key_cipher", sizeof("encrypt_key_cipher")-1)) != NULL && in php_openssl_parse_config()
1215 if (cipher == NULL) { in php_openssl_parse_config()
1216 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm for private key."); in php_openssl_parse_config()
1222 req->priv_key_encrypt_cipher = NULL; in php_openssl_parse_config()
1226 if (req->digest_name == NULL) { in php_openssl_parse_config()
1229 if (req->digest_name != NULL) { in php_openssl_parse_config()
1232 if (req->md_alg == NULL) { in php_openssl_parse_config()
1241 …item = zend_hash_str_find(Z_ARRVAL_P(optional_args), "curve_name", sizeof("curve_name")-1)) != NULL in php_openssl_parse_config()
1245 php_error_docref(NULL, E_WARNING, "Unknown elliptic curve (short) name %s", Z_STRVAL_P(item)); in php_openssl_parse_config()
1253 if (str != NULL && !ASN1_STRING_set_default_mask_asc(str)) { in php_openssl_parse_config()
1254 php_error_docref(NULL, E_WARNING, "Invalid global string mask setting %s", str); in php_openssl_parse_config()
1268 req->priv_key = NULL; in php_openssl_dispose_config()
1272 req->global_config = NULL; in php_openssl_dispose_config()
1276 req->req_config = NULL; in php_openssl_dispose_config()
1290 gettimeofday(&tv, NULL); in php_openssl_rand_add_timeval()
1304 if (file == NULL) { in php_openssl_load_rand_file()
1314 if (file == NULL || !RAND_load_file(file, -1)) { in php_openssl_load_rand_file()
1317 php_error_docref(NULL, E_WARNING, "unable to load random state; not enough random data!"); in php_openssl_load_rand_file()
1337 if (file == NULL) { in php_openssl_write_rand_file()
1341 if (file == NULL || !RAND_write_file(file)) { in php_openssl_write_rand_file()
1343 php_error_docref(NULL, E_WARNING, "unable to write random state"); in php_openssl_write_rand_file()
1389 return NULL; in php_openssl_get_evp_md_from_algo()
1433 return NULL; in php_openssl_get_evp_cipher_from_algo()
1441 PHP_INI_ENTRY("openssl.cafile", NULL, PHP_INI_PERDIR, NULL)
1442 PHP_INI_ENTRY("openssl.capath", NULL, PHP_INI_PERDIR, NULL)
1452 …le_key = zend_register_list_destructors_ex(php_openssl_pkey_free, NULL, "OpenSSL key", module_numb… in PHP_INI_END()
1453 …le_x509 = zend_register_list_destructors_ex(php_openssl_x509_free, NULL, "OpenSSL X.509", module_n… in PHP_INI_END()
1454 …le_csr = zend_register_list_destructors_ex(php_openssl_csr_free, NULL, "OpenSSL X.509 CSR", module… in PHP_INI_END()
1457 OPENSSL_config(NULL); in PHP_INI_END()
1471 OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL); in PHP_INI_END()
1476 ssl_stream_data_index = SSL_get_ex_new_index(0, "PHP stream index", NULL, NULL, NULL); in PHP_INI_END()
1564 if (config_filename == NULL) { in PHP_INI_END()
1569 if (config_filename == NULL) { in PHP_INI_END()
1608 openssl_globals->errors = NULL; in PHP_GINIT_FUNCTION()
1644 CRYPTO_set_locking_callback(NULL); in PHP_MSHUTDOWN_FUNCTION()
1707 X509 *cert = NULL; in php_openssl_x509_from_zval()
1711 *resourceval = NULL; in php_openssl_x509_from_zval()
1720 return NULL; in php_openssl_x509_from_zval()
1732 return NULL; in php_openssl_x509_from_zval()
1737 return NULL; in php_openssl_x509_from_zval()
1743 return NULL; in php_openssl_x509_from_zval()
1747 if (in == NULL) { in php_openssl_x509_from_zval()
1749 return NULL; in php_openssl_x509_from_zval()
1751 cert = PEM_read_bio_X509(in, NULL, NULL, NULL); in php_openssl_x509_from_zval()
1756 if (in == NULL) { in php_openssl_x509_from_zval()
1758 return NULL; in php_openssl_x509_from_zval()
1761 cert = (X509 *) PEM_ASN1_read_bio((d2i_of_void *)d2i_X509, PEM_STRING_X509, in, NULL, NULL, NULL); in php_openssl_x509_from_zval()
1763 cert = (X509 *) PEM_ASN1_read_bio((char *(*)())d2i_X509, PEM_STRING_X509, in, NULL, NULL, NULL); in php_openssl_x509_from_zval()
1771 if (cert == NULL) { in php_openssl_x509_from_zval()
1773 return NULL; in php_openssl_x509_from_zval()
1800 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
1801 if (cert == NULL) { in PHP_FUNCTION()
1802 php_error_docref(NULL, E_WARNING, "cannot get cert from parameter 1"); in PHP_FUNCTION()
1822 php_error_docref(NULL, E_WARNING, "error opening file %s", filename); in PHP_FUNCTION()
1840 char * challenge = NULL, * spkstr = NULL; in PHP_FUNCTION()
1841 zend_string * s = NULL; in PHP_FUNCTION()
1842 zend_resource *keyresource = NULL; in PHP_FUNCTION()
1846 zval *method = NULL; in PHP_FUNCTION()
1847 zval * zpkey = NULL; in PHP_FUNCTION()
1848 EVP_PKEY * pkey = NULL; in PHP_FUNCTION()
1849 NETSCAPE_SPKI *spki=NULL; in PHP_FUNCTION()
1860 if (pkey == NULL) { in PHP_FUNCTION()
1861 php_error_docref(NULL, E_WARNING, "Unable to use supplied private key"); in PHP_FUNCTION()
1865 if (method != NULL) { in PHP_FUNCTION()
1869 php_error_docref(NULL, E_WARNING, "Algorithm must be of supported type"); in PHP_FUNCTION()
1876 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm"); in PHP_FUNCTION()
1880 if ((spki = NETSCAPE_SPKI_new()) == NULL) { in PHP_FUNCTION()
1882 php_error_docref(NULL, E_WARNING, "Unable to create new SPKAC"); in PHP_FUNCTION()
1889 php_error_docref(NULL, E_WARNING, "Unable to set challenge data"); in PHP_FUNCTION()
1896 php_error_docref(NULL, E_WARNING, "Unable to embed public key"); in PHP_FUNCTION()
1902 php_error_docref(NULL, E_WARNING, "Unable to sign with specified algorithm"); in PHP_FUNCTION()
1909 php_error_docref(NULL, E_WARNING, "Unable to encode SPKAC"); in PHP_FUNCTION()
1923 if (spki != NULL) { in PHP_FUNCTION()
1926 if (keyresource == NULL && pkey != NULL) { in PHP_FUNCTION()
1934 if (keyresource == NULL && s != NULL) { in PHP_FUNCTION()
1946 char *spkstr, * spkstr_cleaned = NULL; in PHP_FUNCTION()
1948 EVP_PKEY *pkey = NULL; in PHP_FUNCTION()
1949 NETSCAPE_SPKI *spki = NULL; in PHP_FUNCTION()
1960 php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); in PHP_FUNCTION()
1965 if (spki == NULL) { in PHP_FUNCTION()
1967 php_error_docref(NULL, E_WARNING, "Unable to decode supplied SPKAC"); in PHP_FUNCTION()
1972 if (pkey == NULL) { in PHP_FUNCTION()
1974 php_error_docref(NULL, E_WARNING, "Unable to acquire signed public key"); in PHP_FUNCTION()
1982 if (spki != NULL) { in PHP_FUNCTION()
1985 if (pkey != NULL) { in PHP_FUNCTION()
1988 if (spkstr_cleaned != NULL) { in PHP_FUNCTION()
2005 char *spkstr, * spkstr_cleaned = NULL, * s = NULL; in PHP_FUNCTION()
2008 EVP_PKEY *pkey = NULL; in PHP_FUNCTION()
2009 NETSCAPE_SPKI *spki = NULL; in PHP_FUNCTION()
2010 BIO *out = NULL; in PHP_FUNCTION()
2021 php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); in PHP_FUNCTION()
2026 if (spki == NULL) { in PHP_FUNCTION()
2028 php_error_docref(NULL, E_WARNING, "Unable to decode supplied SPKAC"); in PHP_FUNCTION()
2033 if (pkey == NULL) { in PHP_FUNCTION()
2035 php_error_docref(NULL, E_WARNING, "Unable to acquire signed public key"); in PHP_FUNCTION()
2052 if (spki != NULL) { in PHP_FUNCTION()
2055 if (out != NULL) { in PHP_FUNCTION()
2058 if (pkey != NULL) { in PHP_FUNCTION()
2061 if (spkstr_cleaned != NULL) { in PHP_FUNCTION()
2064 if (s != NULL) { in PHP_FUNCTION()
2075 char *spkstr, * spkstr_cleaned = NULL; in PHP_FUNCTION()
2078 NETSCAPE_SPKI *spki = NULL; in PHP_FUNCTION()
2089 php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); in PHP_FUNCTION()
2094 if (spki == NULL) { in PHP_FUNCTION()
2096 php_error_docref(NULL, E_WARNING, "Unable to decode SPKAC"); in PHP_FUNCTION()
2104 if (spkstr_cleaned != NULL) { in PHP_FUNCTION()
2127 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2128 if (cert == NULL) { in PHP_FUNCTION()
2129 php_error_docref(NULL, E_WARNING, "cannot get cert from parameter 1"); in PHP_FUNCTION()
2169 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm"); in php_openssl_x509_fingerprint()
2170 return NULL; in php_openssl_x509_fingerprint()
2173 php_error_docref(NULL, E_ERROR, "Could not generate signature"); in php_openssl_x509_fingerprint()
2174 return NULL; in php_openssl_x509_fingerprint()
2201 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2202 if (cert == NULL) { in PHP_FUNCTION()
2203 php_error_docref(NULL, E_WARNING, "cannot get cert from parameter 1"); in PHP_FUNCTION()
2224 X509 * cert = NULL; in PHP_FUNCTION()
2225 EVP_PKEY * key = NULL; in PHP_FUNCTION()
2226 zend_resource *keyresource = NULL; in PHP_FUNCTION()
2233 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2234 if (cert == NULL) { in PHP_FUNCTION()
2242 if (keyresource == NULL && key) { in PHP_FUNCTION()
2256 X509 * cert = NULL; in PHP_FUNCTION()
2257 EVP_PKEY * key = NULL; in PHP_FUNCTION()
2258 zend_resource *keyresource = NULL; in PHP_FUNCTION()
2264 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2265 if (cert == NULL) { in PHP_FUNCTION()
2268 key = php_openssl_evp_from_zval(zkey, 1, NULL, 0, 0, &keyresource); in PHP_FUNCTION()
2269 if (key == NULL) { in PHP_FUNCTION()
2280 if (keyresource == NULL && key) { in PHP_FUNCTION()
2298 const X509V3_EXT_METHOD *method = NULL; in openssl_x509v3_subjectAltName()
2304 if (method == NULL) { in openssl_x509v3_subjectAltName()
2312 names = (GENERAL_NAMES*) (ASN1_item_d2i(NULL, &p, length, in openssl_x509v3_subjectAltName()
2315 names = (GENERAL_NAMES*) (method->d2i(NULL, &p, length)); in openssl_x509v3_subjectAltName()
2317 if (names == NULL) { in openssl_x509v3_subjectAltName()
2367 X509 * cert = NULL; in PHP_FUNCTION()
2387 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2388 if (cert == NULL) { in PHP_FUNCTION()
2394 cert_name = X509_NAME_oneline(subject_name, NULL, 0); in PHP_FUNCTION()
2411 bn_serial = ASN1_INTEGER_to_BN(asn1_serial, NULL); in PHP_FUNCTION()
2426 str_serial = i2s_ASN1_INTEGER(NULL, asn1_serial); in PHP_FUNCTION()
2440 tmpstr = (char *)X509_alias_get0(cert, NULL); in PHP_FUNCTION()
2493 if (bio_out == NULL) { in PHP_FUNCTION()
2528 STACK_OF(X509_INFO) *sk=NULL; in STACK_OF()
2529 STACK_OF(X509) *stack=NULL, *ret=NULL; in STACK_OF()
2530 BIO *in=NULL; in STACK_OF()
2535 php_error_docref(NULL, E_ERROR, "memory allocation failure"); in STACK_OF()
2546 php_error_docref(NULL, E_WARNING, "error opening the file, %s", certfile); in STACK_OF()
2552 if (!(sk=PEM_X509_INFO_read_bio(in, NULL, NULL, NULL))) { in STACK_OF()
2554 php_error_docref(NULL, E_WARNING, "error reading the file, %s", certfile); in STACK_OF()
2562 if (xi->x509 != NULL) { in STACK_OF()
2564 xi->x509=NULL; in STACK_OF()
2569 php_error_docref(NULL, E_WARNING, "no certificates in file, %s", certfile); in STACK_OF()
2589 if (csc == NULL) { in check_cert()
2591 php_error_docref(NULL, E_ERROR, "memory allocation failure"); in check_cert()
2596 php_error_docref(NULL, E_WARNING, "cert store initialization failed"); in check_cert()
2616 zval * zcert, * zcainfo = NULL; in PHP_FUNCTION()
2617 X509_STORE * cainfo = NULL; in PHP_FUNCTION()
2618 X509 * cert = NULL; in PHP_FUNCTION()
2619 STACK_OF(X509) * untrustedchain = NULL; in PHP_FUNCTION()
2621 char * untrusted = NULL; in PHP_FUNCTION()
2633 if (untrustedchain == NULL) { in PHP_FUNCTION()
2639 if (cainfo == NULL) { in PHP_FUNCTION()
2642 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2643 if (cert == NULL) { in PHP_FUNCTION()
2680 if (store == NULL) { in php_openssl_setup_verify()
2682 return NULL; in php_openssl_setup_verify()
2689 return NULL; in php_openssl_setup_verify()
2693 php_error_docref(NULL, E_WARNING, "unable to stat %s", ZSTR_VAL(str)); in php_openssl_setup_verify()
2700 …if (file_lookup == NULL || !X509_LOOKUP_load_file(file_lookup, ZSTR_VAL(str), X509_FILETYPE_PEM)) { in php_openssl_setup_verify()
2702 php_error_docref(NULL, E_WARNING, "error loading file %s", ZSTR_VAL(str)); in php_openssl_setup_verify()
2706 file_lookup = NULL; in php_openssl_setup_verify()
2709 if (dir_lookup == NULL || !X509_LOOKUP_add_dir(dir_lookup, ZSTR_VAL(str), X509_FILETYPE_PEM)) { in php_openssl_setup_verify()
2711 php_error_docref(NULL, E_WARNING, "error loading directory %s", ZSTR_VAL(str)); in php_openssl_setup_verify()
2715 dir_lookup = NULL; in php_openssl_setup_verify()
2722 if (file_lookup == NULL || !X509_LOOKUP_load_file(file_lookup, NULL, X509_FILETYPE_DEFAULT)) { in php_openssl_setup_verify()
2728 if (dir_lookup == NULL || !X509_LOOKUP_add_dir(dir_lookup, NULL, X509_FILETYPE_DEFAULT)) { in php_openssl_setup_verify()
2750 if (x509 == NULL) { in PHP_FUNCTION()
2751 …php_error_docref(NULL, E_WARNING, "supplied parameter cannot be coerced into an X509 certificate!"… in PHP_FUNCTION()
2767 if ((cert = (X509 *)zend_fetch_resource(Z_RES_P(x509), "OpenSSL X.509", le_x509)) == NULL) { in PHP_FUNCTION()
2791 STACK_OF(X509) * sk = NULL; in STACK_OF()
2801 if (cert == NULL) { in STACK_OF()
2805 if (certresource != NULL) { in STACK_OF()
2808 if (cert == NULL) { in STACK_OF()
2820 if (cert == NULL) { in STACK_OF()
2824 if (certresource != NULL) { in STACK_OF()
2826 if (cert == NULL) { in STACK_OF()
2843 X509 * cert = NULL; in PHP_FUNCTION()
2844 BIO * bio_out = NULL; in PHP_FUNCTION()
2845 PKCS12 * p12 = NULL; in PHP_FUNCTION()
2847 char * friendly_name = NULL; in PHP_FUNCTION()
2851 zval *zcert = NULL, *zpkey = NULL, *args = NULL; in PHP_FUNCTION()
2852 EVP_PKEY *priv_key = NULL; in PHP_FUNCTION()
2855 STACK_OF(X509) *ca = NULL; in PHP_FUNCTION()
2862 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2863 if (cert == NULL) { in PHP_FUNCTION()
2864 php_error_docref(NULL, E_WARNING, "cannot get cert from parameter 1"); in PHP_FUNCTION()
2868 if (priv_key == NULL) { in PHP_FUNCTION()
2869 php_error_docref(NULL, E_WARNING, "cannot get private key from parameter 3"); in PHP_FUNCTION()
2874 php_error_docref(NULL, E_WARNING, "private key does not correspond to cert"); in PHP_FUNCTION()
2883 …(item = zend_hash_str_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name")-1)) != NULL in PHP_FUNCTION()
2893 …s && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) { in PHP_FUNCTION()
2902 if (p12 != NULL) { in PHP_FUNCTION()
2904 if (bio_out != NULL) { in PHP_FUNCTION()
2912 php_error_docref(NULL, E_WARNING, "error opening file %s", filename); in PHP_FUNCTION()
2924 if (keyresource == NULL && priv_key) { in PHP_FUNCTION()
2938 X509 * cert = NULL; in PHP_FUNCTION()
2940 PKCS12 * p12 = NULL; in PHP_FUNCTION()
2941 zval * zcert = NULL, *zout = NULL, *zpkey, *args = NULL; in PHP_FUNCTION()
2942 EVP_PKEY *priv_key = NULL; in PHP_FUNCTION()
2946 char * friendly_name = NULL; in PHP_FUNCTION()
2948 STACK_OF(X509) *ca = NULL; in PHP_FUNCTION()
2955 cert = php_openssl_x509_from_zval(zcert, 0, NULL); in PHP_FUNCTION()
2956 if (cert == NULL) { in PHP_FUNCTION()
2957 php_error_docref(NULL, E_WARNING, "cannot get cert from parameter 1"); in PHP_FUNCTION()
2961 if (priv_key == NULL) { in PHP_FUNCTION()
2962 php_error_docref(NULL, E_WARNING, "cannot get private key from parameter 3"); in PHP_FUNCTION()
2966 php_error_docref(NULL, E_WARNING, "private key does not correspond to cert"); in PHP_FUNCTION()
2972 …(item = zend_hash_str_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name")-1)) != NULL in PHP_FUNCTION()
2978 …s && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) { in PHP_FUNCTION()
2985 if (p12 != NULL) { in PHP_FUNCTION()
3007 if (keyresource == NULL && priv_key) { in PHP_FUNCTION()
3020 zval *zout = NULL, zextracerts, zcert, zpkey; in PHP_FUNCTION()
3023 PKCS12 * p12 = NULL; in PHP_FUNCTION()
3024 EVP_PKEY * pkey = NULL; in PHP_FUNCTION()
3025 X509 * cert = NULL; in PHP_FUNCTION()
3026 STACK_OF(X509) * ca = NULL; in PHP_FUNCTION()
3027 BIO * bio_in = NULL; in PHP_FUNCTION()
3068 if (PEM_write_bio_PrivateKey(bio_out, pkey, NULL, NULL, 0, 0, NULL)) { in PHP_FUNCTION()
3130 STACK_OF(CONF_VALUE) * dn_sk, *attr_sk = NULL; in php_openssl_make_REQ()
3134 if (dn_sect == NULL) { in php_openssl_make_REQ()
3139 if (dn_sk == NULL) { in php_openssl_make_REQ()
3144 if (attr_sect == NULL) { in php_openssl_make_REQ()
3145 attr_sk = NULL; in php_openssl_make_REQ()
3148 if (attr_sk == NULL) { in php_openssl_make_REQ()
3160 zend_string * strindex = NULL; in php_openssl_make_REQ()
3176 php_error_docref(NULL, E_WARNING, in php_openssl_make_REQ()
3186 php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", ZSTR_VAL(strindex)); in php_openssl_make_REQ()
3232 php_error_docref(NULL, E_WARNING, "add_entry_by_txt %s -> %s (failed)", type, v->value); in php_openssl_make_REQ()
3236 php_error_docref(NULL, E_WARNING, "no objects specified in config file"); in php_openssl_make_REQ()
3244 if (NULL == strindex) { in php_openssl_make_REQ()
3245 php_error_docref(NULL, E_WARNING, "dn: numeric fild names are not supported"); in php_openssl_make_REQ()
3257 …php_error_docref(NULL, E_WARNING, "attribs: add_entry_by_NID %d -> %s (failed)", nid, ZSTR_VAL(str… in php_openssl_make_REQ()
3263 php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", ZSTR_VAL(strindex)); in php_openssl_make_REQ()
3275 php_error_docref(NULL, E_WARNING, in php_openssl_make_REQ()
3298 X509_REQ * csr = NULL; in php_openssl_csr_from_zval()
3299 char * filename = NULL; in php_openssl_csr_from_zval()
3303 *resourceval = NULL; in php_openssl_csr_from_zval()
3319 return NULL; in php_openssl_csr_from_zval()
3321 return NULL; in php_openssl_csr_from_zval()
3329 return NULL; in php_openssl_csr_from_zval()
3336 if (in == NULL) { in php_openssl_csr_from_zval()
3338 return NULL; in php_openssl_csr_from_zval()
3341 csr = PEM_read_bio_X509_REQ(in, NULL,NULL,NULL); in php_openssl_csr_from_zval()
3342 if (csr == NULL) { in php_openssl_csr_from_zval()
3357 zval * zcsr = NULL; in PHP_FUNCTION()
3359 char * filename = NULL; in PHP_FUNCTION()
3370 if (csr == NULL) { in PHP_FUNCTION()
3371 php_error_docref(NULL, E_WARNING, "cannot get CSR from parameter 1"); in PHP_FUNCTION()
3380 if (bio_out != NULL) { in PHP_FUNCTION()
3385 php_error_docref(NULL, E_WARNING, "error writing PEM to file %s", filename); in PHP_FUNCTION()
3393 php_error_docref(NULL, E_WARNING, "error opening file %s", filename); in PHP_FUNCTION()
3396 if (csr_resource == NULL && csr != NULL) { in PHP_FUNCTION()
3407 zval * zcsr = NULL, *zout=NULL; in PHP_FUNCTION()
3419 if (csr == NULL) { in PHP_FUNCTION()
3420 php_error_docref(NULL, E_WARNING, "cannot get CSR from parameter 1"); in PHP_FUNCTION()
3442 if (csr_resource == NULL && csr) { in PHP_FUNCTION()
3453 zval * zcert = NULL, *zcsr, *zpkey, *args = NULL; in PHP_FUNCTION()
3456 X509 * cert = NULL, *new_cert = NULL; in PHP_FUNCTION()
3458 EVP_PKEY * key = NULL, *priv_key = NULL; in PHP_FUNCTION()
3459 zend_resource *csr_resource, *certresource = NULL, *keyresource = NULL; in PHP_FUNCTION()
3470 if (csr == NULL) { in PHP_FUNCTION()
3471 php_error_docref(NULL, E_WARNING, "cannot get CSR from parameter 1"); in PHP_FUNCTION()
3476 if (cert == NULL) { in PHP_FUNCTION()
3477 php_error_docref(NULL, E_WARNING, "cannot get cert from parameter 2"); in PHP_FUNCTION()
3482 if (priv_key == NULL) { in PHP_FUNCTION()
3483 php_error_docref(NULL, E_WARNING, "cannot get private key from parameter 3"); in PHP_FUNCTION()
3488 php_error_docref(NULL, E_WARNING, "private key does not correspond to signing cert"); in PHP_FUNCTION()
3497 if (key == NULL) { in PHP_FUNCTION()
3499 php_error_docref(NULL, E_WARNING, "error unpacking public key"); in PHP_FUNCTION()
3506 php_error_docref(NULL, E_WARNING, "Signature verification problems"); in PHP_FUNCTION()
3510 php_error_docref(NULL, E_WARNING, "Signature did not match the certificate request"); in PHP_FUNCTION()
3517 if (new_cert == NULL) { in PHP_FUNCTION()
3519 php_error_docref(NULL, E_WARNING, "No memory"); in PHP_FUNCTION()
3535 if (cert == NULL) { in PHP_FUNCTION()
3552 X509V3_set_ctx(&ctx, cert, new_cert, csr, NULL, 0); in PHP_FUNCTION()
3563 php_error_docref(NULL, E_WARNING, "failed to sign it"); in PHP_FUNCTION()
3569 new_cert = NULL; in PHP_FUNCTION()
3574 cert = NULL; in PHP_FUNCTION()
3578 if (keyresource == NULL && priv_key) { in PHP_FUNCTION()
3584 if (csr_resource == NULL && csr) { in PHP_FUNCTION()
3587 if (zcert && certresource == NULL && cert) { in PHP_FUNCTION()
3601 zval * args = NULL, * dn, *attribs = NULL; in PHP_FUNCTION()
3603 X509_REQ * csr = NULL; in PHP_FUNCTION()
3620 req.priv_key = php_openssl_evp_from_zval(out_pkey_val, 0, NULL, 0, 0, &key_resource); in PHP_FUNCTION()
3621 if (req.priv_key != NULL) { in PHP_FUNCTION()
3625 if (req.priv_key == NULL) { in PHP_FUNCTION()
3628 if (req.priv_key == NULL) { in PHP_FUNCTION()
3629 php_error_docref(NULL, E_WARNING, "Unable to generate a private key"); in PHP_FUNCTION()
3636 X509V3_set_ctx(&ext_ctx, NULL, NULL, csr, NULL, 0); in PHP_FUNCTION()
3644 …php_error_docref(NULL, E_WARNING, "Error loading extension section %s", req.request_extensions_sec… in PHP_FUNCTION()
3650 csr = NULL; in PHP_FUNCTION()
3653 php_error_docref(NULL, E_WARNING, "Error signing request"); in PHP_FUNCTION()
3659 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3660 } else if (key_resource != NULL) { in PHP_FUNCTION()
3661 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3668 req.priv_key = NULL; in PHP_FUNCTION()
3700 if (csr == NULL) { in PHP_FUNCTION()
3707 php_openssl_add_assoc_name_entry(return_value, NULL, subject, use_shortnames); in PHP_FUNCTION()
3732 if (orig_csr == NULL) { in PHP_FUNCTION()
3760 if (tpubkey == NULL) { in PHP_FUNCTION()
3783 if (password == NULL || password->key == NULL) { in php_openssl_pem_password_cb()
3811 EVP_PKEY * key = NULL; in php_openssl_evp_from_zval()
3812 X509 * cert = NULL; in php_openssl_evp_from_zval()
3814 zend_resource *cert_res = NULL; in php_openssl_evp_from_zval()
3815 char * filename = NULL; in php_openssl_evp_from_zval()
3824 return NULL; in php_openssl_evp_from_zval()
3827 *resourceval = NULL; in php_openssl_evp_from_zval()
3834 if ((zphrase = zend_hash_index_find(Z_ARRVAL_P(val), 1)) == NULL) { in php_openssl_evp_from_zval()
3835 php_error_docref(NULL, E_WARNING, "key array must be of the form array(0 => key, 1 => phrase)"); in php_openssl_evp_from_zval()
3836 return NULL; in php_openssl_evp_from_zval()
3845 return NULL; in php_openssl_evp_from_zval()
3853 if ((val = zend_hash_index_find(Z_ARRVAL_P(val), 0)) == NULL) { in php_openssl_evp_from_zval()
3854 php_error_docref(NULL, E_WARNING, "key array must be of the form array(0 => key, 1 => phrase)"); in php_openssl_evp_from_zval()
3878 php_error_docref(NULL, E_WARNING, "supplied key param is a public key"); in php_openssl_evp_from_zval()
3883 php_error_docref(NULL, E_WARNING, "Don't know how to get public key from this private key"); in php_openssl_evp_from_zval()
3921 free_cert = (cert_res == NULL); in php_openssl_evp_from_zval()
3931 if (in == NULL) { in php_openssl_evp_from_zval()
3935 key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL); in php_openssl_evp_from_zval()
3948 if (in == NULL) { in php_openssl_evp_from_zval()
3951 if (passphrase == NULL) { in php_openssl_evp_from_zval()
3952 key = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL); in php_openssl_evp_from_zval()
3957 key = PEM_read_bio_PrivateKey(in, NULL, php_openssl_pem_password_cb, &password); in php_openssl_evp_from_zval()
3963 if (key == NULL) { in php_openssl_evp_from_zval()
3969 if (key == NULL) { in php_openssl_evp_from_zval()
3991 char * randfile = NULL; in php_openssl_generate_private_key()
3993 EVP_PKEY * return_val = NULL; in php_openssl_generate_private_key()
3996 …php_error_docref(NULL, E_WARNING, "private key length is too short; it needs to be at least %d bit… in php_openssl_generate_private_key()
3998 return NULL; in php_openssl_generate_private_key()
4004 if ((req->priv_key = EVP_PKEY_new()) != NULL) { in php_openssl_generate_private_key()
4012 rsaparam = (RSA*)RSA_generate_key(req->priv_key_bits, RSA_F4, NULL, NULL); in php_openssl_generate_private_key()
4018 php_error_docref(NULL, E_WARNING, "failed setting exponent"); in php_openssl_generate_private_key()
4019 return NULL; in php_openssl_generate_private_key()
4023 if (rsaparam == NULL || !RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL)) { in php_openssl_generate_private_key()
4026 rsaparam = NULL; in php_openssl_generate_private_key()
4043 …(dsaparam && DSA_generate_parameters_ex(dsaparam, req->priv_key_bits, NULL, 0, NULL, NULL, NULL)) { in php_openssl_generate_private_key()
4067 if (dhparam && DH_generate_parameters_ex(dhparam, req->priv_key_bits, 2, NULL)) { in php_openssl_generate_private_key()
4090 php_error_docref(NULL, E_WARNING, "Missing configuration value: 'curve_name' not set"); in php_openssl_generate_private_key()
4091 return NULL; in php_openssl_generate_private_key()
4107 php_error_docref(NULL, E_WARNING, "Unsupported private key type"); in php_openssl_generate_private_key()
4115 if (return_val == NULL) { in php_openssl_generate_private_key()
4117 req->priv_key = NULL; in php_openssl_generate_private_key()
4118 return NULL; in php_openssl_generate_private_key()
4129 assert(pkey != NULL); in php_openssl_is_private_key()
4136 if (rsa != NULL) { in php_openssl_is_private_key()
4140 if (p == NULL || q == NULL) { in php_openssl_is_private_key()
4153 if (dsa != NULL) { in php_openssl_is_private_key()
4157 if (p == NULL || q == NULL) { in php_openssl_is_private_key()
4162 if (priv_key == NULL) { in php_openssl_is_private_key()
4171 if (dh != NULL) { in php_openssl_is_private_key()
4175 if (p == NULL) { in php_openssl_is_private_key()
4180 if (priv_key == NULL) { in php_openssl_is_private_key()
4190 if (ec != NULL && NULL == EC_KEY_get0_private_key(ec)) { in php_openssl_is_private_key()
4197 php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!"); in php_openssl_is_private_key()
4205 if (_bn != NULL) { \
4218 if ((bn = zend_hash_str_find(Z_ARRVAL_P(_data), #_name, sizeof(#_name)-1)) != NULL && \
4222 (int)Z_STRLEN_P(bn), NULL); \
4224 _name = NULL; \
4305 if (pub_key == NULL) { in php_openssl_dh_pub_from_priv()
4307 return NULL; in php_openssl_dh_pub_from_priv()
4311 if (priv_key_const_time == NULL) { in php_openssl_dh_pub_from_priv()
4314 return NULL; in php_openssl_dh_pub_from_priv()
4317 if (ctx == NULL) { in php_openssl_dh_pub_from_priv()
4321 return NULL; in php_openssl_dh_pub_from_priv()
4326 if (!BN_mod_exp_mont(pub_key, g, priv_key_const_time, p, ctx, NULL)) { in php_openssl_dh_pub_from_priv()
4329 pub_key = NULL; in php_openssl_dh_pub_from_priv()
4358 if (pub_key == NULL) { in php_openssl_pkey_init_dh()
4380 zval * args = NULL; in PHP_FUNCTION()
4391 if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "rsa", sizeof("rsa")-1)) != NULL && in PHP_FUNCTION()
4409 } else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dsa", sizeof("dsa") - 1)) != NULL && in PHP_FUNCTION()
4431 } else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dh", sizeof("dh") - 1)) != NULL && in PHP_FUNCTION()
4455 } else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "ec", sizeof("ec") - 1)) != NULL && in PHP_FUNCTION()
4457 EC_KEY *eckey = NULL; in PHP_FUNCTION()
4458 EC_GROUP *group = NULL; in PHP_FUNCTION()
4459 EC_POINT *pnt = NULL; in PHP_FUNCTION()
4460 BIGNUM *d = NULL; in PHP_FUNCTION()
4465 EC_GROUP *group = NULL; in PHP_FUNCTION()
4470 … if ((bn = zend_hash_str_find(Z_ARRVAL_P(data), "curve_name", sizeof("curve_name") - 1)) != NULL && in PHP_FUNCTION()
4488 if (group == NULL) { in PHP_FUNCTION()
4489 php_error_docref(NULL, E_WARNING, "Unknown curve_name"); in PHP_FUNCTION()
4494 if ((bn = zend_hash_str_find(Z_ARRVAL_P(data), "d", sizeof("d") - 1)) != NULL && in PHP_FUNCTION()
4496 d = BN_bin2bn((unsigned char*) Z_STRVAL_P(bn), Z_STRLEN_P(bn), NULL); in PHP_FUNCTION()
4504 if (!pnt || !EC_POINT_mul(group, pnt, d, NULL, NULL, NULL)) { in PHP_FUNCTION()
4510 } else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL && in PHP_FUNCTION()
4512 (y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL && in PHP_FUNCTION()
4515 if (pnt == NULL) { in PHP_FUNCTION()
4520 group, pnt, BN_bin2bn((unsigned char*) Z_STRVAL_P(x), Z_STRLEN_P(x), NULL), in PHP_FUNCTION()
4521 BN_bin2bn((unsigned char*) Z_STRVAL_P(y), Z_STRLEN_P(y), NULL), NULL)) { in PHP_FUNCTION()
4527 if (pnt != NULL) { in PHP_FUNCTION()
4533 pnt = NULL; in PHP_FUNCTION()
4554 if (d != NULL) { in PHP_FUNCTION()
4557 if (pnt != NULL) { in PHP_FUNCTION()
4560 if (group != NULL) { in PHP_FUNCTION()
4563 if (eckey != NULL) { in PHP_FUNCTION()
4566 if (pkey != NULL) { in PHP_FUNCTION()
4581 req.priv_key = NULL; in PHP_FUNCTION()
4593 zval * zpkey, * args = NULL; in PHP_FUNCTION()
4594 char * passphrase = NULL; in PHP_FUNCTION()
4596 char * filename = NULL; in PHP_FUNCTION()
4598 zend_resource *key_resource = NULL; in PHP_FUNCTION()
4601 BIO * bio_out = NULL; in PHP_FUNCTION()
4612 if (key == NULL) { in PHP_FUNCTION()
4613 php_error_docref(NULL, E_WARNING, "cannot get key from parameter 1"); in PHP_FUNCTION()
4625 if (bio_out == NULL) { in PHP_FUNCTION()
4637 cipher = NULL; in PHP_FUNCTION()
4645 (unsigned char *)passphrase, (int)passphrase_len, NULL, NULL); in PHP_FUNCTION()
4651 (unsigned char *)passphrase, (int)passphrase_len, NULL, NULL); in PHP_FUNCTION()
4667 if (key_resource == NULL && key) { in PHP_FUNCTION()
4681 zval * zpkey, * args = NULL, *out; in PHP_FUNCTION()
4682 char * passphrase = NULL; size_t passphrase_len = 0; in PHP_FUNCTION()
4684 zend_resource *key_resource = NULL; in PHP_FUNCTION()
4686 BIO * bio_out = NULL; in PHP_FUNCTION()
4697 if (key == NULL) { in PHP_FUNCTION()
4698 php_error_docref(NULL, E_WARNING, "cannot get key from parameter 1"); in PHP_FUNCTION()
4714 cipher = NULL; in PHP_FUNCTION()
4722 (unsigned char *)passphrase, (int)passphrase_len, NULL, NULL); in PHP_FUNCTION()
4728 (unsigned char *)passphrase, (int)passphrase_len, NULL, NULL); in PHP_FUNCTION()
4748 if (key_resource == NULL && key) { in PHP_FUNCTION()
4768 pkey = php_openssl_evp_from_zval(cert, 1, NULL, 0, 1, &res); in PHP_FUNCTION()
4769 if (pkey == NULL) { in PHP_FUNCTION()
4786 if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) { in PHP_FUNCTION()
4810 if (pkey == NULL) { in PHP_FUNCTION()
4832 if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) { in PHP_FUNCTION()
4856 if (rsa != NULL) { in PHP_FUNCTION()
4885 if (dsa != NULL) { in PHP_FUNCTION()
4907 if (dh != NULL) { in PHP_FUNCTION()
4926 if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { in PHP_FUNCTION()
4951 if (crv_sn != NULL) { in PHP_FUNCTION()
4956 if (obj != NULL) { in PHP_FUNCTION()
4964 if (EC_POINT_get_affine_coordinates_GFp(ec_group, pub, x, y, NULL)) { in PHP_FUNCTION()
4971 if ((d = EC_KEY_get0_private_key(EVP_PKEY_get0_EC_KEY(pkey))) != NULL) { in PHP_FUNCTION()
5008 if ((pkey = (EVP_PKEY *)zend_fetch_resource(Z_RES_P(key), "OpenSSL key", le_key)) == NULL) { in PHP_FUNCTION()
5015 if (dh == NULL) { in PHP_FUNCTION()
5020 pub = BN_bin2bn((unsigned char*)pub_str, (int)pub_len, NULL); in PHP_FUNCTION()
5055 php_error_docref(NULL, E_WARNING, "keylen < 0, assuming NULL"); in PHP_FUNCTION()
5058 if ((pkey = php_openssl_evp_from_zval(priv_key, 0, "", 0, 0, NULL)) == NULL in PHP_FUNCTION()
5059 || (peer_key = php_openssl_evp_from_zval(peer_pub_key, 1, NULL, 0, 0, NULL)) == NULL) { in PHP_FUNCTION()
5062 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
5068 && (key_size > 0 || EVP_PKEY_derive(ctx, NULL, &key_size) > 0) in PHP_FUNCTION()
5069 && (result = zend_string_alloc(key_size, 0)) != NULL) { in PHP_FUNCTION()
5121 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm"); in PHP_FUNCTION()
5149 X509_STORE * store = NULL; in PHP_FUNCTION()
5150 zval * cainfo = NULL; in PHP_FUNCTION()
5151 STACK_OF(X509) *signers= NULL; in PHP_FUNCTION()
5152 STACK_OF(X509) *others = NULL; in PHP_FUNCTION()
5153 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5154 BIO * in = NULL, * datain = NULL, * dataout = NULL, * p7bout = NULL; in PHP_FUNCTION()
5158 char * extracerts = NULL; in PHP_FUNCTION()
5160 char * signersfilename = NULL; in PHP_FUNCTION()
5162 char * datafilename = NULL; in PHP_FUNCTION()
5164 char * p7bfilename = NULL; in PHP_FUNCTION()
5177 if (others == NULL) { in PHP_FUNCTION()
5194 if (in == NULL) { in PHP_FUNCTION()
5199 if (p7 == NULL) { in PHP_FUNCTION()
5214 if (dataout == NULL) { in PHP_FUNCTION()
5227 if (p7bout == NULL) { in PHP_FUNCTION()
5250 signers = PKCS7_get0_signers(p7, NULL, (int)flags); in PHP_FUNCTION()
5251 if (signers != NULL) { in PHP_FUNCTION()
5257 php_error_docref(NULL, E_WARNING, "failed to write signer %d", i); in PHP_FUNCTION()
5270 …php_error_docref(NULL, E_WARNING, "signature OK, but cannot open %s for writing", signersfilename); in PHP_FUNCTION()
5299 zval * zrecipcerts, * zheaders = NULL; in PHP_FUNCTION()
5300 STACK_OF(X509) * recipcerts = NULL; in PHP_FUNCTION()
5301 BIO * infile = NULL, * outfile = NULL; in PHP_FUNCTION()
5303 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5306 const EVP_CIPHER *cipher = NULL; in PHP_FUNCTION()
5309 char * infilename = NULL; in PHP_FUNCTION()
5311 char * outfilename = NULL; in PHP_FUNCTION()
5326 if (infile == NULL) { in PHP_FUNCTION()
5332 if (outfile == NULL) { in PHP_FUNCTION()
5345 if (cert == NULL) { in PHP_FUNCTION()
5349 if (certresource != NULL) { in PHP_FUNCTION()
5353 if (cert == NULL) { in PHP_FUNCTION()
5365 if (cert == NULL) { in PHP_FUNCTION()
5369 if (certresource != NULL) { in PHP_FUNCTION()
5373 if (cert == NULL) { in PHP_FUNCTION()
5383 if (cipher == NULL) { in PHP_FUNCTION()
5385 php_error_docref(NULL, E_WARNING, "Failed to get cipher"); in PHP_FUNCTION()
5391 if (p7 == NULL) { in PHP_FUNCTION()
5436 zval * zout = NULL, zcert; in PHP_FUNCTION()
5439 STACK_OF(X509) *certs = NULL; in PHP_FUNCTION()
5440 STACK_OF(X509_CRL) *crls = NULL; in PHP_FUNCTION()
5441 BIO * bio_in = NULL, * bio_out = NULL; in PHP_FUNCTION()
5442 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5455 if (bio_in == NULL) { in PHP_FUNCTION()
5464 p7 = PEM_read_bio_PKCS7(bio_in, NULL, NULL, NULL); in PHP_FUNCTION()
5465 if (p7 == NULL) { in PHP_FUNCTION()
5472 if (p7->d.sign != NULL) { in PHP_FUNCTION()
5478 if (p7->d.signed_and_enveloped != NULL) { in PHP_FUNCTION()
5492 if (certs != NULL) { in PHP_FUNCTION()
5507 if (crls != NULL) { in PHP_FUNCTION()
5525 if (bio_in != NULL) { in PHP_FUNCTION()
5529 if (p7 != NULL) { in PHP_FUNCTION()
5542 X509 * cert = NULL; in PHP_FUNCTION()
5543 EVP_PKEY * privkey = NULL; in PHP_FUNCTION()
5545 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5546 BIO * infile = NULL, * outfile = NULL; in PHP_FUNCTION()
5547 STACK_OF(X509) *others = NULL; in PHP_FUNCTION()
5548 zend_resource *certresource = NULL, *keyresource = NULL; in PHP_FUNCTION()
5554 char * extracertsfilename = NULL; in PHP_FUNCTION()
5568 if (others == NULL) { in PHP_FUNCTION()
5574 if (privkey == NULL) { in PHP_FUNCTION()
5575 php_error_docref(NULL, E_WARNING, "error getting private key"); in PHP_FUNCTION()
5580 if (cert == NULL) { in PHP_FUNCTION()
5581 php_error_docref(NULL, E_WARNING, "error getting cert"); in PHP_FUNCTION()
5590 if (infile == NULL) { in PHP_FUNCTION()
5592 php_error_docref(NULL, E_WARNING, "error opening input file %s!", infilename); in PHP_FUNCTION()
5597 if (outfile == NULL) { in PHP_FUNCTION()
5599 php_error_docref(NULL, E_WARNING, "error opening output file %s!", outfilename); in PHP_FUNCTION()
5604 if (p7 == NULL) { in PHP_FUNCTION()
5606 php_error_docref(NULL, E_WARNING, "error creating PKCS7 structure!"); in PHP_FUNCTION()
5647 if (privkey && keyresource == NULL) { in PHP_FUNCTION()
5650 if (cert && certresource == NULL) { in PHP_FUNCTION()
5661 zval * recipcert, * recipkey = NULL; in PHP_FUNCTION()
5662 X509 * cert = NULL; in PHP_FUNCTION()
5663 EVP_PKEY * key = NULL; in PHP_FUNCTION()
5665 BIO * in = NULL, * out = NULL, * datain = NULL; in PHP_FUNCTION()
5666 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5680 if (cert == NULL) { in PHP_FUNCTION()
5681 php_error_docref(NULL, E_WARNING, "unable to coerce parameter 3 to x509 cert"); in PHP_FUNCTION()
5686 if (key == NULL) { in PHP_FUNCTION()
5687 php_error_docref(NULL, E_WARNING, "unable to get private key"); in PHP_FUNCTION()
5696 if (in == NULL) { in PHP_FUNCTION()
5701 if (out == NULL) { in PHP_FUNCTION()
5708 if (p7 == NULL) { in PHP_FUNCTION()
5722 if (cert && certresval == NULL) { in PHP_FUNCTION()
5725 if (key && keyresval == NULL) { in PHP_FUNCTION()
5740 zend_string *cryptedbuf = NULL; in PHP_FUNCTION()
5742 zend_resource *keyresource = NULL; in PHP_FUNCTION()
5754 if (pkey == NULL) { in PHP_FUNCTION()
5755 php_error_docref(NULL, E_WARNING, "key param is not a valid private key"); in PHP_FUNCTION()
5774 php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!"); in PHP_FUNCTION()
5780 cryptedbuf = NULL; in PHP_FUNCTION()
5788 if (keyresource == NULL) { in PHP_FUNCTION()
5801 zend_string *cryptedbuf = NULL; in PHP_FUNCTION()
5805 zend_resource *keyresource = NULL; in PHP_FUNCTION()
5815 if (pkey == NULL) { in PHP_FUNCTION()
5816 php_error_docref(NULL, E_WARNING, "key parameter is not a valid private key"); in PHP_FUNCTION()
5840 php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!"); in PHP_FUNCTION()
5848 cryptedbuf = NULL; in PHP_FUNCTION()
5854 if (keyresource == NULL) { in PHP_FUNCTION()
5872 zend_resource *keyresource = NULL; in PHP_FUNCTION()
5881 pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, 0, &keyresource); in PHP_FUNCTION()
5882 if (pkey == NULL) { in PHP_FUNCTION()
5883 php_error_docref(NULL, E_WARNING, "key parameter is not a valid public key"); in PHP_FUNCTION()
5902 php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!"); in PHP_FUNCTION()
5909 cryptedbuf = NULL; in PHP_FUNCTION()
5914 if (keyresource == NULL) { in PHP_FUNCTION()
5930 zend_string *cryptedbuf = NULL; in PHP_FUNCTION()
5933 zend_resource *keyresource = NULL; in PHP_FUNCTION()
5943 pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, 0, &keyresource); in PHP_FUNCTION()
5944 if (pkey == NULL) { in PHP_FUNCTION()
5945 php_error_docref(NULL, E_WARNING, "key parameter is not a valid public key"); in PHP_FUNCTION()
5970 php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!"); in PHP_FUNCTION()
5979 cryptedbuf = NULL; in PHP_FUNCTION()
5988 if (keyresource == NULL) { in PHP_FUNCTION()
6007 if (OPENSSL_G(errors) == NULL || OPENSSL_G(errors)->top == OPENSSL_G(errors)->bottom) { in PHP_FUNCTION()
6031 zend_resource *keyresource = NULL; in PHP_FUNCTION()
6035 zval *method = NULL; in PHP_FUNCTION()
6043 if (pkey == NULL) { in PHP_FUNCTION()
6044 php_error_docref(NULL, E_WARNING, "supplied key param cannot be coerced into a private key"); in PHP_FUNCTION()
6048 if (method == NULL || Z_TYPE_P(method) == IS_LONG) { in PHP_FUNCTION()
6049 if (method != NULL) { in PHP_FUNCTION()
6056 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm."); in PHP_FUNCTION()
6060 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm."); in PHP_FUNCTION()
6068 if (md_ctx != NULL && in PHP_FUNCTION()
6082 if (keyresource == NULL) { in PHP_FUNCTION()
6097 zend_resource *keyresource = NULL; in PHP_FUNCTION()
6102 zval *method = NULL; in PHP_FUNCTION()
6111 if (method == NULL || Z_TYPE_P(method) == IS_LONG) { in PHP_FUNCTION()
6112 if (method != NULL) { in PHP_FUNCTION()
6119 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm."); in PHP_FUNCTION()
6123 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm."); in PHP_FUNCTION()
6127 pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, 0, &keyresource); in PHP_FUNCTION()
6128 if (pkey == NULL) { in PHP_FUNCTION()
6129 php_error_docref(NULL, E_WARNING, "supplied key param cannot be coerced into a public key"); in PHP_FUNCTION()
6134 if (md_ctx == NULL || in PHP_FUNCTION()
6142 if (keyresource == NULL) { in PHP_FUNCTION()
6153 zval *pubkeys, *pubkey, *sealdata, *ekeys, *iv = NULL; in PHP_FUNCTION()
6158 unsigned char iv_buf[EVP_MAX_IV_LENGTH + 1], *buf = NULL, **eks; in PHP_FUNCTION()
6161 char *method =NULL; in PHP_FUNCTION()
6173 php_error_docref(NULL, E_WARNING, "Fourth argument to openssl_seal() must be a non-empty array"); in PHP_FUNCTION()
6182 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm."); in PHP_FUNCTION()
6191 php_error_docref(NULL, E_WARNING, in PHP_FUNCTION()
6207 pkeys[i] = php_openssl_evp_from_zval(pubkey, 1, NULL, 0, 0, &key_resources[i]); in PHP_FUNCTION()
6208 if (pkeys[i] == NULL) { in PHP_FUNCTION()
6209 php_error_docref(NULL, E_WARNING, "not a public key (%dth member of pubkeys)", i+1); in PHP_FUNCTION()
6218 if (ctx == NULL || !EVP_EncryptInit(ctx,cipher,NULL,NULL)) { in PHP_FUNCTION()
6253 eks[i] = NULL; in PHP_FUNCTION()
6268 if (key_resources[i] == NULL && pkeys[i] != NULL) { in PHP_FUNCTION()
6290 zend_resource *keyresource = NULL; in PHP_FUNCTION()
6296 char *method = NULL, *iv = NULL; in PHP_FUNCTION()
6306 if (pkey == NULL) { in PHP_FUNCTION()
6307 php_error_docref(NULL, E_WARNING, "unable to coerce parameter 4 into a private key"); in PHP_FUNCTION()
6317 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm."); in PHP_FUNCTION()
6327 php_error_docref(NULL, E_WARNING, in PHP_FUNCTION()
6332 php_error_docref(NULL, E_WARNING, "IV length is invalid"); in PHP_FUNCTION()
6337 iv_buf = NULL; in PHP_FUNCTION()
6343 if (ctx != NULL && EVP_OpenInit(ctx, cipher, (unsigned char *)ekey, (int)ekey_len, iv_buf, pkey) && in PHP_FUNCTION()
6355 if (keyresource == NULL) { in PHP_FUNCTION()
6413 EC_builtin_curve *curves = NULL; in PHP_FUNCTION()
6416 size_t len = EC_get_builtin_curves(NULL, 0); in PHP_FUNCTION()
6426 if (sname != NULL) { in PHP_FUNCTION()
6452 php_error_docref(NULL, E_WARNING, "Unknown signature algorithm"); in PHP_FUNCTION()
6548 if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) != 1) { in php_openssl_validate_iv()
6549 php_error_docref(NULL, E_WARNING, "Setting of IV length for AEAD mode failed"); in php_openssl_validate_iv()
6572 php_error_docref(NULL, E_WARNING, in php_openssl_validate_iv()
6582 php_error_docref(NULL, E_WARNING, in php_openssl_validate_iv()
6608 php_error_docref(NULL, E_WARNING, in php_openssl_cipher_init()
6612 if (!EVP_CipherInit_ex(cipher_ctx, cipher_type, NULL, NULL, NULL, enc)) { in php_openssl_cipher_init()
6620 if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) { in php_openssl_cipher_init()
6621 php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed"); in php_openssl_cipher_init()
6627 …php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher method does not suppo… in php_openssl_cipher_init()
6629 php_error_docref(NULL, E_WARNING, "Setting tag for AEAD cipher decryption failed"); in php_openssl_cipher_init()
6639 php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher method"); in php_openssl_cipher_init()
6655 if (!EVP_CipherInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)*piv, enc)) { in php_openssl_cipher_init()
6674 if (mode->is_single_run_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, NULL, (int)data_len)) { in php_openssl_cipher_update()
6676 php_error_docref(NULL, E_WARNING, "Setting of data length failed"); in php_openssl_cipher_update()
6680 if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (unsigned char *)aad, (int)aad_len)) { in php_openssl_cipher_update()
6682 php_error_docref(NULL, E_WARNING, "Setting of additional application data failed"); in php_openssl_cipher_update()
6716 zend_string *outbuf = NULL; in php_openssl_encrypt()
6726 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in php_openssl_encrypt()
6727 return NULL; in php_openssl_encrypt()
6732 php_error_docref(NULL, E_WARNING, "Failed to create cipher context"); in php_openssl_encrypt()
6733 return NULL; in php_openssl_encrypt()
6740 &iv, &iv_len, &free_iv, NULL, tag_len, options, 1) == FAILURE || in php_openssl_encrypt()
6743 outbuf = NULL; in php_openssl_encrypt()
6764 php_error_docref(NULL, E_WARNING, "Retrieving verification tag failed"); in php_openssl_encrypt()
6767 outbuf = NULL; in php_openssl_encrypt()
6772 php_error_docref(NULL, E_WARNING, "A tag should be provided when using AEAD mode"); in php_openssl_encrypt()
6774 outbuf = NULL; in php_openssl_encrypt()
6779 outbuf = NULL; in php_openssl_encrypt()
6801 zval *tag = NULL; in PHP_FUNCTION()
6822 zend_string *base64_str = NULL; in php_openssl_decrypt()
6824 zend_string *outbuf = NULL; in php_openssl_decrypt()
6834 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in php_openssl_decrypt()
6835 return NULL; in php_openssl_decrypt()
6840 php_error_docref(NULL, E_WARNING, "Failed to create cipher context"); in php_openssl_decrypt()
6841 return NULL; in php_openssl_decrypt()
6849 php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input"); in php_openssl_decrypt()
6851 return NULL; in php_openssl_decrypt()
6862 outbuf = NULL; in php_openssl_decrypt()
6871 outbuf = NULL; in php_openssl_decrypt()
6893 char *data, *method, *password, *iv = "", *tag = NULL, *aad = ""; in PHP_FUNCTION()
6903 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in PHP_FUNCTION()
6921 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in php_openssl_cipher_iv_length()
6940 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in PHP_FUNCTION()
6955 zend_string *buffer = NULL; in php_openssl_random_pseudo_bytes()
6962 return NULL; in php_openssl_random_pseudo_bytes()
6971 return NULL; in php_openssl_random_pseudo_bytes()
6981 return NULL; in php_openssl_random_pseudo_bytes()
6993 zend_string *buffer = NULL; in PHP_FUNCTION()
6995 zval *zstrong_result_returned = NULL; in PHP_FUNCTION()