summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2010-06-09 15:40:19 -0400
committerjim-p <jimp@pfsense.org>2010-06-09 15:40:19 -0400
commite22eca366211bbde2a82acbc4fd0c1ca2b9e35d0 (patch)
tree7255dd32650fffb6421d31fed11475dfae16968b /etc/inc
parent901aa044a5c13474f2ba52b1e1963e9684e86a0b (diff)
downloadpfsense-e22eca366211bbde2a82acbc4fd0c1ca2b9e35d0.zip
pfsense-e22eca366211bbde2a82acbc4fd0c1ca2b9e35d0.tar.gz
Use different logic for this function, copied from crypt_acb.php. Ticket #537
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/crypt.inc31
1 files changed, 11 insertions, 20 deletions
diff --git a/etc/inc/crypt.inc b/etc/inc/crypt.inc
index e13b8ff..dcc359f 100644
--- a/etc/inc/crypt.inc
+++ b/etc/inc/crypt.inc
@@ -32,26 +32,17 @@
DISABLE_PHP_LINT_CHECKING
*/
- function crypt_data(& $data, $pass, $opt) {
-
- $pspec = "/usr/bin/openssl enc {$opt} -aes-256-cbc -k {$pass}";
- $dspec = array( 0 => array("pipe", "r"),
- 1 => array("pipe", "w"),
- 2 => array("pipe", "e"));
-
- $fp = proc_open($pspec, $dspec, $pipes);
- if (!$fp)
- return false;
-
- fwrite($pipes[0], $data);
- fclose($pipes[0]);
-
- $rslt = stream_get_contents($pipes[1]);
- fclose($pipes[1]);
-
- proc_close($fp);
-
- return $rslt;
+ function crypt_data($val, $pass, $opt) {
+ $file = tempnam("/tmp", "php-encrypt");
+ $fd = fopen("$file.dec", "w");
+ fwrite($fd, $val);
+ fclose($fd);
+ exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in $file.dec -out $file.enc -k {$pass}");
+ $result = file_get_contents("$file.enc");
+ exec("rm $file");
+ exec("rm $file.dec");
+ exec("rm $file.enc");
+ return $result;
}
function encrypt_data(& $data, $pass) {
OpenPOWER on IntegriCloud