[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16990] updated handling of libsodium
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16990] updated handling of libsodium |
Date: |
Sun, 20 Aug 2017 14:52:42 -0400 (EDT) |
Revision: 16990
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16990
Author: sigurdne
Date: 2017-08-20 14:52:42 -0400 (Sun, 20 Aug 2017)
Log Message:
-----------
updated handling of libsodium
Modified Paths:
--------------
trunk/phpgwapi/inc/class.crypto_libsodium.inc.php
trunk/setup/manageheader.php
Modified: trunk/phpgwapi/inc/class.crypto_libsodium.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.crypto_libsodium.inc.php 2017-08-19 23:23:12 UTC
(rev 16989)
+++ trunk/phpgwapi/inc/class.crypto_libsodium.inc.php 2017-08-20 18:52:42 UTC
(rev 16990)
@@ -28,12 +28,11 @@
{
$key = $vars[0];
- if ($GLOBALS['phpgw_info']['server']['enable_crypto']
== 'libsodium' && extension_loaded('libsodium') && !$this->enabled)
+ if ($GLOBALS['phpgw_info']['server']['enable_crypto']
== 'libsodium' && extension_loaded('sodium') && !$this->enabled)
{
$this->enabled = true;
- $keysize = \Sodium\CRYPTO_SECRETBOX_KEYBYTES;
-
+ $keysize = SODIUM_CRYPTO_SECRETBOX_KEYBYTES;
/* Hack Key to be the correct size */
$x = strlen($key);
@@ -48,7 +47,7 @@
{
if ($this->enabled)
{
- \Sodium\memzero($this->key);
+ sodium_memzero($this->key);
}
}
@@ -201,18 +200,18 @@
*/
function safeEncrypt( $message, $key )
{
- $nonce = \Sodium\randombytes_buf(
- \Sodium\CRYPTO_SECRETBOX_NONCEBYTES
+ $nonce = random_bytes(
+ SODIUM_CRYPTO_SECRETBOX_NONCEBYTES
);
$cipher = base64_encode(
$nonce .
- \Sodium\crypto_secretbox(
+ sodium_crypto_secretbox(
$message, $nonce, $key
)
);
- \Sodium\memzero($message);
- \Sodium\memzero($key);
+ sodium_memzero($message);
+ sodium_memzero($key);
return $cipher;
}
@@ -231,14 +230,15 @@
return false;
// throw new \Exception('Scream bloody murder, the
encoding failed');
}
- if (mb_strlen($decoded, '8bit') <
(\Sodium\CRYPTO_SECRETBOX_NONCEBYTES + \Sodium\CRYPTO_SECRETBOX_MACBYTES))
+ if (mb_strlen($decoded, '8bit') <
(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES))
{
+ return $encrypted;
// throw new \Exception('Scream bloody murder, the
message was truncated');
}
- $nonce = mb_substr($decoded, 0,
\Sodium\CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
- $ciphertext = mb_substr($decoded,
\Sodium\CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
+ $nonce = mb_substr($decoded, 0,
SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
+ $ciphertext = mb_substr($decoded,
SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
- $plain = \Sodium\crypto_secretbox_open(
+ $plain = sodium_crypto_secretbox_open(
$ciphertext, $nonce, $key
);
if ($plain === false)
@@ -245,8 +245,8 @@
{
// throw new \Exception('Scream bloody murder, the
message was tampered with in transit');
}
- \Sodium\memzero($ciphertext);
- \Sodium\memzero($key);
+ sodium_memzero($ciphertext);
+ sodium_memzero($key);
return $plain;
}
}
Modified: trunk/setup/manageheader.php
===================================================================
--- trunk/setup/manageheader.php 2017-08-19 23:23:12 UTC (rev 16989)
+++ trunk/setup/manageheader.php 2017-08-20 18:52:42 UTC (rev 16990)
@@ -475,7 +475,7 @@
if(extension_loaded('libsodium') ||
extension_loaded('sodium'))
{
$supported_crypto_type[] = 'libsodium';
- $detected .= '<li>' . lang('You appear to have
enabled support for libsodium %1', \Sodium\version_string()) . "</li>\n";
+ $detected .= '<li>' . lang('You appear to have
enabled support for libsodium %1', SODIUM_LIBRARY_VERSION) . "</li>\n";
}
else
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16990] updated handling of libsodium,
sigurdne <=