/* +----------------------------------------------------------------------+ | 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 | +----------------------------------------------------------------------+ */ #ifdef SUHOSIN_EXPERIMENTAL #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