summaryrefslogtreecommitdiffstats
path: root/libsodium-pr70.patch
blob: b97287fdd2d0bc02d9fa6a6cedec0fdcc96d41f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From ca45bd4a55541d58136c21b38b9b90e750fedfbc Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Mon, 30 Nov 2015 18:31:42 +0100
Subject: [PATCH] fix test

---
 tests/crypto_auth.phpt | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tests/crypto_auth.phpt b/tests/crypto_auth.phpt
index c72451e..76f30eb 100644
--- a/tests/crypto_auth.phpt
+++ b/tests/crypto_auth.phpt
@@ -18,13 +18,9 @@ var_dump(\Sodium\crypto_auth_verify($mac, $badmsg, $key));
 
 // Let's flip a bit pseudo-randomly
 $badmsg = $msg;
-$badmsg[mt_rand(0, 999)] = \chr(
-    \ord($msg[0]) ^ (
-        // Mask out higher bits (thus 256 => 0)
-        0xFF & (
-            // 1, 2, 4, 8, 16, 32, 64, 128, 256
-            1 << mt_rand(0, 8)
-        )
+$badmsg[$i=mt_rand(0, 999)] = \chr(
+    \ord($msg[$i]) ^ (
+        1 << mt_rand(0, 7)
     )
 );
 
@@ -32,7 +28,7 @@ var_dump(\Sodium\crypto_auth_verify($mac, $badmsg, $key));
 
 // Now let's change a bit in the MAC
 $badmac = $mac;
-$badmac[0] = \chr(\ord($badmsg[0]) ^ 0x80);
+$badmac[0] = \chr(\ord($badmac[0]) ^ 0x80);
 var_dump(\Sodium\crypto_auth_verify($badmac, $msg, $key));
 ?>
 --EXPECT--