diff -Naur suhosin-0.9.31.org/config.m4 suhosin-0.9.31/config.m4 --- suhosin-0.9.31.org/config.m4 2010-03-28 22:43:13.000000000 +0200 +++ suhosin-0.9.31/config.m4 2010-04-18 15:56:25.000000000 +0200 @@ -5,5 +5,5 @@ [ --enable-suhosin Enable suhosin support]) if test "$PHP_SUHOSIN" != "no"; then - PHP_NEW_EXTENSION(suhosin, suhosin.c crypt.c crypt_blowfish.c sha256.c memory_limit.c treat_data.c ifilter.c post_handler.c ufilter.c rfc1867.c log.c header.c execute.c ex_imp.c session.c aes.c compat_snprintf.c, $ext_shared) + PHP_NEW_EXTENSION(suhosin, suhosin.c crypt.c crypt_blowfish.c sha256.c memory_limit.c treat_data.c ifilter.c post_handler.c ufilter.c rfc1867.c log.c header.c execute.c ex_imp.c session.c aes.c compat_snprintf.c secureconfig.c, $ext_shared) fi diff -Naur suhosin-0.9.31.org/config.w32 suhosin-0.9.31/config.w32 --- suhosin-0.9.31.org/config.w32 2010-03-28 22:43:13.000000000 +0200 +++ suhosin-0.9.31/config.w32 2010-04-18 15:56:25.000000000 +0200 @@ -4,7 +4,7 @@ ARG_ENABLE("suhosin", "whether to enable suhosin support", "yes"); if (PHP_SUHOSIN == "yes") { - EXTENSION("suhosin", "suhosin.c crypt.c crypt_blowfish.c sha256.c memory_limit.c treat_data.c ifilter.c post_handler.c ufilter.c rfc1867.c log.c header.c execute.c ex_imp.c session.c aes.c"); + EXTENSION("suhosin", "suhosin.c crypt.c crypt_blowfish.c sha256.c memory_limit.c treat_data.c ifilter.c post_handler.c ufilter.c rfc1867.c log.c header.c execute.c ex_imp.c session.c aes.c secureconfig.c"); if (PHP_SUHOSIN_SHARED) { ADD_SOURCES(configure_module_dirname, "crypt_win32.c crypt_md5.c", "suhosin"); } diff -Naur suhosin-0.9.31.org/php_suhosin.h suhosin-0.9.31/php_suhosin.h --- suhosin-0.9.31.org/php_suhosin.h 2010-03-28 22:43:13.000000000 +0200 +++ suhosin-0.9.31/php_suhosin.h 2010-04-18 15:56:25.000000000 +0200 @@ -214,6 +214,8 @@ long cookie_checkraddr; HashTable *cookie_plainlist; HashTable *cookie_cryptlist; + + char* secureconfig_cryptkey; zend_bool coredump; zend_bool apc_bug_workaround; @@ -329,6 +331,7 @@ void normalize_varname(char *varname); int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TSRMLS_DC); void suhosin_bailout(TSRMLS_D); +void suhosin_hook_secureconfig(); /* Add pseudo refcount macros for PHP version < 5.3 */ #ifndef Z_REFCOUNT_PP diff -Naur suhosin-0.9.31.org/secureconfig.c suhosin-0.9.31/secureconfig.c --- suhosin-0.9.31.org/secureconfig.c 1970-01-01 01:00:00.000000000 +0100 +++ suhosin-0.9.31/secureconfig.c 2010-04-18 16:20:33.000000000 +0200 @@ -0,0 +1,133 @@ +/* + +----------------------------------------------------------------------+ + | Suhosin Version 1 | + +----------------------------------------------------------------------+ + | Copyright (c) 2006-2007 The Hardened-PHP Project | + | Copyright (c) 2007-2010 SektionEins GmbH | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Juergen Pabel | + +----------------------------------------------------------------------+ +*/ + +#include +#include "php.h" +#include "php_suhosin.h" +#include "sha256.h" + +static char cryptkey[32]; + +/* {{{ proto string secureconfig_encrypt(string plaintext) + Encrypt a configuration value using the configured cryptographic key */ +static PHP_FUNCTION(suhosin_secureconfig_encrypt) +{ + char *plaintext, *ciphertext; + int plaintext_len, ciphertext_len; + int i; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &plaintext, &plaintext_len) == FAILURE) { + return; + } + ciphertext = suhosin_encrypt_string(plaintext, plaintext_len, "", 0, cryptkey TSRMLS_CC); + if(ciphertext == NULL) { + return; + } + ciphertext_len = strlen(ciphertext); + /* undo suhosin_encrypt_string()'s base64 alphabet transformation */ + for (i=0; i