Lines Matching refs:NULL

161 …zend_throw_error(NULL, "Cannot directly construct OpenSSLCertificate, use openssl_x509_read() inst…  in php_openssl_certificate_get_constructor()
162 return NULL; in php_openssl_certificate_get_constructor()
201 …zend_throw_error(NULL, "Cannot directly construct OpenSSLCertificateSigningRequest, use openssl_cs… in php_openssl_request_get_constructor()
202 return NULL; in php_openssl_request_get_constructor()
249 …zend_throw_error(NULL, "Cannot directly construct OpenSSLAsymmetricKey, use openssl_pkey_new() ins… in php_openssl_pkey_get_constructor()
250 return NULL; in php_openssl_pkey_get_constructor()
268 NULL,
269 NULL,
275 NULL,
438 return NULL; \
494 php_verror(NULL, arg_name, type, format, va); in php_openssl_check_path_error()
506 const char *error_msg = NULL; in php_openssl_check_path_ex()
529 } else if (expand_filepath(fs_file_path, real_path) == NULL) { in php_openssl_check_path_ex()
533 if (error_msg != NULL) { in php_openssl_check_path_ex()
537 php_error_docref(NULL, E_WARNING, "Path for %s %s %s", in php_openssl_check_path_ex()
539 } else if (is_from_array && option_name != NULL) { in php_openssl_check_path_ex()
544 } else if (option_name != NULL) { in php_openssl_check_path_ex()
620 ASN1_STRING * str = NULL; in php_openssl_add_assoc_name_entry()
623 if (key != NULL) { in php_openssl_add_assoc_name_entry()
630 const unsigned char *to_add = NULL; in php_openssl_add_assoc_name_entry()
632 unsigned char *to_add_buf = NULL; in php_openssl_add_assoc_name_entry()
656 if ((data = zend_hash_str_find(Z_ARRVAL(subitem), sname, strlen(sname))) != NULL) { in php_openssl_add_assoc_name_entry()
675 if (to_add_buf != NULL) { in php_openssl_add_assoc_name_entry()
680 if (key != NULL) { in php_openssl_add_assoc_name_entry()
709 php_error_docref(NULL, E_WARNING, "Illegal ASN1 data type for timestamp"); in php_openssl_asn1_time_to_time_t()
716 php_error_docref(NULL, E_WARNING, "Illegal length in timestamp"); in php_openssl_asn1_time_to_time_t()
721 php_error_docref(NULL, E_WARNING, "Unable to parse time string %s correctly", timestr->data); in php_openssl_asn1_time_to_time_t()
726 php_error_docref(NULL, E_WARNING, "Unable to parse time string %s correctly", timestr->data); in php_openssl_asn1_time_to_time_t()
797 if (!X509V3_EXT_add_nconf(config, &ctx, (char *)section, NULL)) { in php_openssl_config_check_syntax()
799 php_error_docref(NULL, E_WARNING, "Error loading %s section %s of %s", in php_openssl_config_check_syntax()
834 str = php_openssl_conf_get_string(req->req_config, NULL, "oid_section"); in php_openssl_add_oid_section()
835 if (str == NULL) { in php_openssl_add_oid_section()
839 if (sktmp == NULL) { in php_openssl_add_oid_section()
841 php_error_docref(NULL, E_WARNING, "Problem loading oid section %s", str); in php_openssl_add_oid_section()
849 php_error_docref(NULL, E_WARNING, "Problem creating object %s=%s", cnf->name, cnf->value); in php_openssl_add_oid_section()
866 …m = zend_hash_str_find(Z_ARRVAL_P(optional_args), key, sizeof(key)-1)) != NULL && Z_TYPE_P(item) =…
870 if (varname == NULL) { \
877 …m = zend_hash_str_find(Z_ARRVAL_P(optional_args), key, sizeof(key)-1)) != NULL && Z_TYPE_P(item) =…
909 req->global_config = NCONF_new(NULL); in php_openssl_parse_config()
910 if (!NCONF_load(req->global_config, default_ssl_conf_filename, NULL)) { in php_openssl_parse_config()
914 req->req_config = NCONF_new(NULL); in php_openssl_parse_config()
915 if (!NCONF_load(req->req_config, req->config_filename, NULL)) { in php_openssl_parse_config()
920 str = php_openssl_conf_get_string(req->req_config, NULL, "oid_file"); in php_openssl_parse_config()
921 …if (str != NULL && php_openssl_check_path_ex(str, strlen(str), path, 0, false, false, "oid_file"))… in php_openssl_parse_config()
942 …= zend_hash_str_find(Z_ARRVAL_P(optional_args), "encrypt_key", sizeof("encrypt_key")-1)) != NULL) { in php_openssl_parse_config()
946 if (str == NULL) { in php_openssl_parse_config()
949 if (str != NULL && strcmp(str, "no") == 0) { in php_openssl_parse_config()
958 …r_find(Z_ARRVAL_P(optional_args), "encrypt_key_cipher", sizeof("encrypt_key_cipher")-1)) != NULL && in php_openssl_parse_config()
963 if (cipher == NULL) { in php_openssl_parse_config()
964 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm for private key"); in php_openssl_parse_config()
970 req->priv_key_encrypt_cipher = NULL; in php_openssl_parse_config()
974 if (req->digest_name == NULL) { in php_openssl_parse_config()
977 if (req->digest_name != NULL) { in php_openssl_parse_config()
980 if (req->md_alg == NULL) { in php_openssl_parse_config()
989 …item = zend_hash_str_find(Z_ARRVAL_P(optional_args), "curve_name", sizeof("curve_name")-1)) != NULL in php_openssl_parse_config()
993 php_error_docref(NULL, E_WARNING, "Unknown elliptic curve (short) name %s", Z_STRVAL_P(item)); in php_openssl_parse_config()
1001 if (str != NULL && !ASN1_STRING_set_default_mask_asc(str)) { in php_openssl_parse_config()
1002 php_error_docref(NULL, E_WARNING, "Invalid global string mask setting %s", str); in php_openssl_parse_config()
1016 req->priv_key = NULL; in php_openssl_dispose_config()
1020 req->global_config = NULL; in php_openssl_dispose_config()
1024 req->req_config = NULL; in php_openssl_dispose_config()
1038 gettimeofday(&tv, NULL); in php_openssl_rand_add_timeval()
1052 if (file == NULL) { in php_openssl_load_rand_file()
1062 if (file == NULL || !RAND_load_file(file, -1)) { in php_openssl_load_rand_file()
1065 php_error_docref(NULL, E_WARNING, "Unable to load random state; not enough random data!"); in php_openssl_load_rand_file()
1085 if (file == NULL) { in php_openssl_write_rand_file()
1089 if (file == NULL || !RAND_write_file(file)) { in php_openssl_write_rand_file()
1091 php_error_docref(NULL, E_WARNING, "Unable to write random state"); in php_openssl_write_rand_file()
1141 return NULL; in php_openssl_get_evp_md_from_algo()
1185 return NULL; in php_openssl_get_evp_cipher_from_algo()
1193 PHP_INI_ENTRY("openssl.cafile", NULL, PHP_INI_PERDIR, NULL)
1194 PHP_INI_ENTRY("openssl.capath", NULL, PHP_INI_PERDIR, NULL)
1210 php_openssl_certificate_object_handlers.clone_obj = NULL; in PHP_INI_END()
1220 php_openssl_request_object_handlers.clone_obj = NULL; in PHP_INI_END()
1230 php_openssl_pkey_object_handlers.clone_obj = NULL; in PHP_INI_END()
1234 OPENSSL_config(NULL); in PHP_INI_END()
1241 OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL); in PHP_INI_END()
1246 ssl_stream_data_index = SSL_get_ex_new_index(0, "PHP stream index", NULL, NULL, NULL); in PHP_INI_END()
1252 if (config_filename == NULL) { in PHP_INI_END()
1257 if (config_filename == NULL) { in PHP_INI_END()
1295 openssl_globals->errors = NULL; in PHP_GINIT_FUNCTION()
1328 CRYPTO_set_locking_callback(NULL); in PHP_MSHUTDOWN_FUNCTION()
1390 X509 *cert = NULL; in php_openssl_x509_from_str()
1396 return NULL; in php_openssl_x509_from_str()
1400 if (in == NULL) { in php_openssl_x509_from_str()
1402 return NULL; in php_openssl_x509_from_str()
1404 cert = PEM_read_bio_X509(in, NULL, NULL, NULL); in php_openssl_x509_from_str()
1407 if (in == NULL) { in php_openssl_x509_from_str()
1409 return NULL; in php_openssl_x509_from_str()
1412 cert = (X509 *) PEM_ASN1_read_bio((d2i_of_void *)d2i_X509, PEM_STRING_X509, in, NULL, NULL, NULL); in php_openssl_x509_from_str()
1414 cert = (X509 *) PEM_ASN1_read_bio((char *(*)())d2i_X509, PEM_STRING_X509, in, NULL, NULL, NULL); in php_openssl_x509_from_str()
1422 if (cert == NULL) { in php_openssl_x509_from_str()
1424 return NULL; in php_openssl_x509_from_str()
1445 return php_openssl_x509_from_str(cert_str, arg_num, false, NULL); in php_openssl_x509_from_param()
1461 return NULL; in php_openssl_x509_from_zval()
1490 if (cert == NULL) { in PHP_FUNCTION()
1491 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
1511 php_error_docref(NULL, E_WARNING, "Error opening file %s", file_path); in PHP_FUNCTION()
1529 char * challenge = NULL, *spkstr = NULL; in PHP_FUNCTION()
1530 zend_string * s = NULL; in PHP_FUNCTION()
1534 zval *zpkey = NULL; in PHP_FUNCTION()
1535 EVP_PKEY *pkey = NULL; in PHP_FUNCTION()
1536 NETSCAPE_SPKI *spki=NULL; in PHP_FUNCTION()
1547 if (pkey == NULL) { in PHP_FUNCTION()
1549 php_error_docref(NULL, E_WARNING, "Unable to use supplied private key"); in PHP_FUNCTION()
1557 php_error_docref(NULL, E_WARNING, "Unknown digest algorithm"); in PHP_FUNCTION()
1561 if ((spki = NETSCAPE_SPKI_new()) == NULL) { in PHP_FUNCTION()
1563 php_error_docref(NULL, E_WARNING, "Unable to create new SPKAC"); in PHP_FUNCTION()
1570 php_error_docref(NULL, E_WARNING, "Unable to set challenge data"); in PHP_FUNCTION()
1577 php_error_docref(NULL, E_WARNING, "Unable to embed public key"); in PHP_FUNCTION()
1583 php_error_docref(NULL, E_WARNING, "Unable to sign with specified digest algorithm"); in PHP_FUNCTION()
1590 php_error_docref(NULL, E_WARNING, "Unable to encode SPKAC"); in PHP_FUNCTION()
1604 if (spki != NULL) { in PHP_FUNCTION()
1619 char *spkstr, * spkstr_cleaned = NULL; in PHP_FUNCTION()
1621 EVP_PKEY *pkey = NULL; in PHP_FUNCTION()
1622 NETSCAPE_SPKI *spki = NULL; in PHP_FUNCTION()
1633 php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); in PHP_FUNCTION()
1638 if (spki == NULL) { in PHP_FUNCTION()
1640 php_error_docref(NULL, E_WARNING, "Unable to decode supplied SPKAC"); in PHP_FUNCTION()
1645 if (pkey == NULL) { in PHP_FUNCTION()
1647 php_error_docref(NULL, E_WARNING, "Unable to acquire signed public key"); in PHP_FUNCTION()
1655 if (spki != NULL) { in PHP_FUNCTION()
1659 if (spkstr_cleaned != NULL) { in PHP_FUNCTION()
1675 char *spkstr, * spkstr_cleaned = NULL, * s = NULL; in PHP_FUNCTION()
1678 EVP_PKEY *pkey = NULL; in PHP_FUNCTION()
1679 NETSCAPE_SPKI *spki = NULL; in PHP_FUNCTION()
1680 BIO *out = NULL; in PHP_FUNCTION()
1691 php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); in PHP_FUNCTION()
1696 if (spki == NULL) { in PHP_FUNCTION()
1698 php_error_docref(NULL, E_WARNING, "Unable to decode supplied SPKAC"); in PHP_FUNCTION()
1703 if (pkey == NULL) { in PHP_FUNCTION()
1705 php_error_docref(NULL, E_WARNING, "Unable to acquire signed public key"); in PHP_FUNCTION()
1722 if (spki != NULL) { in PHP_FUNCTION()
1727 if (spkstr_cleaned != NULL) { in PHP_FUNCTION()
1730 if (s != NULL) { in PHP_FUNCTION()
1740 char *spkstr, * spkstr_cleaned = NULL; in PHP_FUNCTION()
1743 NETSCAPE_SPKI *spki = NULL; in PHP_FUNCTION()
1754 php_error_docref(NULL, E_WARNING, "Invalid SPKAC"); in PHP_FUNCTION()
1759 if (spki == NULL) { in PHP_FUNCTION()
1761 php_error_docref(NULL, E_WARNING, "Unable to decode SPKAC"); in PHP_FUNCTION()
1769 if (spkstr_cleaned != NULL) { in PHP_FUNCTION()
1798 if (cert == NULL) { in PHP_FUNCTION()
1799 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
1839 php_error_docref(NULL, E_WARNING, "Unknown digest algorithm"); in php_openssl_x509_fingerprint()
1840 return NULL; in php_openssl_x509_fingerprint()
1843 php_error_docref(NULL, E_ERROR, "Could not generate signature"); in php_openssl_x509_fingerprint()
1844 return NULL; in php_openssl_x509_fingerprint()
1876 if (cert == NULL) { in PHP_FUNCTION()
1877 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
1900 EVP_PKEY * key = NULL; in PHP_FUNCTION()
1908 if (cert == NULL) { in PHP_FUNCTION()
1933 EVP_PKEY * key = NULL; in PHP_FUNCTION()
1942 if (cert == NULL) { in PHP_FUNCTION()
1946 key = php_openssl_pkey_from_zval(zkey, 1, NULL, 0, 2); in PHP_FUNCTION()
1947 if (key != NULL) { in PHP_FUNCTION()
1971 const X509V3_EXT_METHOD *method = NULL; in openssl_x509v3_subjectAltName()
1977 if (method == NULL) { in openssl_x509v3_subjectAltName()
1985 names = (GENERAL_NAMES*) (ASN1_item_d2i(NULL, &p, length, in openssl_x509v3_subjectAltName()
1988 names = (GENERAL_NAMES*) (method->d2i(NULL, &p, length)); in openssl_x509v3_subjectAltName()
1990 if (names == NULL) { in openssl_x509v3_subjectAltName()
2064 if (cert == NULL) { in PHP_FUNCTION()
2071 cert_name = X509_NAME_oneline(subject_name, NULL, 0); in PHP_FUNCTION()
2088 bn_serial = ASN1_INTEGER_to_BN(asn1_serial, NULL); in PHP_FUNCTION()
2103 str_serial = i2s_ASN1_INTEGER(NULL, asn1_serial); in PHP_FUNCTION()
2117 tmpstr = (char *)X509_alias_get0(cert, NULL); in PHP_FUNCTION()
2170 if (bio_out == NULL) { in PHP_FUNCTION()
2206 STACK_OF(X509_INFO) *sk=NULL; in STACK_OF()
2207 STACK_OF(X509) *stack=NULL, *ret=NULL; in STACK_OF()
2208 BIO *in=NULL; in STACK_OF()
2214 php_error_docref(NULL, E_ERROR, "Memory allocation failure"); in STACK_OF()
2225 php_error_docref(NULL, E_WARNING, "Error opening the file, %s", cert_path); in STACK_OF()
2231 if (!(sk = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL))) { in STACK_OF()
2233 php_error_docref(NULL, E_WARNING, "Error reading the file, %s", cert_path); in STACK_OF()
2241 if (xi->x509 != NULL) { in STACK_OF()
2243 xi->x509=NULL; in STACK_OF()
2248 php_error_docref(NULL, E_WARNING, "No certificates in file, %s", cert_path); in STACK_OF()
2268 if (csc == NULL) { in check_cert()
2270 php_error_docref(NULL, E_ERROR, "Memory allocation failure"); in check_cert()
2275 php_error_docref(NULL, E_WARNING, "Certificate store initialization failed"); in check_cert()
2297 zval *zcainfo = NULL; in PHP_FUNCTION()
2298 X509_STORE *cainfo = NULL; in PHP_FUNCTION()
2299 STACK_OF(X509) *untrustedchain = NULL; in PHP_FUNCTION()
2301 char * untrusted = NULL; in PHP_FUNCTION()
2317 if (untrustedchain == NULL) { in PHP_FUNCTION()
2323 if (cainfo == NULL) { in PHP_FUNCTION()
2327 if (cert == NULL) { in PHP_FUNCTION()
2366 if (store == NULL) { in php_openssl_setup_verify()
2368 return NULL; in php_openssl_setup_verify()
2375 return NULL; in php_openssl_setup_verify()
2378 if (!php_openssl_check_path_str_ex(str, file_path, arg_num, false, true, NULL)) { in php_openssl_setup_verify()
2385 php_error_docref(NULL, E_WARNING, "Unable to stat %s", file_path); in php_openssl_setup_verify()
2391 if (file_lookup == NULL || !X509_LOOKUP_load_file(file_lookup, file_path, X509_FILETYPE_PEM)) { in php_openssl_setup_verify()
2393 php_error_docref(NULL, E_WARNING, "Error loading file %s", file_path); in php_openssl_setup_verify()
2397 file_lookup = NULL; in php_openssl_setup_verify()
2400 if (dir_lookup == NULL || !X509_LOOKUP_add_dir(dir_lookup, file_path, X509_FILETYPE_PEM)) { in php_openssl_setup_verify()
2402 php_error_docref(NULL, E_WARNING, "Error loading directory %s", file_path); in php_openssl_setup_verify()
2406 dir_lookup = NULL; in php_openssl_setup_verify()
2412 if (file_lookup == NULL || !X509_LOOKUP_load_file(file_lookup, NULL, X509_FILETYPE_DEFAULT)) { in php_openssl_setup_verify()
2418 if (dir_lookup == NULL || !X509_LOOKUP_add_dir(dir_lookup, NULL, X509_FILETYPE_DEFAULT)) { in php_openssl_setup_verify()
2439 if (cert == NULL) { in PHP_FUNCTION()
2440 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
2478 STACK_OF(X509) * sk = NULL; in STACK_OF()
2488 if (cert == NULL) { in STACK_OF()
2496 if (cert == NULL) { in STACK_OF()
2508 if (cert == NULL) { in STACK_OF()
2515 if (cert == NULL) { in STACK_OF()
2534 BIO * bio_out = NULL; in PHP_FUNCTION()
2535 PKCS12 * p12 = NULL; in PHP_FUNCTION()
2537 char * friendly_name = NULL; in PHP_FUNCTION()
2541 zval *zpkey = NULL, *args = NULL; in PHP_FUNCTION()
2542 EVP_PKEY *priv_key = NULL; in PHP_FUNCTION()
2544 STACK_OF(X509) *ca = NULL; in PHP_FUNCTION()
2558 if (cert == NULL) { in PHP_FUNCTION()
2559 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
2564 if (priv_key == NULL) { in PHP_FUNCTION()
2566 php_error_docref(NULL, E_WARNING, "Cannot get private key from parameter 3"); in PHP_FUNCTION()
2572 php_error_docref(NULL, E_WARNING, "Private key does not correspond to cert"); in PHP_FUNCTION()
2581 …(item = zend_hash_str_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name")-1)) != NULL in PHP_FUNCTION()
2591 …s && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) { in PHP_FUNCTION()
2600 if (p12 != NULL) { in PHP_FUNCTION()
2602 if (bio_out != NULL) { in PHP_FUNCTION()
2605 php_error_docref(NULL, E_WARNING, "Error writing to file %s", file_path); in PHP_FUNCTION()
2612 php_error_docref(NULL, E_WARNING, "Error opening file %s", file_path); in PHP_FUNCTION()
2638 PKCS12 * p12 = NULL; in PHP_FUNCTION()
2639 zval *zout = NULL, *zpkey, *args = NULL; in PHP_FUNCTION()
2640 EVP_PKEY *priv_key = NULL; in PHP_FUNCTION()
2643 char * friendly_name = NULL; in PHP_FUNCTION()
2645 STACK_OF(X509) *ca = NULL; in PHP_FUNCTION()
2659 if (cert == NULL) { in PHP_FUNCTION()
2660 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
2665 if (priv_key == NULL) { in PHP_FUNCTION()
2667 php_error_docref(NULL, E_WARNING, "Cannot get private key from parameter 3"); in PHP_FUNCTION()
2672 php_error_docref(NULL, E_WARNING, "Private key does not correspond to cert"); in PHP_FUNCTION()
2678 …(item = zend_hash_str_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name")-1)) != NULL in PHP_FUNCTION()
2684 …s && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) { in PHP_FUNCTION()
2691 if (p12 != NULL) { in PHP_FUNCTION()
2722 zval *zout = NULL, zextracerts, zcert, zpkey; in PHP_FUNCTION()
2725 PKCS12 * p12 = NULL; in PHP_FUNCTION()
2726 EVP_PKEY * pkey = NULL; in PHP_FUNCTION()
2727 X509 * cert = NULL; in PHP_FUNCTION()
2728 STACK_OF(X509) * ca = NULL; in PHP_FUNCTION()
2729 BIO * bio_in = NULL; in PHP_FUNCTION()
2771 if (PEM_write_bio_PrivateKey(bio_out, pkey, NULL, NULL, 0, 0, NULL)) { in PHP_FUNCTION()
2829 STACK_OF(CONF_VALUE) * dn_sk, *attr_sk = NULL; in php_openssl_make_REQ()
2833 if (dn_sect == NULL) { in php_openssl_make_REQ()
2838 if (dn_sk == NULL) { in php_openssl_make_REQ()
2843 if (attr_sect == NULL) { in php_openssl_make_REQ()
2844 attr_sk = NULL; in php_openssl_make_REQ()
2847 if (attr_sk == NULL) { in php_openssl_make_REQ()
2859 zend_string * strindex = NULL; in php_openssl_make_REQ()
2875 php_error_docref(NULL, E_WARNING, in php_openssl_make_REQ()
2885 php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", ZSTR_VAL(strindex)); in php_openssl_make_REQ()
2931 php_error_docref(NULL, E_WARNING, "add_entry_by_txt %s -> %s (failed)", type, v->value); in php_openssl_make_REQ()
2935 php_error_docref(NULL, E_WARNING, "No objects specified in config file"); in php_openssl_make_REQ()
2943 if (NULL == strindex) { in php_openssl_make_REQ()
2944 php_error_docref(NULL, E_WARNING, "dn: numeric fild names are not supported"); in php_openssl_make_REQ()
2956 …php_error_docref(NULL, E_WARNING, "attribs: add_entry_by_NID %d -> %s (failed)", nid, ZSTR_VAL(str… in php_openssl_make_REQ()
2962 php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", ZSTR_VAL(strindex)); in php_openssl_make_REQ()
2974 php_error_docref(NULL, E_WARNING, in php_openssl_make_REQ()
2997 X509_REQ * csr = NULL; in php_openssl_csr_from_str()
3003 return NULL; in php_openssl_csr_from_str()
3010 if (in == NULL) { in php_openssl_csr_from_str()
3012 return NULL; in php_openssl_csr_from_str()
3015 csr = PEM_read_bio_X509_REQ(in, NULL,NULL,NULL); in php_openssl_csr_from_str()
3016 if (csr == NULL) { in php_openssl_csr_from_str()
3044 char * filename = NULL; in PHP_FUNCTION()
3059 if (csr == NULL) { in PHP_FUNCTION()
3060 php_error_docref(NULL, E_WARNING, "X.509 Certificate Signing Request cannot be retrieved"); in PHP_FUNCTION()
3069 if (bio_out != NULL) { in PHP_FUNCTION()
3074 php_error_docref(NULL, E_WARNING, "Error writing PEM to file %s", file_path); in PHP_FUNCTION()
3082 php_error_docref(NULL, E_WARNING, "Error opening file %s", file_path); in PHP_FUNCTION()
3111 if (csr == NULL) { in PHP_FUNCTION()
3112 php_error_docref(NULL, E_WARNING, "X.509 Certificate Signing Request cannot be retrieved"); in PHP_FUNCTION()
3151 zval *zpkey, *args = NULL; in PHP_FUNCTION()
3154 X509 *cert = NULL, *new_cert = NULL; in PHP_FUNCTION()
3155 EVP_PKEY * key = NULL, *priv_key = NULL; in PHP_FUNCTION()
3173 if (csr == NULL) { in PHP_FUNCTION()
3174 php_error_docref(NULL, E_WARNING, "X.509 Certificate Signing Request cannot be retrieved"); in PHP_FUNCTION()
3182 if (cert == NULL) { in PHP_FUNCTION()
3183 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
3189 if (priv_key == NULL) { in PHP_FUNCTION()
3191 php_error_docref(NULL, E_WARNING, "Cannot get private key from parameter 3"); in PHP_FUNCTION()
3197 php_error_docref(NULL, E_WARNING, "Private key does not correspond to signing cert"); in PHP_FUNCTION()
3206 if (key == NULL) { in PHP_FUNCTION()
3208 php_error_docref(NULL, E_WARNING, "Error unpacking public key"); in PHP_FUNCTION()
3215 php_error_docref(NULL, E_WARNING, "Signature verification problems"); in PHP_FUNCTION()
3219 php_error_docref(NULL, E_WARNING, "Signature did not match the certificate request"); in PHP_FUNCTION()
3226 if (new_cert == NULL) { in PHP_FUNCTION()
3228 php_error_docref(NULL, E_WARNING, "No memory"); in PHP_FUNCTION()
3244 if (cert == NULL) { in PHP_FUNCTION()
3261 X509V3_set_ctx(&ctx, cert, new_cert, csr, NULL, 0); in PHP_FUNCTION()
3272 php_error_docref(NULL, E_WARNING, "Failed to sign it"); in PHP_FUNCTION()
3304 zval *args = NULL, *dn, *attribs = NULL; in PHP_FUNCTION()
3306 X509_REQ *csr = NULL; in PHP_FUNCTION()
3322 req.priv_key = php_openssl_pkey_from_zval(out_pkey_val, 0, NULL, 0, 2); in PHP_FUNCTION()
3324 if (req.priv_key == NULL) { in PHP_FUNCTION()
3328 if (req.priv_key == NULL) { in PHP_FUNCTION()
3329 php_error_docref(NULL, E_WARNING, "Unable to generate a private key"); in PHP_FUNCTION()
3336 X509V3_set_ctx(&ext_ctx, NULL, NULL, csr, NULL, 0); in PHP_FUNCTION()
3344 …php_error_docref(NULL, E_WARNING, "Error loading extension section %s", req.request_extensions_sec… in PHP_FUNCTION()
3352 csr = NULL; in PHP_FUNCTION()
3355 php_error_docref(NULL, E_WARNING, "Error signing request"); in PHP_FUNCTION()
3364 req.priv_key = NULL; /* make sure the cleanup code doesn't zap it! */ in PHP_FUNCTION()
3397 if (csr == NULL) { in PHP_FUNCTION()
3404 php_openssl_add_assoc_name_entry(return_value, NULL, subject, use_shortnames); in PHP_FUNCTION()
3418 return NULL; in php_openssl_extract_public_key()
3421 EVP_PKEY *pub_key = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL); in php_openssl_extract_public_key()
3440 if (csr == NULL) { in PHP_FUNCTION()
3454 if (tpubkey == NULL) { in PHP_FUNCTION()
3477 if (password == NULL || password->key == NULL) { in php_openssl_pem_password_cb()
3491 EVP_PKEY *key = NULL; in php_openssl_pkey_from_zval()
3492 X509 *cert = NULL; in php_openssl_pkey_from_zval()
3503 return NULL; in php_openssl_pkey_from_zval()
3510 if ((zphrase = zend_hash_index_find(Z_ARRVAL_P(val), 1)) == NULL) { in php_openssl_pkey_from_zval()
3512 return NULL; in php_openssl_pkey_from_zval()
3521 return NULL; in php_openssl_pkey_from_zval()
3529 if ((val = zend_hash_index_find(Z_ARRVAL_P(val), 0)) == NULL) { in php_openssl_pkey_from_zval()
3542 php_error_docref(NULL, E_WARNING, "Supplied key param is a public key"); in php_openssl_pkey_from_zval()
3547 php_error_docref(NULL, E_WARNING, "Don't know how to get public key from this private key"); in php_openssl_pkey_from_zval()
3579 cert = php_openssl_x509_from_str(Z_STR_P(val), arg_num, false, NULL); in php_openssl_pkey_from_zval()
3591 if (in == NULL) { in php_openssl_pkey_from_zval()
3595 key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL); in php_openssl_pkey_from_zval()
3608 if (in == NULL) { in php_openssl_pkey_from_zval()
3611 if (passphrase == NULL) { in php_openssl_pkey_from_zval()
3612 key = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL); in php_openssl_pkey_from_zval()
3617 key = PEM_read_bio_PrivateKey(in, NULL, php_openssl_pem_password_cb, &password); in php_openssl_pkey_from_zval()
3623 if (key == NULL) { in php_openssl_pkey_from_zval()
3629 if (key == NULL) { in php_openssl_pkey_from_zval()
3671 php_error_docref(NULL, E_WARNING, "Private key length must be at least %d bits, configured to %d", in php_openssl_generate_private_key()
3673 return NULL; in php_openssl_generate_private_key()
3678 php_error_docref(NULL, E_WARNING, "Unsupported private key type"); in php_openssl_generate_private_key()
3679 return NULL; in php_openssl_generate_private_key()
3687 EVP_PKEY *key = NULL; in php_openssl_generate_private_key()
3688 EVP_PKEY *params = NULL; in php_openssl_generate_private_key()
3689 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(type, NULL); in php_openssl_generate_private_key()
3721 php_error_docref(NULL, E_WARNING, "Missing configuration value: \"curve_name\" not set"); in php_openssl_generate_private_key()
3741 ctx = EVP_PKEY_CTX_new(params, NULL); in php_openssl_generate_private_key()
3774 if (bn != NULL) { in php_openssl_add_bn_to_array()
3787 if ((bn = zend_hash_str_find(Z_ARRVAL_P(_data), #_name, sizeof(#_name)-1)) != NULL && \
3791 (int)Z_STRLEN_P(bn), NULL); \
3793 _name = NULL; \
3829 BIGNUM *n = NULL, *e = NULL, *d = NULL, *p = NULL, *q = NULL; in php_openssl_pkey_init_rsa()
3830 BIGNUM *dmp1 = NULL, *dmq1 = NULL, *iqmp = NULL; in php_openssl_pkey_init_rsa()
3831 EVP_PKEY *pkey = NULL; in php_openssl_pkey_init_rsa()
3832 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); in php_openssl_pkey_init_rsa()
3833 OSSL_PARAM *params = NULL; in php_openssl_pkey_init_rsa()
3898 return NULL; in php_openssl_pkey_init_rsa()
3905 return NULL; in php_openssl_pkey_init_rsa()
3913 return NULL; in php_openssl_pkey_init_rsa()
3935 *is_private = priv_key != NULL; in php_openssl_pkey_init_legacy_dsa()
3962 BIGNUM *p = NULL, *q = NULL, *g = NULL, *priv_key = NULL, *pub_key = NULL; in php_openssl_pkey_init_dsa()
3963 EVP_PKEY *param_key = NULL, *pkey = NULL; in php_openssl_pkey_init_dsa()
3964 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_DSA, NULL); in php_openssl_pkey_init_dsa()
3965 OSSL_PARAM *params = NULL; in php_openssl_pkey_init_dsa()
4002 *is_private = priv_key != NULL; in php_openssl_pkey_init_dsa()
4009 ctx = EVP_PKEY_CTX_new(param_key, NULL); in php_openssl_pkey_init_dsa()
4031 return NULL; in php_openssl_pkey_init_dsa()
4038 return NULL; in php_openssl_pkey_init_dsa()
4046 return NULL; in php_openssl_pkey_init_dsa()
4060 if (pub_key == NULL) { in php_openssl_dh_pub_from_priv()
4062 return NULL; in php_openssl_dh_pub_from_priv()
4066 if (priv_key_const_time == NULL) { in php_openssl_dh_pub_from_priv()
4069 return NULL; in php_openssl_dh_pub_from_priv()
4072 if (ctx == NULL) { in php_openssl_dh_pub_from_priv()
4076 return NULL; in php_openssl_dh_pub_from_priv()
4081 if (!BN_mod_exp_mont(pub_key, g, priv_key_const_time, p, ctx, NULL)) { in php_openssl_dh_pub_from_priv()
4084 pub_key = NULL; in php_openssl_dh_pub_from_priv()
4108 *is_private = priv_key != NULL; in php_openssl_pkey_init_legacy_dh()
4114 if (pub_key == NULL) { in php_openssl_pkey_init_legacy_dh()
4135 BIGNUM *p = NULL, *q = NULL, *g = NULL, *priv_key = NULL, *pub_key = NULL; in php_openssl_pkey_init_dh()
4136 EVP_PKEY *param_key = NULL, *pkey = NULL; in php_openssl_pkey_init_dh()
4137 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_DH, NULL); in php_openssl_pkey_init_dh()
4138 OSSL_PARAM *params = NULL; in php_openssl_pkey_init_dh()
4182 *is_private = priv_key != NULL; in php_openssl_pkey_init_dh()
4189 ctx = EVP_PKEY_CTX_new(param_key, NULL); in php_openssl_pkey_init_dh()
4211 return NULL; in php_openssl_pkey_init_dh()
4217 return NULL; in php_openssl_pkey_init_dh()
4225 return NULL; in php_openssl_pkey_init_dh()
4235 EC_GROUP *group = NULL; in php_openssl_pkey_init_legacy_ec()
4236 EC_POINT *pnt = NULL; in php_openssl_pkey_init_legacy_ec()
4237 BIGNUM *d = NULL; in php_openssl_pkey_init_legacy_ec()
4244 if ((bn = zend_hash_str_find(Z_ARRVAL_P(data), "curve_name", sizeof("curve_name") - 1)) != NULL && in php_openssl_pkey_init_legacy_ec()
4262 if (group == NULL) { in php_openssl_pkey_init_legacy_ec()
4263 php_error_docref(NULL, E_WARNING, "Unknown curve name"); in php_openssl_pkey_init_legacy_ec()
4268 if ((bn = zend_hash_str_find(Z_ARRVAL_P(data), "d", sizeof("d") - 1)) != NULL && in php_openssl_pkey_init_legacy_ec()
4271 d = BN_bin2bn((unsigned char*) Z_STRVAL_P(bn), Z_STRLEN_P(bn), NULL); in php_openssl_pkey_init_legacy_ec()
4279 if (!pnt || !EC_POINT_mul(group, pnt, d, NULL, NULL, NULL)) { in php_openssl_pkey_init_legacy_ec()
4285 } else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL && in php_openssl_pkey_init_legacy_ec()
4287 (y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL && in php_openssl_pkey_init_legacy_ec()
4290 if (pnt == NULL) { in php_openssl_pkey_init_legacy_ec()
4295 group, pnt, BN_bin2bn((unsigned char*) Z_STRVAL_P(x), Z_STRLEN_P(x), NULL), in php_openssl_pkey_init_legacy_ec()
4296 BN_bin2bn((unsigned char*) Z_STRVAL_P(y), Z_STRLEN_P(y), NULL), NULL)) { in php_openssl_pkey_init_legacy_ec()
4302 if (pnt != NULL) { in php_openssl_pkey_init_legacy_ec()
4308 pnt = NULL; in php_openssl_pkey_init_legacy_ec()
4334 BIGNUM *d = NULL, *x = NULL, *y = NULL; in php_openssl_pkey_init_ec()
4335 EC_GROUP *group = NULL; in php_openssl_pkey_init_ec()
4336 EC_POINT *pnt = NULL; in php_openssl_pkey_init_ec()
4337 unsigned char *pnt_oct = NULL; in php_openssl_pkey_init_ec()
4338 EVP_PKEY *param_key = NULL, *pkey = NULL; in php_openssl_pkey_init_ec()
4339 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL); in php_openssl_pkey_init_ec()
4340 OSSL_PARAM *params = NULL; in php_openssl_pkey_init_ec()
4357 php_error_docref(NULL, E_WARNING, "Unknown curve name"); in php_openssl_pkey_init_ec()
4368 if (!pnt || !EC_POINT_mul(group, pnt, d, NULL, NULL, NULL)) { in php_openssl_pkey_init_ec()
4374 if (!pnt || !EC_POINT_set_affine_coordinates(group, pnt, x, y, NULL)) { in php_openssl_pkey_init_ec()
4381 EC_POINT_point2buf(group, pnt, POINT_CONVERSION_COMPRESSED, &pnt_oct, NULL); in php_openssl_pkey_init_ec()
4400 ctx = EVP_PKEY_CTX_new(param_key, NULL); in php_openssl_pkey_init_ec()
4402 *is_private = d != NULL; in php_openssl_pkey_init_ec()
4430 return NULL; in php_openssl_pkey_init_ec()
4436 return NULL; in php_openssl_pkey_init_ec()
4444 return NULL; in php_openssl_pkey_init_ec()
4456 zval * args = NULL; in PHP_FUNCTION()
4467 if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "rsa", sizeof("rsa")-1)) != NULL && in PHP_FUNCTION()
4475 } else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dsa", sizeof("dsa") - 1)) != NULL && in PHP_FUNCTION()
4484 } else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "dh", sizeof("dh") - 1)) != NULL && in PHP_FUNCTION()
4494 } else if ((data = zend_hash_str_find(Z_ARRVAL_P(args), "ec", sizeof("ec") - 1)) != NULL && in PHP_FUNCTION()
4514 req.priv_key = NULL; in PHP_FUNCTION()
4525 zval * zpkey, * args = NULL; in PHP_FUNCTION()
4526 char * passphrase = NULL; in PHP_FUNCTION()
4528 char * filename = NULL, file_path[MAXPATHLEN]; in PHP_FUNCTION()
4532 BIO * bio_out = NULL; in PHP_FUNCTION()
4543 if (key == NULL) { in PHP_FUNCTION()
4545 php_error_docref(NULL, E_WARNING, "Cannot get key from parameter 1"); in PHP_FUNCTION()
4558 if (bio_out == NULL) { in PHP_FUNCTION()
4570 cipher = NULL; in PHP_FUNCTION()
4575 (unsigned char *)passphrase, (int)passphrase_len, NULL, NULL); in PHP_FUNCTION()
4596 zval * zpkey, * args = NULL, *out; in PHP_FUNCTION()
4597 char * passphrase = NULL; size_t passphrase_len = 0; in PHP_FUNCTION()
4600 BIO * bio_out = NULL; in PHP_FUNCTION()
4611 if (key == NULL) { in PHP_FUNCTION()
4613 php_error_docref(NULL, E_WARNING, "Cannot get key from parameter 1"); in PHP_FUNCTION()
4630 cipher = NULL; in PHP_FUNCTION()
4635 (unsigned char *)passphrase, (int)passphrase_len, NULL, NULL); in PHP_FUNCTION()
4665 pkey = php_openssl_pkey_from_zval(cert, 1, NULL, 0, 1); in PHP_FUNCTION()
4666 if (pkey == NULL) { in PHP_FUNCTION()
4702 if (pkey == NULL) { in PHP_FUNCTION()
4714 BIGNUM *bn = NULL; in php_openssl_copy_bn_param()
4732 return NULL; in php_openssl_get_utf8_param()
4840 if (rsa != NULL) { in PHP_FUNCTION()
4869 if (dsa != NULL) { in PHP_FUNCTION()
4891 if (dh != NULL) { in PHP_FUNCTION()
4910 if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { in PHP_FUNCTION()
4935 if (crv_sn != NULL) { in PHP_FUNCTION()
4940 if (obj != NULL) { in PHP_FUNCTION()
4948 if (EC_POINT_get_affine_coordinates_GFp(ec_group, pub, x, y, NULL)) { in PHP_FUNCTION()
4955 if ((d = EC_KEY_get0_private_key(EVP_PKEY_get0_EC_KEY(pkey))) != NULL) { in PHP_FUNCTION()
4978 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(key, NULL); in php_openssl_pkey_derive()
4980 return NULL; in php_openssl_pkey_derive()
4985 (key_size == 0 && EVP_PKEY_derive(ctx, NULL, &key_size) <= 0)) { in php_openssl_pkey_derive()
4988 return NULL; in php_openssl_pkey_derive()
4996 return NULL; in php_openssl_pkey_derive()
5012 return NULL; in php_openssl_dh_compute_key()
5020 if (dh == NULL) { in php_openssl_dh_compute_key()
5021 return NULL; in php_openssl_dh_compute_key()
5024 BIGNUM *pub = BN_bin2bn((unsigned char*)pub_str, (int)pub_len, NULL); in php_openssl_dh_compute_key()
5032 return NULL; in php_openssl_dh_compute_key()
5089 EVP_PKEY *peer_key = php_openssl_pkey_from_zval(peer_pub_key, 1, NULL, 0, 1); in PHP_FUNCTION()
5147 php_error_docref(NULL, E_WARNING, "Unknown digest algorithm"); in PHP_FUNCTION()
5171 return NULL; in php_openssl_bio_new_file()
5175 if (bio == NULL) { in php_openssl_bio_new_file()
5177 return NULL; in php_openssl_bio_new_file()
5188 X509_STORE * store = NULL; in PHP_FUNCTION()
5189 zval * cainfo = NULL; in PHP_FUNCTION()
5190 STACK_OF(X509) *signers= NULL; in PHP_FUNCTION()
5191 STACK_OF(X509) *others = NULL; in PHP_FUNCTION()
5192 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5193 BIO * in = NULL, * datain = NULL, * dataout = NULL, * p7bout = NULL; in PHP_FUNCTION()
5197 char * extracerts = NULL; in PHP_FUNCTION()
5199 char * signersfilename = NULL; in PHP_FUNCTION()
5201 char * datafilename = NULL; in PHP_FUNCTION()
5203 char * p7bfilename = NULL; in PHP_FUNCTION()
5216 if (others == NULL) { in PHP_FUNCTION()
5230 if (in == NULL) { in PHP_FUNCTION()
5235 if (p7 == NULL) { in PHP_FUNCTION()
5245 if (dataout == NULL) { in PHP_FUNCTION()
5252 if (p7bout == NULL) { in PHP_FUNCTION()
5272 if (signers != NULL) { in PHP_FUNCTION()
5278 php_error_docref(NULL, E_WARNING, "Failed to write signer %d", i); in PHP_FUNCTION()
5290 …php_error_docref(NULL, E_WARNING, "Signature OK, but cannot open %s for writing", signersfilename); in PHP_FUNCTION()
5296 php_error_docref(NULL, E_WARNING, "Failed to write PKCS7 to file"); in PHP_FUNCTION()
5322 zval * zrecipcerts, * zheaders = NULL; in PHP_FUNCTION()
5323 STACK_OF(X509) * recipcerts = NULL; in PHP_FUNCTION()
5324 BIO * infile = NULL, * outfile = NULL; in PHP_FUNCTION()
5326 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5329 const EVP_CIPHER *cipher = NULL; in PHP_FUNCTION()
5332 char * infilename = NULL; in PHP_FUNCTION()
5334 char * outfilename = NULL; in PHP_FUNCTION()
5345 if (infile == NULL) { in PHP_FUNCTION()
5350 if (outfile == NULL) { in PHP_FUNCTION()
5361 cert = php_openssl_x509_from_zval(zcertval, &free_cert, 3, true, NULL); in PHP_FUNCTION()
5362 if (cert == NULL) { in PHP_FUNCTION()
5371 if (cert == NULL) { in PHP_FUNCTION()
5382 cert = php_openssl_x509_from_zval(zrecipcerts, &free_cert, 3, false, NULL); in PHP_FUNCTION()
5383 if (cert == NULL) { in PHP_FUNCTION()
5392 if (cert == NULL) { in PHP_FUNCTION()
5402 if (cipher == NULL) { in PHP_FUNCTION()
5404 php_error_docref(NULL, E_WARNING, "Failed to get cipher"); in PHP_FUNCTION()
5410 if (p7 == NULL) { in PHP_FUNCTION()
5454 zval * zout = NULL, zcert; in PHP_FUNCTION()
5457 STACK_OF(X509) *certs = NULL; in PHP_FUNCTION()
5458 STACK_OF(X509_CRL) *crls = NULL; in PHP_FUNCTION()
5459 BIO * bio_in = NULL, * bio_out = NULL; in PHP_FUNCTION()
5460 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5473 if (bio_in == NULL) { in PHP_FUNCTION()
5482 p7 = PEM_read_bio_PKCS7(bio_in, NULL, NULL, NULL); in PHP_FUNCTION()
5483 if (p7 == NULL) { in PHP_FUNCTION()
5490 if (p7->d.sign != NULL) { in PHP_FUNCTION()
5496 if (p7->d.signed_and_enveloped != NULL) { in PHP_FUNCTION()
5510 if (certs != NULL) { in PHP_FUNCTION()
5525 if (crls != NULL) { in PHP_FUNCTION()
5545 if (p7 != NULL) { in PHP_FUNCTION()
5555 X509 *cert = NULL; in PHP_FUNCTION()
5560 EVP_PKEY * privkey = NULL; in PHP_FUNCTION()
5562 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5563 BIO * infile = NULL, * outfile = NULL; in PHP_FUNCTION()
5564 STACK_OF(X509) *others = NULL; in PHP_FUNCTION()
5570 char * extracertsfilename = NULL; in PHP_FUNCTION()
5589 if (others == NULL) { in PHP_FUNCTION()
5595 if (privkey == NULL) { in PHP_FUNCTION()
5597 php_error_docref(NULL, E_WARNING, "Error getting private key"); in PHP_FUNCTION()
5603 if (cert == NULL) { in PHP_FUNCTION()
5604 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
5609 if (infile == NULL) { in PHP_FUNCTION()
5610 php_error_docref(NULL, E_WARNING, "Error opening input file %s!", infilename); in PHP_FUNCTION()
5615 if (outfile == NULL) { in PHP_FUNCTION()
5616 php_error_docref(NULL, E_WARNING, "Error opening output file %s!", outfilename); in PHP_FUNCTION()
5621 if (p7 == NULL) { in PHP_FUNCTION()
5623 php_error_docref(NULL, E_WARNING, "Error creating PKCS7 structure!"); in PHP_FUNCTION()
5676 zval *recipcert, *recipkey = NULL; in PHP_FUNCTION()
5678 EVP_PKEY * key = NULL; in PHP_FUNCTION()
5679 BIO * in = NULL, *out = NULL, *datain = NULL; in PHP_FUNCTION()
5680 PKCS7 * p7 = NULL; in PHP_FUNCTION()
5696 cert = php_openssl_x509_from_zval(recipcert, &free_recipcert, 3, false, NULL); in PHP_FUNCTION()
5697 if (cert == NULL) { in PHP_FUNCTION()
5698 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
5703 if (key == NULL) { in PHP_FUNCTION()
5705 php_error_docref(NULL, E_WARNING, "Unable to get private key"); in PHP_FUNCTION()
5712 if (in == NULL) { in PHP_FUNCTION()
5718 if (out == NULL) { in PHP_FUNCTION()
5724 if (p7 == NULL) { in PHP_FUNCTION()
5752 X509_STORE * store = NULL; in PHP_FUNCTION()
5753 zval * cainfo = NULL; in PHP_FUNCTION()
5754 STACK_OF(X509) *signers= NULL; in PHP_FUNCTION()
5755 STACK_OF(X509) *others = NULL; in PHP_FUNCTION()
5756 CMS_ContentInfo * cms = NULL; in PHP_FUNCTION()
5757 BIO * in = NULL, * datain = NULL, * dataout = NULL, * p7bout = NULL; in PHP_FUNCTION()
5758 BIO *certout = NULL, *sigbio = NULL; in PHP_FUNCTION()
5762 char * extracerts = NULL; in PHP_FUNCTION()
5764 char * signersfilename = NULL; in PHP_FUNCTION()
5766 char * datafilename = NULL; in PHP_FUNCTION()
5768 char * p7bfilename = NULL; in PHP_FUNCTION()
5770 char * sigfile = NULL; in PHP_FUNCTION()
5785 if (in == NULL) { in PHP_FUNCTION()
5790 php_error_docref(NULL, E_WARNING, in PHP_FUNCTION()
5795 if (sigbio == NULL) { in PHP_FUNCTION()
5804 cms = PEM_read_bio_CMS(sigbio, NULL, 0, NULL); in PHP_FUNCTION()
5808 cms = d2i_CMS_bio(sigbio, NULL); in PHP_FUNCTION()
5815 php_error_docref(NULL, E_WARNING, "Unknown encoding"); in PHP_FUNCTION()
5818 if (cms == NULL) { in PHP_FUNCTION()
5823 datain = NULL; /* when not detached, don't pass a real BIO */ in PHP_FUNCTION()
5828 if (others == NULL) { in PHP_FUNCTION()
5842 if (dataout == NULL) { in PHP_FUNCTION()
5850 if (p7bout == NULL) { in PHP_FUNCTION()
5866 if (signers != NULL) { in PHP_FUNCTION()
5872 php_error_docref(NULL, E_WARNING, "Failed to write signer %d", i); in PHP_FUNCTION()
5882 …php_error_docref(NULL, E_WARNING, "Signature OK, but cannot open %s for writing", signersfilename); in PHP_FUNCTION()
5888 php_error_docref(NULL, E_WARNING, "Failed to write CMS to file"); in PHP_FUNCTION()
5924 zval * zrecipcerts, * zheaders = NULL; in PHP_FUNCTION()
5925 STACK_OF(X509) * recipcerts = NULL; in PHP_FUNCTION()
5926 BIO * infile = NULL, * outfile = NULL; in PHP_FUNCTION()
5929 CMS_ContentInfo * cms = NULL; in PHP_FUNCTION()
5932 const EVP_CIPHER *cipher = NULL; in PHP_FUNCTION()
5935 char * infilename = NULL; in PHP_FUNCTION()
5937 char * outfilename = NULL; in PHP_FUNCTION()
5951 if (infile == NULL) { in PHP_FUNCTION()
5957 if (outfile == NULL) { in PHP_FUNCTION()
5968 cert = php_openssl_x509_from_zval(zcertval, &free_cert, 3, true, NULL); in PHP_FUNCTION()
5969 if (cert == NULL) { in PHP_FUNCTION()
5977 if (cert == NULL) { in PHP_FUNCTION()
5988 cert = php_openssl_x509_from_zval(zrecipcerts, &free_cert, 3, false, NULL); in PHP_FUNCTION()
5989 if (cert == NULL) { in PHP_FUNCTION()
5997 if (cert == NULL) { in PHP_FUNCTION()
6007 if (cipher == NULL) { in PHP_FUNCTION()
6009 php_error_docref(NULL, E_WARNING, "Failed to get cipher"); in PHP_FUNCTION()
6015 if (cms == NULL) { in PHP_FUNCTION()
6051 if (CMS_final(cms, infile, NULL, (unsigned int) flags) != 1) { in PHP_FUNCTION()
6063 if (CMS_final(cms, infile, NULL, (unsigned int) flags) != 1) { in PHP_FUNCTION()
6081 php_error_docref(NULL, E_WARNING, "Unknown OPENSSL encoding"); in PHP_FUNCTION()
6102 zval * zout = NULL, zcert; in PHP_FUNCTION()
6105 STACK_OF(X509) *certs = NULL; in PHP_FUNCTION()
6106 STACK_OF(X509_CRL) *crls = NULL; in PHP_FUNCTION()
6107 BIO * bio_in = NULL, * bio_out = NULL; in PHP_FUNCTION()
6108 CMS_ContentInfo * cms = NULL; in PHP_FUNCTION()
6121 if (bio_in == NULL) { in PHP_FUNCTION()
6130 cms = PEM_read_bio_CMS(bio_in, NULL, NULL, NULL); in PHP_FUNCTION()
6131 if (cms == NULL) { in PHP_FUNCTION()
6151 if (certs != NULL) { in PHP_FUNCTION()
6166 if (crls != NULL) { in PHP_FUNCTION()
6185 if (cms != NULL) { in PHP_FUNCTION()
6188 if (certs != NULL) { in PHP_FUNCTION()
6191 if (crls != NULL) { in PHP_FUNCTION()
6201 X509 *cert = NULL; in PHP_FUNCTION()
6206 EVP_PKEY * privkey = NULL; in PHP_FUNCTION()
6209 CMS_ContentInfo * cms = NULL; in PHP_FUNCTION()
6210 BIO * infile = NULL, * outfile = NULL; in PHP_FUNCTION()
6211 STACK_OF(X509) *others = NULL; in PHP_FUNCTION()
6217 char * extracertsfilename = NULL; in PHP_FUNCTION()
6238 if (others == NULL) { in PHP_FUNCTION()
6244 if (privkey == NULL) { in PHP_FUNCTION()
6246 php_error_docref(NULL, E_WARNING, "Error getting private key"); in PHP_FUNCTION()
6252 if (cert == NULL) { in PHP_FUNCTION()
6253 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
6258 php_error_docref(NULL, in PHP_FUNCTION()
6276 if (infile == NULL) { in PHP_FUNCTION()
6277 php_error_docref(NULL, E_WARNING, "Error opening input file %s!", infilename); in PHP_FUNCTION()
6283 if (outfile == NULL) { in PHP_FUNCTION()
6284 php_error_docref(NULL, E_WARNING, "Error opening output file %s!", outfilename); in PHP_FUNCTION()
6289 if (cms == NULL) { in PHP_FUNCTION()
6291 php_error_docref(NULL, E_WARNING, "Error creating CMS structure!"); in PHP_FUNCTION()
6329 if (CMS_final(cms, infile, NULL, (unsigned int) flags) != 1) { in PHP_FUNCTION()
6341 if (CMS_final(cms, infile, NULL, (unsigned int) flags) != 1) { in PHP_FUNCTION()
6359 php_error_docref(NULL, E_WARNING, "Unknown OPENSSL encoding"); in PHP_FUNCTION()
6385 zval *recipcert, *recipkey = NULL; in PHP_FUNCTION()
6387 EVP_PKEY * key = NULL; in PHP_FUNCTION()
6389 BIO * in = NULL, * out = NULL, * datain = NULL; in PHP_FUNCTION()
6390 CMS_ContentInfo * cms = NULL; in PHP_FUNCTION()
6407 cert = php_openssl_x509_from_zval(recipcert, &free_recipcert, 3, false, NULL); in PHP_FUNCTION()
6408 if (cert == NULL) { in PHP_FUNCTION()
6409 php_error_docref(NULL, E_WARNING, "X.509 Certificate cannot be retrieved"); in PHP_FUNCTION()
6414 if (key == NULL) { in PHP_FUNCTION()
6416 php_error_docref(NULL, E_WARNING, "Unable to get private key"); in PHP_FUNCTION()
6423 if (in == NULL) { in PHP_FUNCTION()
6429 if (out == NULL) { in PHP_FUNCTION()
6435 cms = d2i_CMS_bio(in, NULL); in PHP_FUNCTION()
6438 cms = PEM_read_bio_CMS(in, NULL, 0, NULL); in PHP_FUNCTION()
6448 if (cms == NULL) { in PHP_FUNCTION()
6452 if (CMS_decrypt(cms, key, cert, NULL, out, 0)) { in PHP_FUNCTION()
6488 if (pkey == NULL) { in PHP_FUNCTION()
6490 php_error_docref(NULL, E_WARNING, "key param is not a valid private key"); in PHP_FUNCTION()
6496 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
6499 EVP_PKEY_sign(ctx, NULL, &out_len, (unsigned char *) data, data_len) <= 0) { in PHP_FUNCTION()
6537 if (pkey == NULL) { in PHP_FUNCTION()
6539 php_error_docref(NULL, E_WARNING, "key parameter is not a valid private key"); in PHP_FUNCTION()
6545 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
6548 EVP_PKEY_decrypt(ctx, NULL, &out_len, (unsigned char *) data, data_len) <= 0) { in PHP_FUNCTION()
6586 EVP_PKEY *pkey = php_openssl_pkey_from_zval(key, 1, NULL, 0, 3); in PHP_FUNCTION()
6587 if (pkey == NULL) { in PHP_FUNCTION()
6589 php_error_docref(NULL, E_WARNING, "key parameter is not a valid public key"); in PHP_FUNCTION()
6595 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
6598 EVP_PKEY_encrypt(ctx, NULL, &out_len, (unsigned char *) data, data_len) <= 0) { in PHP_FUNCTION()
6635 EVP_PKEY *pkey = php_openssl_pkey_from_zval(key, 1, NULL, 0, 3); in PHP_FUNCTION()
6636 if (pkey == NULL) { in PHP_FUNCTION()
6638 php_error_docref(NULL, E_WARNING, "key parameter is not a valid public key"); in PHP_FUNCTION()
6644 EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(pkey, NULL); in PHP_FUNCTION()
6647 EVP_PKEY_verify_recover(ctx, NULL, &out_len, (unsigned char *) data, data_len) <= 0) { in PHP_FUNCTION()
6685 if (OPENSSL_G(errors) == NULL || OPENSSL_G(errors)->top == OPENSSL_G(errors)->bottom) { in PHP_FUNCTION()
6711 zend_string *method_str = NULL; in PHP_FUNCTION()
6724 if (pkey == NULL) { in PHP_FUNCTION()
6726 php_error_docref(NULL, E_WARNING, "Supplied key param cannot be coerced into a private key"); in PHP_FUNCTION()
6737 php_error_docref(NULL, E_WARNING, "Unknown digest algorithm"); in PHP_FUNCTION()
6745 if (md_ctx != NULL && in PHP_FUNCTION()
6775 zend_string *method_str = NULL; in PHP_FUNCTION()
6794 php_error_docref(NULL, E_WARNING, "Unknown digest algorithm"); in PHP_FUNCTION()
6798 pkey = php_openssl_pkey_from_zval(key, 1, NULL, 0, 3); in PHP_FUNCTION()
6799 if (pkey == NULL) { in PHP_FUNCTION()
6801 php_error_docref(NULL, E_WARNING, "Supplied key param cannot be coerced into a public key"); in PHP_FUNCTION()
6807 if (md_ctx == NULL || in PHP_FUNCTION()
6822 zval *pubkeys, *pubkey, *sealdata, *ekeys, *iv = NULL; in PHP_FUNCTION()
6826 unsigned char iv_buf[EVP_MAX_IV_LENGTH + 1], *buf = NULL, **eks; in PHP_FUNCTION()
6850 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in PHP_FUNCTION()
6869 pkeys[i] = php_openssl_pkey_from_zval(pubkey, 1, NULL, 0, 4); in PHP_FUNCTION()
6870 if (pkeys[i] == NULL) { in PHP_FUNCTION()
6872 php_error_docref(NULL, E_WARNING, "Not a public key (%dth member of pubkeys)", i+1); in PHP_FUNCTION()
6882 if (ctx == NULL || !EVP_EncryptInit(ctx,cipher,NULL,NULL)) { in PHP_FUNCTION()
6917 eks[i] = NULL; in PHP_FUNCTION()
6932 if (pkeys[i] != NULL) { in PHP_FUNCTION()
6957 char *method, *iv = NULL; in PHP_FUNCTION()
6970 if (pkey == NULL) { in PHP_FUNCTION()
6972 php_error_docref(NULL, E_WARNING, "Unable to coerce parameter 4 into a private key"); in PHP_FUNCTION()
6979 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in PHP_FUNCTION()
6990 php_error_docref(NULL, E_WARNING, "IV length is invalid"); in PHP_FUNCTION()
6995 iv_buf = NULL; in PHP_FUNCTION()
7001 if (ctx != NULL && EVP_OpenInit(ctx, cipher, (unsigned char *)ekey, (int)ekey_len, iv_buf, pkey) && in PHP_FUNCTION()
7082 EVP_CIPHER_do_all_provided(NULL, in PHP_FUNCTION()
7098 EC_builtin_curve *curves = NULL; in PHP_FUNCTION()
7101 size_t len = EC_get_builtin_curves(NULL, 0); in PHP_FUNCTION()
7115 if (sname != NULL) { in PHP_FUNCTION()
7140 php_error_docref(NULL, E_WARNING, "Unknown digest algorithm"); in PHP_FUNCTION()
7251 if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) != 1) { in php_openssl_validate_iv()
7252 php_error_docref(NULL, E_WARNING, "Setting of IV length for AEAD mode failed"); in php_openssl_validate_iv()
7275 php_error_docref(NULL, E_WARNING, in php_openssl_validate_iv()
7285 php_error_docref(NULL, E_WARNING, in php_openssl_validate_iv()
7311 php_error_docref(NULL, E_WARNING, in php_openssl_cipher_init()
7315 if (!EVP_CipherInit_ex(cipher_ctx, cipher_type, NULL, NULL, NULL, enc)) { in php_openssl_cipher_init()
7323 if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) { in php_openssl_cipher_init()
7324 php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed"); in php_openssl_cipher_init()
7330 …php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher algorithm does not su… in php_openssl_cipher_init()
7332 php_error_docref(NULL, E_WARNING, "Setting tag for AEAD cipher decryption failed"); in php_openssl_cipher_init()
7342 php_error_docref(NULL, E_WARNING, "Key length cannot be set for the cipher algorithm"); in php_openssl_cipher_init()
7358 if (!EVP_CipherInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)*piv, enc)) { in php_openssl_cipher_init()
7377 if (mode->is_single_run_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, NULL, (int)data_len)) { in php_openssl_cipher_update()
7379 php_error_docref(NULL, E_WARNING, "Setting of data length failed"); in php_openssl_cipher_update()
7383 …if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (const unsigned char *) aad, (int) aa… in php_openssl_cipher_update()
7385 php_error_docref(NULL, E_WARNING, "Setting of additional application data failed"); in php_openssl_cipher_update()
7426 zend_string *outbuf = NULL; in php_openssl_encrypt()
7436 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in php_openssl_encrypt()
7437 return NULL; in php_openssl_encrypt()
7442 php_error_docref(NULL, E_WARNING, "Failed to create cipher context"); in php_openssl_encrypt()
7443 return NULL; in php_openssl_encrypt()
7450 &iv, &iv_len, &free_iv, NULL, tag_len, options, 1) == FAILURE || in php_openssl_encrypt()
7453 outbuf = NULL; in php_openssl_encrypt()
7474 php_error_docref(NULL, E_WARNING, "Retrieving verification tag failed"); in php_openssl_encrypt()
7477 outbuf = NULL; in php_openssl_encrypt()
7482 php_error_docref(NULL, E_WARNING, "A tag should be provided when using AEAD mode"); in php_openssl_encrypt()
7484 outbuf = NULL; in php_openssl_encrypt()
7489 outbuf = NULL; in php_openssl_encrypt()
7510 zval *tag = NULL; in PHP_FUNCTION()
7538 zend_string *base64_str = NULL; in php_openssl_decrypt()
7540 zend_string *outbuf = NULL; in php_openssl_decrypt()
7550 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in php_openssl_decrypt()
7551 return NULL; in php_openssl_decrypt()
7556 php_error_docref(NULL, E_WARNING, "Failed to create cipher context"); in php_openssl_decrypt()
7557 return NULL; in php_openssl_decrypt()
7565 php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input"); in php_openssl_decrypt()
7567 return NULL; in php_openssl_decrypt()
7578 outbuf = NULL; in php_openssl_decrypt()
7587 outbuf = NULL; in php_openssl_decrypt()
7608 char *data, *method, *password, *iv = "", *tag = NULL, *aad = ""; in PHP_FUNCTION()
7636 php_error_docref(NULL, E_WARNING, "Unknown cipher algorithm"); in php_openssl_get_evp_cipher_by_name()
7637 return NULL; in php_openssl_get_evp_cipher_by_name()
7647 return cipher_type == NULL ? -1 : EVP_CIPHER_iv_length(cipher_type); in php_openssl_cipher_iv_length()
7676 return cipher_type == NULL ? -1 : EVP_CIPHER_key_length(cipher_type); in php_openssl_cipher_key_length()
7703 zend_string *buffer = NULL; in php_openssl_random_pseudo_bytes()
7706 return NULL; in php_openssl_random_pseudo_bytes()
7710 return NULL; in php_openssl_random_pseudo_bytes()
7719 return NULL; in php_openssl_random_pseudo_bytes()
7730 zend_string *buffer = NULL; in PHP_FUNCTION()
7732 zval *zstrong_result_returned = NULL; in PHP_FUNCTION()