summaryrefslogtreecommitdiffstats
path: root/libsodium-pr63.patch
diff options
context:
space:
mode:
Diffstat (limited to 'libsodium-pr63.patch')
-rw-r--r--libsodium-pr63.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/libsodium-pr63.patch b/libsodium-pr63.patch
new file mode 100644
index 0000000..3d28573
--- /dev/null
+++ b/libsodium-pr63.patch
@@ -0,0 +1,88 @@
+From fbecbcfcbe819a1fae9663689e9c34b9d904502a Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Tue, 27 Oct 2015 08:28:00 +0100
+Subject: [PATCH 1/2] fix build with old libsodium
+
+---
+ libsodium.c | 3 +++
+ tests/crypto_aead.phpt | 5 ++++-
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/libsodium.c b/libsodium.c
+index bc03b49..f9f12f7 100644
+--- a/libsodium.c
++++ b/libsodium.c
+@@ -2033,6 +2033,8 @@ PHP_FUNCTION(crypto_sign_ed25519_pk_to_curve25519)
+ RETURN_STR(ecdhkey);
+ }
+
++#if SODIUM_LIBRARY_VERSION_MAJOR > 7 || \
++ (SODIUM_LIBRARY_VERSION_MAJOR == 7 && SODIUM_LIBRARY_VERSION_MINOR >= 6)
+ PHP_FUNCTION(sodium_compare)
+ {
+ char *buf1;
+@@ -2054,3 +2056,4 @@ PHP_FUNCTION(sodium_compare)
+ (const unsigned char *) buf2, (size_t) len1));
+ }
+ }
++#endif
+\ No newline at end of file
+diff --git a/tests/crypto_aead.phpt b/tests/crypto_aead.phpt
+index c2a5ff1..96029aa 100644
+--- a/tests/crypto_aead.phpt
++++ b/tests/crypto_aead.phpt
+@@ -1,7 +1,10 @@
+ --TEST--
+ Check for libsodium AEAD
+ --SKIPIF--
+-<?php if (!extension_loaded("libsodium")) print "skip"; ?>
++<?php
++if (!extension_loaded("libsodium")) print "skip extension not loaded";
++if (!defined('Sodium\CRYPTO_AEAD_AES256GCM_NPUBBYTES')) print "skip libsodium without AESGCM";
++?>
+ --FILE--
+ <?php
+ $msg = \Sodium\randombytes_buf(\Sodium\randombytes_uniform(1000));
+
+From dddee3245f58a424151d901c3085806529e67503 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Tue, 27 Oct 2015 09:18:18 +0100
+Subject: [PATCH 2/2] add check for crypto_aead_aes256gcm_encrypt symbol
+
+---
+ config.m4 | 8 +++++++-
+ libsodium.c | 2 +-
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/config.m4 b/config.m4
+index 2a7fe2e..eb11468 100644
+--- a/config.m4
++++ b/config.m4
+@@ -38,7 +38,13 @@ if test "$PHP_LIBSODIUM" != "no"; then
+ ],[
+ -L$LIBSODIUM_DIR/$PHP_LIBDIR
+ ])
+-
++ PHP_CHECK_LIBRARY($LIBNAME,crypto_aead_aes256gcm_encrypt,
++ [
++ AC_DEFINE(HAVE_CRYPTO_AEAD_AES256GCM,1,[ ])
++ ],[],[
++ -L$LIBSODIUM_DIR/$PHP_LIBDIR
++ ])
++
+ PHP_SUBST(LIBSODIUM_SHARED_LIBADD)
+
+ PHP_NEW_EXTENSION(libsodium, libsodium.c, $ext_shared)
+diff --git a/libsodium.c b/libsodium.c
+index f9f12f7..f73e62f 100644
+--- a/libsodium.c
++++ b/libsodium.c
+@@ -148,7 +148,7 @@ ZEND_END_ARG_INFO()
+ # define PHP_FE_END { NULL, NULL, NULL }
+ #endif
+
+-#if defined(crypto_aead_aes256gcm_KEYBYTES) && \
++#if defined(HAVE_CRYPTO_AEAD_AES256GCM) && defined(crypto_aead_aes256gcm_KEYBYTES) && \
+ (defined(__amd64) || defined(__amd64__) || defined(__x86_64__) || defined(__i386__) || \
+ defined(_M_AMD64) || defined(_M_IX86))
+ # define HAVE_AESGCM 1