php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #38917
Patch spki.patch revision 2011-12-22 10:41 UTC by jason dot gerfen at gmail dot com
revision 2011-12-21 20:31 UTC by jason dot gerfen at gmail dot com
revision 2011-12-21 16:09 UTC by jason dot gerfen at gmail dot com
revision 2011-12-21 03:48 UTC by jason dot gerfen at gmail dot com
revision 2011-12-21 03:26 UTC by jason dot gerfen at gmail dot com
revision 2011-12-19 17:58 UTC by jason dot gerfen at gmail dot com
revision 2011-12-19 17:53 UTC by jason dot gerfen at gmail dot com
revision 2011-12-19 14:36 UTC by jason dot gerfen at gmail dot com
revision 2011-12-14 11:38 UTC by jason dot gerfen at gmail dot com
revision 2011-12-13 16:55 UTC by jason dot gerfen at gmail dot com
revision 2011-12-08 10:57 UTC by jason dot gerfen at gmail dot com
revision 2011-12-06 21:02 UTC by jason dot gerfen at gmail dot com
revision 2011-12-06 11:35 UTC by jason dot gerfen at gmail dot com
revision 2011-12-06 11:29 UTC by jason dot gerfen at gmail dot com

Patch spki.patch for OpenSSL related Bug #38917

Patch version 2011-12-06 21:02 UTC

Return to Bug #38917 | Download this patch
Patch Revisions: 2011-12-22 10:41 UTC | 2011-12-21 20:31 UTC | 2011-12-21 16:09 UTC | 2011-12-21 03:48 UTC | 2011-12-21 03:26 UTC | 2011-12-19 17:58 UTC | 2011-12-19 17:53 UTC | 2011-12-19 14:36 UTC | 2011-12-14 11:38 UTC | 2011-12-13 16:55 UTC | 2011-12-08 10:57 UTC | 2011-12-06 21:02 UTC | 2011-12-06 11:35 UTC | 2011-12-06 11:29 UTC

Developer: jason.gerfen@gmail.com

Line 1 (now 1), was 8 lines, now 6 lines
 diff -Naur php-5.3.8/ext/openssl/openssl.c php-5.3.8-patched/ext/openssl/openssl.c
  --- php-5.3.8/ext/openssl/openssl.c	2011-07-25 05:42:53.000000000 -0600
 +++ php-5.3.8-patched/ext/openssl/openssl.c	2011-12-06 04:24:32.403578621 -0700
  
 +++ php-5.3.8-patched/ext/openssl/openssl.c	2011-12-06 11:38:55.470584042 -0700
  @@ -372,11 +372,30 @@
       ZEND_ARG_INFO(0, length)
       ZEND_ARG_INFO(1, result_is_strong)
   ZEND_END_ARG_INFO()


  +ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_export, 0)
  +    ZEND_ARG_INFO(0, spki)
  +ZEND_END_ARG_INFO()
   /* }}} */
  
 
   /* {{{ openssl_functions[]
    */
   const zend_function_entry openssl_functions[] = {
  +/* spki functions */
Line 32 (now 30), was 13 lines, now 12 lines

  +
   /* public/private key functions */
   	PHP_FE(openssl_pkey_free,			arginfo_openssl_pkey_free)
   	PHP_FE(openssl_pkey_new,			arginfo_openssl_pkey_new)
 
  @@ -1252,6 +1271,151 @@
   }
   /* }}} */
  
 
  +/* {{{ proto string openssl_spki_new(mixed priv_key, string password)
  +   Creates new private key (or uses existing) and creates a new spki cert
  +   outputting results to var */
  +PHP_FUNCTION(openssl_spki_new)


  +PHP_FUNCTION(openssl_spki_verify)
  +{
  + int spkstr_len, i, x=0;
  + char *spkstr = NULL;
 + EVP_PKEY *pkey = NULL;
 + NETSCAPE_SPKI *spki = NULL;
 +
 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &spkstr, &spkstr_len) == FAILURE) {
 +  php_error_docref(NULL TSRMLS_CC, E_WARNING, "missing argument 1");
 +  goto cleanup;
 + }
 +
 + if (!spkstr) {
 +  php_error_docref(NULL TSRMLS_CC, E_WARNING, "spki not found");
 + EVP_PKEY *pkey = NULL;
 + NETSCAPE_SPKI *spki = NULL;
 +
 + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &spkstr, &spkstr_len) == FAILURE) {
 +  php_error_docref(NULL TSRMLS_CC, E_WARNING, "missing argument 1");
 +  goto cleanup;
 + }
 +
 + if (!spkstr) {
 +  php_error_docref(NULL TSRMLS_CC, E_WARNING, "spki not found");
  +  goto cleanup;
  + }
  +
  + spki = NETSCAPE_SPKI_b64_decode(spkstr, -1);
  + if (!spki) {
  +  php_error_docref(NULL TSRMLS_CC, E_WARNING, "error decoding spki");
 +  goto cleanup;
 + }
 +  goto cleanup;
 + }
  +
  + pkey = NETSCAPE_SPKI_get_pubkey(spki);
  + if (pkey == NULL) {
  +  php_error_docref(NULL TSRMLS_CC, E_WARNING, "error getting public key from spki");


  +
  + if (i > 0) {
  +  x = 1;
  + } else {
 +  x = 0;
 +  x = 0;
  + }
  + goto cleanup;
  +
  +cleanup:


  +  goto cleanup;
  + }
  +
  + PEM_write_bio_PUBKEY(out, pkey);
 + goto cleanup;
  +
  +cleanup:
  + NETSCAPE_SPKI_free(spki);
  + EVP_PKEY_free(pkey);
 + BIO_free(out);
  +}
  +/* }}} */
  +
   /* {{{ proto bool openssl_x509_export(mixed x509, string &out [, bool notext = true])
      Exports a CERT to file or a var */
   PHP_FUNCTION(openssl_x509_export)
 
 diff -Naur php-5.3.8/ext/openssl/php_openssl.h php-5.3.8-patched/ext/openssl/php_openssl.h
  --- php-5.3.8/ext/openssl/php_openssl.h	2010-12-31 19:19:59.000000000 -0700
 +++ php-5.3.8-patched/ext/openssl/php_openssl.h	2011-12-06 04:24:56.581276358 -0700
 +++ php-5.3.8-patched/ext/openssl/php_openssl.h	2011-12-06 11:26:59.986583142 -0700
  @@ -74,6 +74,10 @@
   PHP_FUNCTION(openssl_csr_sign);
   PHP_FUNCTION(openssl_csr_get_subject);
   PHP_FUNCTION(openssl_csr_get_public_key);


  +PHP_FUNCTION(openssl_spki_new);
  +PHP_FUNCTION(openssl_spki_verify);
  +PHP_FUNCTION(openssl_spki_export);
   #else
  
 
   #define phpext_openssl_ptr NULL
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 11:01:26 2019 UTC