Completed
Push — develop ( f0d100...266ee2 )
by J.D.
04:14
created
src/library/sodium_compat/src/Core32/XChaCha20.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_XChaCha20', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,54 +9,54 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class ParagonIE_Sodium_Core32_XChaCha20 extends ParagonIE_Sodium_Core32_HChaCha20
11 11
 {
12
-    /**
13
-     * @internal You should not use this directly from another application
14
-     *
15
-     * @param int $len
16
-     * @param string $nonce
17
-     * @param string $key
18
-     * @return string
19
-     * @throws Exception
20
-     */
21
-    public static function stream($len = 64, $nonce = '', $key = '')
22
-    {
23
-        if (self::strlen($nonce) !== 24) {
24
-            throw new Exception('Nonce must be 24 bytes long');
25
-        }
26
-        return self::encryptBytes(
27
-            new ParagonIE_Sodium_Core32_ChaCha20_Ctx(
28
-                self::hChaCha20(
29
-                    self::substr($nonce, 0, 16),
30
-                    $key
31
-                ),
32
-                self::substr($nonce, 16, 8)
33
-            ),
34
-            str_repeat("\x00", $len)
35
-        );
36
-    }
12
+	/**
13
+	 * @internal You should not use this directly from another application
14
+	 *
15
+	 * @param int $len
16
+	 * @param string $nonce
17
+	 * @param string $key
18
+	 * @return string
19
+	 * @throws Exception
20
+	 */
21
+	public static function stream($len = 64, $nonce = '', $key = '')
22
+	{
23
+		if (self::strlen($nonce) !== 24) {
24
+			throw new Exception('Nonce must be 24 bytes long');
25
+		}
26
+		return self::encryptBytes(
27
+			new ParagonIE_Sodium_Core32_ChaCha20_Ctx(
28
+				self::hChaCha20(
29
+					self::substr($nonce, 0, 16),
30
+					$key
31
+				),
32
+				self::substr($nonce, 16, 8)
33
+			),
34
+			str_repeat("\x00", $len)
35
+		);
36
+	}
37 37
 
38
-    /**
39
-     * @internal You should not use this directly from another application
40
-     *
41
-     * @param string $message
42
-     * @param string $nonce
43
-     * @param string $key
44
-     * @param string $ic
45
-     * @return string
46
-     * @throws Exception
47
-     */
48
-    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
49
-    {
50
-        if (self::strlen($nonce) !== 24) {
51
-            throw new Exception('Nonce must be 24 bytes long');
52
-        }
53
-        return self::encryptBytes(
54
-            new ParagonIE_Sodium_Core32_ChaCha20_Ctx(
55
-                self::hChaCha20(self::substr($nonce, 0, 16), $key),
56
-                self::substr($nonce, 16, 8),
57
-                $ic
58
-            ),
59
-            $message
60
-        );
61
-    }
38
+	/**
39
+	 * @internal You should not use this directly from another application
40
+	 *
41
+	 * @param string $message
42
+	 * @param string $nonce
43
+	 * @param string $key
44
+	 * @param string $ic
45
+	 * @return string
46
+	 * @throws Exception
47
+	 */
48
+	public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
49
+	{
50
+		if (self::strlen($nonce) !== 24) {
51
+			throw new Exception('Nonce must be 24 bytes long');
52
+		}
53
+		return self::encryptBytes(
54
+			new ParagonIE_Sodium_Core32_ChaCha20_Ctx(
55
+				self::hChaCha20(self::substr($nonce, 0, 16), $key),
56
+				self::substr($nonce, 16, 8),
57
+				$ic
58
+			),
59
+			$message
60
+		);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_XChaCha20', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_XChaCha20', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -18,20 +18,20 @@  discard block
 block discarded – undo
18 18
      * @return string
19 19
      * @throws Exception
20 20
      */
21
-    public static function stream($len = 64, $nonce = '', $key = '')
21
+    public static function stream( $len = 64, $nonce = '', $key = '' )
22 22
     {
23
-        if (self::strlen($nonce) !== 24) {
24
-            throw new Exception('Nonce must be 24 bytes long');
23
+        if ( self::strlen( $nonce ) !== 24 ) {
24
+            throw new Exception( 'Nonce must be 24 bytes long' );
25 25
         }
26 26
         return self::encryptBytes(
27 27
             new ParagonIE_Sodium_Core32_ChaCha20_Ctx(
28 28
                 self::hChaCha20(
29
-                    self::substr($nonce, 0, 16),
29
+                    self::substr( $nonce, 0, 16 ),
30 30
                     $key
31 31
                 ),
32
-                self::substr($nonce, 16, 8)
32
+                self::substr( $nonce, 16, 8 )
33 33
             ),
34
-            str_repeat("\x00", $len)
34
+            str_repeat( "\x00", $len )
35 35
         );
36 36
     }
37 37
 
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
      * @return string
46 46
      * @throws Exception
47 47
      */
48
-    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
48
+    public static function streamXorIc( $message, $nonce = '', $key = '', $ic = '' )
49 49
     {
50
-        if (self::strlen($nonce) !== 24) {
51
-            throw new Exception('Nonce must be 24 bytes long');
50
+        if ( self::strlen( $nonce ) !== 24 ) {
51
+            throw new Exception( 'Nonce must be 24 bytes long' );
52 52
         }
53 53
         return self::encryptBytes(
54 54
             new ParagonIE_Sodium_Core32_ChaCha20_Ctx(
55
-                self::hChaCha20(self::substr($nonce, 0, 16), $key),
56
-                self::substr($nonce, 16, 8),
55
+                self::hChaCha20( self::substr( $nonce, 0, 16 ), $key ),
56
+                self::substr( $nonce, 16, 8 ),
57 57
                 $ic
58 58
             ),
59 59
             $message
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_XChaCha20
9 9
  */
10
-class ParagonIE_Sodium_Core32_XChaCha20 extends ParagonIE_Sodium_Core32_HChaCha20
11
-{
10
+class ParagonIE_Sodium_Core32_XChaCha20 extends ParagonIE_Sodium_Core32_HChaCha20 {
12 11
     /**
13 12
      * @internal You should not use this directly from another application
14 13
      *
@@ -18,8 +17,7 @@  discard block
 block discarded – undo
18 17
      * @return string
19 18
      * @throws Exception
20 19
      */
21
-    public static function stream($len = 64, $nonce = '', $key = '')
22
-    {
20
+    public static function stream($len = 64, $nonce = '', $key = '') {
23 21
         if (self::strlen($nonce) !== 24) {
24 22
             throw new Exception('Nonce must be 24 bytes long');
25 23
         }
@@ -45,8 +43,7 @@  discard block
 block discarded – undo
45 43
      * @return string
46 44
      * @throws Exception
47 45
      */
48
-    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
49
-    {
46
+    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') {
50 47
         if (self::strlen($nonce) !== 24) {
51 48
             throw new Exception('Nonce must be 24 bytes long');
52 49
         }
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/SipHash.php 3 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_SipHash', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -11,227 +11,227 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class ParagonIE_Sodium_Core32_SipHash extends ParagonIE_Sodium_Core32_Util
13 13
 {
14
-    /**
15
-     * @internal You should not use this directly from another application
16
-     *
17
-     * @param array<int, ParagonIE_Sodium_Core32_Int64> $v
18
-     * @return array<int, ParagonIE_Sodium_Core32_Int64>
19
-     */
20
-    public static function sipRound(array $v)
21
-    {
22
-        # v0 += v1;
23
-        $v[0] = $v[0]->addInt64($v[1]);
24
-
25
-        # v1 = ROTL(v1, 13);
26
-        $v[1] = $v[1]->rotateLeft(13);
27
-
28
-        #  v1 ^= v0;
29
-        $v[1] = $v[1]->xorInt64($v[0]);
30
-
31
-        #  v0=ROTL(v0,32);
32
-        $v[0] = $v[0]->rotateLeft(32);
33
-
34
-        # v2 += v3;
35
-        $v[2] = $v[2]->addInt64($v[3]);
36
-
37
-        # v3=ROTL(v3,16);
38
-        $v[3] = $v[3]->rotateLeft(16);
39
-
40
-        #  v3 ^= v2;
41
-        $v[3] = $v[3]->xorInt64($v[2]);
42
-
43
-        # v0 += v3;
44
-        $v[0] = $v[0]->addInt64($v[3]);
45
-
46
-        # v3=ROTL(v3,21);
47
-        $v[3] = $v[3]->rotateLeft(21);
48
-
49
-        # v3 ^= v0;
50
-        $v[3] = $v[3]->xorInt64($v[0]);
51
-
52
-        # v2 += v1;
53
-        $v[2] = $v[2]->addInt64($v[1]);
54
-
55
-        # v1=ROTL(v1,17);
56
-        $v[1] = $v[1]->rotateLeft(17);
57
-
58
-        #  v1 ^= v2;
59
-        $v[1] = $v[1]->xorInt64($v[2]);
60
-
61
-        # v2=ROTL(v2,32)
62
-        $v[2] = $v[2]->rotateLeft(32);
63
-
64
-        return $v;
65
-    }
66
-
67
-    /**
68
-     * @internal You should not use this directly from another application
69
-     *
70
-     * @param string $in
71
-     * @param string $key
72
-     * @return string
73
-     */
74
-    public static function sipHash24($in, $key)
75
-    {
76
-        $inlen = self::strlen($in);
77
-
78
-        # /* "somepseudorandomlygeneratedbytes" */
79
-        # u64 v0 = 0x736f6d6570736575ULL;
80
-        # u64 v1 = 0x646f72616e646f6dULL;
81
-        # u64 v2 = 0x6c7967656e657261ULL;
82
-        # u64 v3 = 0x7465646279746573ULL;
83
-        $v = array(
84
-            new ParagonIE_Sodium_Core32_Int64(
85
-                array(0x736f, 0x6d65, 0x7073, 0x6575)
86
-            ),
87
-            new ParagonIE_Sodium_Core32_Int64(
88
-                array(0x646f, 0x7261, 0x6e64, 0x6f6d)
89
-            ),
90
-            new ParagonIE_Sodium_Core32_Int64(
91
-                array(0x6c79, 0x6765, 0x6e65, 0x7261)
92
-            ),
93
-            new ParagonIE_Sodium_Core32_Int64(
94
-                array(0x7465, 0x6462, 0x7974, 0x6573)
95
-            )
96
-        );
97
-
98
-        # u64 k0 = LOAD64_LE( k );
99
-        # u64 k1 = LOAD64_LE( k + 8 );
100
-        $k = array(
101
-            ParagonIE_Sodium_Core32_Int64::fromReverseString(
102
-                self::substr($key, 0, 8)
103
-            ),
104
-            ParagonIE_Sodium_Core32_Int64::fromReverseString(
105
-                self::substr($key, 8, 8)
106
-            )
107
-        );
108
-
109
-        # b = ( ( u64 )inlen ) << 56;
110
-        $b = new ParagonIE_Sodium_Core32_Int64(
111
-            array(($inlen << 8) & 0xffff, 0, 0, 0)
112
-        );
113
-
114
-        # v3 ^= k1;
115
-        $v[3] = $v[3]->xorInt64($k[1]);
116
-        # v2 ^= k0;
117
-        $v[2] = $v[2]->xorInt64($k[0]);
118
-        # v1 ^= k1;
119
-        $v[1] = $v[1]->xorInt64($k[1]);
120
-        # v0 ^= k0;
121
-        $v[0] = $v[0]->xorInt64($k[0]);
122
-
123
-        $left = $inlen;
124
-        # for ( ; in != end; in += 8 )
125
-        while ($left >= 8) {
126
-            # m = LOAD64_LE( in );
127
-            $m = ParagonIE_Sodium_Core32_Int64::fromReverseString(
128
-                self::substr($in, 0, 8)
129
-            );
130
-
131
-            # v3 ^= m;
132
-            $v[3] = $v[3]->xorInt64($m);
133
-
134
-            # SIPROUND;
135
-            # SIPROUND;
136
-            $v = self::sipRound($v);
137
-            $v = self::sipRound($v);
138
-
139
-            # v0 ^= m;
140
-            $v[0] = $v[0]->xorInt64($m);
141
-
142
-            $in = self::substr($in, 8);
143
-            $left -= 8;
144
-        }
145
-
146
-        # switch( left )
147
-        #  {
148
-        #     case 7: b |= ( ( u64 )in[ 6] )  << 48;
149
-        #     case 6: b |= ( ( u64 )in[ 5] )  << 40;
150
-        #     case 5: b |= ( ( u64 )in[ 4] )  << 32;
151
-        #     case 4: b |= ( ( u64 )in[ 3] )  << 24;
152
-        #     case 3: b |= ( ( u64 )in[ 2] )  << 16;
153
-        #     case 2: b |= ( ( u64 )in[ 1] )  <<  8;
154
-        #     case 1: b |= ( ( u64 )in[ 0] ); break;
155
-        #     case 0: break;
156
-        # }
157
-        switch ($left) {
158
-            case 7:
159
-                $b = $b->orInt64(
160
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
161
-                        0, self::chrToInt($in[6]) << 16
162
-                    )
163
-                );
164
-            case 6:
165
-                $b = $b->orInt64(
166
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
167
-                        0, self::chrToInt($in[5]) << 8
168
-                    )
169
-                );
170
-            case 5:
171
-                $b = $b->orInt64(
172
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
173
-                        0, self::chrToInt($in[4])
174
-                    )
175
-                );
176
-            case 4:
177
-                $b = $b->orInt64(
178
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
179
-                        self::chrToInt($in[3]) << 24, 0
180
-                    )
181
-                );
182
-            case 3:
183
-                $b = $b->orInt64(
184
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
185
-                        self::chrToInt($in[2]) << 16, 0
186
-                    )
187
-                );
188
-            case 2:
189
-                $b = $b->orInt64(
190
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
191
-                        self::chrToInt($in[1]) << 8, 0
192
-                    )
193
-                );
194
-            case 1:
195
-                $b = $b->orInt64(
196
-                    ParagonIE_Sodium_Core32_Int64::fromInts(
197
-                        self::chrToInt($in[0]), 0
198
-                    )
199
-                );
200
-            case 0:
201
-                break;
202
-        }
203
-        // See docblock for why the 0th index gets the higher bits.
204
-
205
-        # v3 ^= b;
206
-        $v[3] = $v[3]->xorInt64($b);
207
-
208
-        # SIPROUND;
209
-        # SIPROUND;
210
-        $v = self::sipRound($v);
211
-        $v = self::sipRound($v);
212
-
213
-        # v0 ^= b;
214
-        $v[0] = $v[0]->xorInt64($b);
215
-
216
-        // Flip the lower 8 bits of v2 which is ($v[4], $v[5]) in our implementation
217
-        # v2 ^= 0xff;
218
-        $v[2]->limbs[3] ^= 0xff;
219
-
220
-        # SIPROUND;
221
-        # SIPROUND;
222
-        # SIPROUND;
223
-        # SIPROUND;
224
-        $v = self::sipRound($v);
225
-        $v = self::sipRound($v);
226
-        $v = self::sipRound($v);
227
-        $v = self::sipRound($v);
228
-
229
-        # b = v0 ^ v1 ^ v2 ^ v3;
230
-        # STORE64_LE( out, b );
231
-        return $v[0]
232
-            ->xorInt64($v[1])
233
-            ->xorInt64($v[2])
234
-            ->xorInt64($v[3])
235
-            ->toReverseString();
236
-    }
14
+	/**
15
+	 * @internal You should not use this directly from another application
16
+	 *
17
+	 * @param array<int, ParagonIE_Sodium_Core32_Int64> $v
18
+	 * @return array<int, ParagonIE_Sodium_Core32_Int64>
19
+	 */
20
+	public static function sipRound(array $v)
21
+	{
22
+		# v0 += v1;
23
+		$v[0] = $v[0]->addInt64($v[1]);
24
+
25
+		# v1 = ROTL(v1, 13);
26
+		$v[1] = $v[1]->rotateLeft(13);
27
+
28
+		#  v1 ^= v0;
29
+		$v[1] = $v[1]->xorInt64($v[0]);
30
+
31
+		#  v0=ROTL(v0,32);
32
+		$v[0] = $v[0]->rotateLeft(32);
33
+
34
+		# v2 += v3;
35
+		$v[2] = $v[2]->addInt64($v[3]);
36
+
37
+		# v3=ROTL(v3,16);
38
+		$v[3] = $v[3]->rotateLeft(16);
39
+
40
+		#  v3 ^= v2;
41
+		$v[3] = $v[3]->xorInt64($v[2]);
42
+
43
+		# v0 += v3;
44
+		$v[0] = $v[0]->addInt64($v[3]);
45
+
46
+		# v3=ROTL(v3,21);
47
+		$v[3] = $v[3]->rotateLeft(21);
48
+
49
+		# v3 ^= v0;
50
+		$v[3] = $v[3]->xorInt64($v[0]);
51
+
52
+		# v2 += v1;
53
+		$v[2] = $v[2]->addInt64($v[1]);
54
+
55
+		# v1=ROTL(v1,17);
56
+		$v[1] = $v[1]->rotateLeft(17);
57
+
58
+		#  v1 ^= v2;
59
+		$v[1] = $v[1]->xorInt64($v[2]);
60
+
61
+		# v2=ROTL(v2,32)
62
+		$v[2] = $v[2]->rotateLeft(32);
63
+
64
+		return $v;
65
+	}
66
+
67
+	/**
68
+	 * @internal You should not use this directly from another application
69
+	 *
70
+	 * @param string $in
71
+	 * @param string $key
72
+	 * @return string
73
+	 */
74
+	public static function sipHash24($in, $key)
75
+	{
76
+		$inlen = self::strlen($in);
77
+
78
+		# /* "somepseudorandomlygeneratedbytes" */
79
+		# u64 v0 = 0x736f6d6570736575ULL;
80
+		# u64 v1 = 0x646f72616e646f6dULL;
81
+		# u64 v2 = 0x6c7967656e657261ULL;
82
+		# u64 v3 = 0x7465646279746573ULL;
83
+		$v = array(
84
+			new ParagonIE_Sodium_Core32_Int64(
85
+				array(0x736f, 0x6d65, 0x7073, 0x6575)
86
+			),
87
+			new ParagonIE_Sodium_Core32_Int64(
88
+				array(0x646f, 0x7261, 0x6e64, 0x6f6d)
89
+			),
90
+			new ParagonIE_Sodium_Core32_Int64(
91
+				array(0x6c79, 0x6765, 0x6e65, 0x7261)
92
+			),
93
+			new ParagonIE_Sodium_Core32_Int64(
94
+				array(0x7465, 0x6462, 0x7974, 0x6573)
95
+			)
96
+		);
97
+
98
+		# u64 k0 = LOAD64_LE( k );
99
+		# u64 k1 = LOAD64_LE( k + 8 );
100
+		$k = array(
101
+			ParagonIE_Sodium_Core32_Int64::fromReverseString(
102
+				self::substr($key, 0, 8)
103
+			),
104
+			ParagonIE_Sodium_Core32_Int64::fromReverseString(
105
+				self::substr($key, 8, 8)
106
+			)
107
+		);
108
+
109
+		# b = ( ( u64 )inlen ) << 56;
110
+		$b = new ParagonIE_Sodium_Core32_Int64(
111
+			array(($inlen << 8) & 0xffff, 0, 0, 0)
112
+		);
113
+
114
+		# v3 ^= k1;
115
+		$v[3] = $v[3]->xorInt64($k[1]);
116
+		# v2 ^= k0;
117
+		$v[2] = $v[2]->xorInt64($k[0]);
118
+		# v1 ^= k1;
119
+		$v[1] = $v[1]->xorInt64($k[1]);
120
+		# v0 ^= k0;
121
+		$v[0] = $v[0]->xorInt64($k[0]);
122
+
123
+		$left = $inlen;
124
+		# for ( ; in != end; in += 8 )
125
+		while ($left >= 8) {
126
+			# m = LOAD64_LE( in );
127
+			$m = ParagonIE_Sodium_Core32_Int64::fromReverseString(
128
+				self::substr($in, 0, 8)
129
+			);
130
+
131
+			# v3 ^= m;
132
+			$v[3] = $v[3]->xorInt64($m);
133
+
134
+			# SIPROUND;
135
+			# SIPROUND;
136
+			$v = self::sipRound($v);
137
+			$v = self::sipRound($v);
138
+
139
+			# v0 ^= m;
140
+			$v[0] = $v[0]->xorInt64($m);
141
+
142
+			$in = self::substr($in, 8);
143
+			$left -= 8;
144
+		}
145
+
146
+		# switch( left )
147
+		#  {
148
+		#     case 7: b |= ( ( u64 )in[ 6] )  << 48;
149
+		#     case 6: b |= ( ( u64 )in[ 5] )  << 40;
150
+		#     case 5: b |= ( ( u64 )in[ 4] )  << 32;
151
+		#     case 4: b |= ( ( u64 )in[ 3] )  << 24;
152
+		#     case 3: b |= ( ( u64 )in[ 2] )  << 16;
153
+		#     case 2: b |= ( ( u64 )in[ 1] )  <<  8;
154
+		#     case 1: b |= ( ( u64 )in[ 0] ); break;
155
+		#     case 0: break;
156
+		# }
157
+		switch ($left) {
158
+			case 7:
159
+				$b = $b->orInt64(
160
+					ParagonIE_Sodium_Core32_Int64::fromInts(
161
+						0, self::chrToInt($in[6]) << 16
162
+					)
163
+				);
164
+			case 6:
165
+				$b = $b->orInt64(
166
+					ParagonIE_Sodium_Core32_Int64::fromInts(
167
+						0, self::chrToInt($in[5]) << 8
168
+					)
169
+				);
170
+			case 5:
171
+				$b = $b->orInt64(
172
+					ParagonIE_Sodium_Core32_Int64::fromInts(
173
+						0, self::chrToInt($in[4])
174
+					)
175
+				);
176
+			case 4:
177
+				$b = $b->orInt64(
178
+					ParagonIE_Sodium_Core32_Int64::fromInts(
179
+						self::chrToInt($in[3]) << 24, 0
180
+					)
181
+				);
182
+			case 3:
183
+				$b = $b->orInt64(
184
+					ParagonIE_Sodium_Core32_Int64::fromInts(
185
+						self::chrToInt($in[2]) << 16, 0
186
+					)
187
+				);
188
+			case 2:
189
+				$b = $b->orInt64(
190
+					ParagonIE_Sodium_Core32_Int64::fromInts(
191
+						self::chrToInt($in[1]) << 8, 0
192
+					)
193
+				);
194
+			case 1:
195
+				$b = $b->orInt64(
196
+					ParagonIE_Sodium_Core32_Int64::fromInts(
197
+						self::chrToInt($in[0]), 0
198
+					)
199
+				);
200
+			case 0:
201
+				break;
202
+		}
203
+		// See docblock for why the 0th index gets the higher bits.
204
+
205
+		# v3 ^= b;
206
+		$v[3] = $v[3]->xorInt64($b);
207
+
208
+		# SIPROUND;
209
+		# SIPROUND;
210
+		$v = self::sipRound($v);
211
+		$v = self::sipRound($v);
212
+
213
+		# v0 ^= b;
214
+		$v[0] = $v[0]->xorInt64($b);
215
+
216
+		// Flip the lower 8 bits of v2 which is ($v[4], $v[5]) in our implementation
217
+		# v2 ^= 0xff;
218
+		$v[2]->limbs[3] ^= 0xff;
219
+
220
+		# SIPROUND;
221
+		# SIPROUND;
222
+		# SIPROUND;
223
+		# SIPROUND;
224
+		$v = self::sipRound($v);
225
+		$v = self::sipRound($v);
226
+		$v = self::sipRound($v);
227
+		$v = self::sipRound($v);
228
+
229
+		# b = v0 ^ v1 ^ v2 ^ v3;
230
+		# STORE64_LE( out, b );
231
+		return $v[0]
232
+			->xorInt64($v[1])
233
+			->xorInt64($v[2])
234
+			->xorInt64($v[3])
235
+			->toReverseString();
236
+	}
237 237
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_SipHash', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_SipHash', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -17,49 +17,49 @@  discard block
 block discarded – undo
17 17
      * @param array<int, ParagonIE_Sodium_Core32_Int64> $v
18 18
      * @return array<int, ParagonIE_Sodium_Core32_Int64>
19 19
      */
20
-    public static function sipRound(array $v)
20
+    public static function sipRound( array $v )
21 21
     {
22 22
         # v0 += v1;
23
-        $v[0] = $v[0]->addInt64($v[1]);
23
+        $v[0] = $v[0]->addInt64( $v[1] );
24 24
 
25 25
         # v1 = ROTL(v1, 13);
26
-        $v[1] = $v[1]->rotateLeft(13);
26
+        $v[1] = $v[1]->rotateLeft( 13 );
27 27
 
28 28
         #  v1 ^= v0;
29
-        $v[1] = $v[1]->xorInt64($v[0]);
29
+        $v[1] = $v[1]->xorInt64( $v[0] );
30 30
 
31 31
         #  v0=ROTL(v0,32);
32
-        $v[0] = $v[0]->rotateLeft(32);
32
+        $v[0] = $v[0]->rotateLeft( 32 );
33 33
 
34 34
         # v2 += v3;
35
-        $v[2] = $v[2]->addInt64($v[3]);
35
+        $v[2] = $v[2]->addInt64( $v[3] );
36 36
 
37 37
         # v3=ROTL(v3,16);
38
-        $v[3] = $v[3]->rotateLeft(16);
38
+        $v[3] = $v[3]->rotateLeft( 16 );
39 39
 
40 40
         #  v3 ^= v2;
41
-        $v[3] = $v[3]->xorInt64($v[2]);
41
+        $v[3] = $v[3]->xorInt64( $v[2] );
42 42
 
43 43
         # v0 += v3;
44
-        $v[0] = $v[0]->addInt64($v[3]);
44
+        $v[0] = $v[0]->addInt64( $v[3] );
45 45
 
46 46
         # v3=ROTL(v3,21);
47
-        $v[3] = $v[3]->rotateLeft(21);
47
+        $v[3] = $v[3]->rotateLeft( 21 );
48 48
 
49 49
         # v3 ^= v0;
50
-        $v[3] = $v[3]->xorInt64($v[0]);
50
+        $v[3] = $v[3]->xorInt64( $v[0] );
51 51
 
52 52
         # v2 += v1;
53
-        $v[2] = $v[2]->addInt64($v[1]);
53
+        $v[2] = $v[2]->addInt64( $v[1] );
54 54
 
55 55
         # v1=ROTL(v1,17);
56
-        $v[1] = $v[1]->rotateLeft(17);
56
+        $v[1] = $v[1]->rotateLeft( 17 );
57 57
 
58 58
         #  v1 ^= v2;
59
-        $v[1] = $v[1]->xorInt64($v[2]);
59
+        $v[1] = $v[1]->xorInt64( $v[2] );
60 60
 
61 61
         # v2=ROTL(v2,32)
62
-        $v[2] = $v[2]->rotateLeft(32);
62
+        $v[2] = $v[2]->rotateLeft( 32 );
63 63
 
64 64
         return $v;
65 65
     }
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      * @param string $key
72 72
      * @return string
73 73
      */
74
-    public static function sipHash24($in, $key)
74
+    public static function sipHash24( $in, $key )
75 75
     {
76
-        $inlen = self::strlen($in);
76
+        $inlen = self::strlen( $in );
77 77
 
78 78
         # /* "somepseudorandomlygeneratedbytes" */
79 79
         # u64 v0 = 0x736f6d6570736575ULL;
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
         # u64 v3 = 0x7465646279746573ULL;
83 83
         $v = array(
84 84
             new ParagonIE_Sodium_Core32_Int64(
85
-                array(0x736f, 0x6d65, 0x7073, 0x6575)
85
+                array( 0x736f, 0x6d65, 0x7073, 0x6575 )
86 86
             ),
87 87
             new ParagonIE_Sodium_Core32_Int64(
88
-                array(0x646f, 0x7261, 0x6e64, 0x6f6d)
88
+                array( 0x646f, 0x7261, 0x6e64, 0x6f6d )
89 89
             ),
90 90
             new ParagonIE_Sodium_Core32_Int64(
91
-                array(0x6c79, 0x6765, 0x6e65, 0x7261)
91
+                array( 0x6c79, 0x6765, 0x6e65, 0x7261 )
92 92
             ),
93 93
             new ParagonIE_Sodium_Core32_Int64(
94
-                array(0x7465, 0x6462, 0x7974, 0x6573)
94
+                array( 0x7465, 0x6462, 0x7974, 0x6573 )
95 95
             )
96 96
         );
97 97
 
@@ -99,47 +99,47 @@  discard block
 block discarded – undo
99 99
         # u64 k1 = LOAD64_LE( k + 8 );
100 100
         $k = array(
101 101
             ParagonIE_Sodium_Core32_Int64::fromReverseString(
102
-                self::substr($key, 0, 8)
102
+                self::substr( $key, 0, 8 )
103 103
             ),
104 104
             ParagonIE_Sodium_Core32_Int64::fromReverseString(
105
-                self::substr($key, 8, 8)
105
+                self::substr( $key, 8, 8 )
106 106
             )
107 107
         );
108 108
 
109 109
         # b = ( ( u64 )inlen ) << 56;
110 110
         $b = new ParagonIE_Sodium_Core32_Int64(
111
-            array(($inlen << 8) & 0xffff, 0, 0, 0)
111
+            array( ( $inlen << 8 ) & 0xffff, 0, 0, 0 )
112 112
         );
113 113
 
114 114
         # v3 ^= k1;
115
-        $v[3] = $v[3]->xorInt64($k[1]);
115
+        $v[3] = $v[3]->xorInt64( $k[1] );
116 116
         # v2 ^= k0;
117
-        $v[2] = $v[2]->xorInt64($k[0]);
117
+        $v[2] = $v[2]->xorInt64( $k[0] );
118 118
         # v1 ^= k1;
119
-        $v[1] = $v[1]->xorInt64($k[1]);
119
+        $v[1] = $v[1]->xorInt64( $k[1] );
120 120
         # v0 ^= k0;
121
-        $v[0] = $v[0]->xorInt64($k[0]);
121
+        $v[0] = $v[0]->xorInt64( $k[0] );
122 122
 
123 123
         $left = $inlen;
124 124
         # for ( ; in != end; in += 8 )
125
-        while ($left >= 8) {
125
+        while ( $left >= 8 ) {
126 126
             # m = LOAD64_LE( in );
127 127
             $m = ParagonIE_Sodium_Core32_Int64::fromReverseString(
128
-                self::substr($in, 0, 8)
128
+                self::substr( $in, 0, 8 )
129 129
             );
130 130
 
131 131
             # v3 ^= m;
132
-            $v[3] = $v[3]->xorInt64($m);
132
+            $v[3] = $v[3]->xorInt64( $m );
133 133
 
134 134
             # SIPROUND;
135 135
             # SIPROUND;
136
-            $v = self::sipRound($v);
137
-            $v = self::sipRound($v);
136
+            $v = self::sipRound( $v );
137
+            $v = self::sipRound( $v );
138 138
 
139 139
             # v0 ^= m;
140
-            $v[0] = $v[0]->xorInt64($m);
140
+            $v[0] = $v[0]->xorInt64( $m );
141 141
 
142
-            $in = self::substr($in, 8);
142
+            $in = self::substr( $in, 8 );
143 143
             $left -= 8;
144 144
         }
145 145
 
@@ -154,47 +154,47 @@  discard block
 block discarded – undo
154 154
         #     case 1: b |= ( ( u64 )in[ 0] ); break;
155 155
         #     case 0: break;
156 156
         # }
157
-        switch ($left) {
157
+        switch ( $left ) {
158 158
             case 7:
159 159
                 $b = $b->orInt64(
160 160
                     ParagonIE_Sodium_Core32_Int64::fromInts(
161
-                        0, self::chrToInt($in[6]) << 16
161
+                        0, self::chrToInt( $in[6] ) << 16
162 162
                     )
163 163
                 );
164 164
             case 6:
165 165
                 $b = $b->orInt64(
166 166
                     ParagonIE_Sodium_Core32_Int64::fromInts(
167
-                        0, self::chrToInt($in[5]) << 8
167
+                        0, self::chrToInt( $in[5] ) << 8
168 168
                     )
169 169
                 );
170 170
             case 5:
171 171
                 $b = $b->orInt64(
172 172
                     ParagonIE_Sodium_Core32_Int64::fromInts(
173
-                        0, self::chrToInt($in[4])
173
+                        0, self::chrToInt( $in[4] )
174 174
                     )
175 175
                 );
176 176
             case 4:
177 177
                 $b = $b->orInt64(
178 178
                     ParagonIE_Sodium_Core32_Int64::fromInts(
179
-                        self::chrToInt($in[3]) << 24, 0
179
+                        self::chrToInt( $in[3] ) << 24, 0
180 180
                     )
181 181
                 );
182 182
             case 3:
183 183
                 $b = $b->orInt64(
184 184
                     ParagonIE_Sodium_Core32_Int64::fromInts(
185
-                        self::chrToInt($in[2]) << 16, 0
185
+                        self::chrToInt( $in[2] ) << 16, 0
186 186
                     )
187 187
                 );
188 188
             case 2:
189 189
                 $b = $b->orInt64(
190 190
                     ParagonIE_Sodium_Core32_Int64::fromInts(
191
-                        self::chrToInt($in[1]) << 8, 0
191
+                        self::chrToInt( $in[1] ) << 8, 0
192 192
                     )
193 193
                 );
194 194
             case 1:
195 195
                 $b = $b->orInt64(
196 196
                     ParagonIE_Sodium_Core32_Int64::fromInts(
197
-                        self::chrToInt($in[0]), 0
197
+                        self::chrToInt( $in[0] ), 0
198 198
                     )
199 199
                 );
200 200
             case 0:
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
         // See docblock for why the 0th index gets the higher bits.
204 204
 
205 205
         # v3 ^= b;
206
-        $v[3] = $v[3]->xorInt64($b);
206
+        $v[3] = $v[3]->xorInt64( $b );
207 207
 
208 208
         # SIPROUND;
209 209
         # SIPROUND;
210
-        $v = self::sipRound($v);
211
-        $v = self::sipRound($v);
210
+        $v = self::sipRound( $v );
211
+        $v = self::sipRound( $v );
212 212
 
213 213
         # v0 ^= b;
214
-        $v[0] = $v[0]->xorInt64($b);
214
+        $v[0] = $v[0]->xorInt64( $b );
215 215
 
216 216
         // Flip the lower 8 bits of v2 which is ($v[4], $v[5]) in our implementation
217 217
         # v2 ^= 0xff;
@@ -221,17 +221,17 @@  discard block
 block discarded – undo
221 221
         # SIPROUND;
222 222
         # SIPROUND;
223 223
         # SIPROUND;
224
-        $v = self::sipRound($v);
225
-        $v = self::sipRound($v);
226
-        $v = self::sipRound($v);
227
-        $v = self::sipRound($v);
224
+        $v = self::sipRound( $v );
225
+        $v = self::sipRound( $v );
226
+        $v = self::sipRound( $v );
227
+        $v = self::sipRound( $v );
228 228
 
229 229
         # b = v0 ^ v1 ^ v2 ^ v3;
230 230
         # STORE64_LE( out, b );
231 231
         return $v[0]
232
-            ->xorInt64($v[1])
233
-            ->xorInt64($v[2])
234
-            ->xorInt64($v[3])
232
+            ->xorInt64( $v[1] )
233
+            ->xorInt64( $v[2] )
234
+            ->xorInt64( $v[3] )
235 235
             ->toReverseString();
236 236
     }
237 237
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,16 +9,14 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * Only uses 32-bit arithmetic, while the original SipHash used 64-bit integers
11 11
  */
12
-class ParagonIE_Sodium_Core32_SipHash extends ParagonIE_Sodium_Core32_Util
13
-{
12
+class ParagonIE_Sodium_Core32_SipHash extends ParagonIE_Sodium_Core32_Util {
14 13
     /**
15 14
      * @internal You should not use this directly from another application
16 15
      *
17 16
      * @param array<int, ParagonIE_Sodium_Core32_Int64> $v
18 17
      * @return array<int, ParagonIE_Sodium_Core32_Int64>
19 18
      */
20
-    public static function sipRound(array $v)
21
-    {
19
+    public static function sipRound(array $v) {
22 20
         # v0 += v1;
23 21
         $v[0] = $v[0]->addInt64($v[1]);
24 22
 
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
      * @param string $key
72 70
      * @return string
73 71
      */
74
-    public static function sipHash24($in, $key)
75
-    {
72
+    public static function sipHash24($in, $key) {
76 73
         $inlen = self::strlen($in);
77 74
 
78 75
         # /* "somepseudorandomlygeneratedbytes" */
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/HSalsa20.php 3 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_HSalsa20', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,131 +9,131 @@  discard block
 block discarded – undo
9 9
  */
10 10
 abstract class ParagonIE_Sodium_Core32_HSalsa20 extends ParagonIE_Sodium_Core32_Salsa20
11 11
 {
12
-    /**
13
-     * Calculate an hsalsa20 hash of a single block
14
-     *
15
-     * HSalsa20 doesn't have a counter and will never be used for more than
16
-     * one block (used to derive a subkey for xsalsa20).
17
-     *
18
-     * @internal You should not use this directly from another application
19
-     *
20
-     * @param string $in
21
-     * @param string $k
22
-     * @param string|null $c
23
-     * @return string
24
-     */
25
-    public static function hsalsa20($in, $k, $c = null)
26
-    {
27
-        /**
28
-         * @var ParagonIE_Sodium_Core32_Int32 $x0
29
-         * @var ParagonIE_Sodium_Core32_Int32 $x1
30
-         * @var ParagonIE_Sodium_Core32_Int32 $x2
31
-         * @var ParagonIE_Sodium_Core32_Int32 $x3
32
-         * @var ParagonIE_Sodium_Core32_Int32 $x4
33
-         * @var ParagonIE_Sodium_Core32_Int32 $x5
34
-         * @var ParagonIE_Sodium_Core32_Int32 $x6
35
-         * @var ParagonIE_Sodium_Core32_Int32 $x7
36
-         * @var ParagonIE_Sodium_Core32_Int32 $x8
37
-         * @var ParagonIE_Sodium_Core32_Int32 $x9
38
-         * @var ParagonIE_Sodium_Core32_Int32 $x10
39
-         * @var ParagonIE_Sodium_Core32_Int32 $x11
40
-         * @var ParagonIE_Sodium_Core32_Int32 $x12
41
-         * @var ParagonIE_Sodium_Core32_Int32 $x13
42
-         * @var ParagonIE_Sodium_Core32_Int32 $x14
43
-         * @var ParagonIE_Sodium_Core32_Int32 $x15
44
-         * @var ParagonIE_Sodium_Core32_Int32 $j0
45
-         * @var ParagonIE_Sodium_Core32_Int32 $j1
46
-         * @var ParagonIE_Sodium_Core32_Int32 $j2
47
-         * @var ParagonIE_Sodium_Core32_Int32 $j3
48
-         * @var ParagonIE_Sodium_Core32_Int32 $j4
49
-         * @var ParagonIE_Sodium_Core32_Int32 $j5
50
-         * @var ParagonIE_Sodium_Core32_Int32 $j6
51
-         * @var ParagonIE_Sodium_Core32_Int32 $j7
52
-         * @var ParagonIE_Sodium_Core32_Int32 $j8
53
-         * @var ParagonIE_Sodium_Core32_Int32 $j9
54
-         * @var ParagonIE_Sodium_Core32_Int32 $j10
55
-         * @var ParagonIE_Sodium_Core32_Int32 $j11
56
-         * @var ParagonIE_Sodium_Core32_Int32 $j12
57
-         * @var ParagonIE_Sodium_Core32_Int32 $j13
58
-         * @var ParagonIE_Sodium_Core32_Int32 $j14
59
-         * @var ParagonIE_Sodium_Core32_Int32 $j15
60
-         */
61
-        if (self::strlen($k) < 32) {
62
-            throw new RangeException('Key must be 32 bytes long');
63
-        }
64
-        if ($c === null) {
65
-            $x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
66
-            $x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
67
-            $x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
68
-            $x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
69
-        } else {
70
-            $x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4));
71
-            $x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4));
72
-            $x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4));
73
-            $x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4));
74
-        }
75
-        $x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 0, 4));
76
-        $x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 4, 4));
77
-        $x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 8, 4));
78
-        $x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 12, 4));
79
-        $x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4));
80
-        $x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4));
81
-        $x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4));
82
-        $x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4));
83
-        $x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 16, 4));
84
-        $x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 20, 4));
85
-        $x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 24, 4));
86
-        $x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 28, 4));
12
+	/**
13
+	 * Calculate an hsalsa20 hash of a single block
14
+	 *
15
+	 * HSalsa20 doesn't have a counter and will never be used for more than
16
+	 * one block (used to derive a subkey for xsalsa20).
17
+	 *
18
+	 * @internal You should not use this directly from another application
19
+	 *
20
+	 * @param string $in
21
+	 * @param string $k
22
+	 * @param string|null $c
23
+	 * @return string
24
+	 */
25
+	public static function hsalsa20($in, $k, $c = null)
26
+	{
27
+		/**
28
+		 * @var ParagonIE_Sodium_Core32_Int32 $x0
29
+		 * @var ParagonIE_Sodium_Core32_Int32 $x1
30
+		 * @var ParagonIE_Sodium_Core32_Int32 $x2
31
+		 * @var ParagonIE_Sodium_Core32_Int32 $x3
32
+		 * @var ParagonIE_Sodium_Core32_Int32 $x4
33
+		 * @var ParagonIE_Sodium_Core32_Int32 $x5
34
+		 * @var ParagonIE_Sodium_Core32_Int32 $x6
35
+		 * @var ParagonIE_Sodium_Core32_Int32 $x7
36
+		 * @var ParagonIE_Sodium_Core32_Int32 $x8
37
+		 * @var ParagonIE_Sodium_Core32_Int32 $x9
38
+		 * @var ParagonIE_Sodium_Core32_Int32 $x10
39
+		 * @var ParagonIE_Sodium_Core32_Int32 $x11
40
+		 * @var ParagonIE_Sodium_Core32_Int32 $x12
41
+		 * @var ParagonIE_Sodium_Core32_Int32 $x13
42
+		 * @var ParagonIE_Sodium_Core32_Int32 $x14
43
+		 * @var ParagonIE_Sodium_Core32_Int32 $x15
44
+		 * @var ParagonIE_Sodium_Core32_Int32 $j0
45
+		 * @var ParagonIE_Sodium_Core32_Int32 $j1
46
+		 * @var ParagonIE_Sodium_Core32_Int32 $j2
47
+		 * @var ParagonIE_Sodium_Core32_Int32 $j3
48
+		 * @var ParagonIE_Sodium_Core32_Int32 $j4
49
+		 * @var ParagonIE_Sodium_Core32_Int32 $j5
50
+		 * @var ParagonIE_Sodium_Core32_Int32 $j6
51
+		 * @var ParagonIE_Sodium_Core32_Int32 $j7
52
+		 * @var ParagonIE_Sodium_Core32_Int32 $j8
53
+		 * @var ParagonIE_Sodium_Core32_Int32 $j9
54
+		 * @var ParagonIE_Sodium_Core32_Int32 $j10
55
+		 * @var ParagonIE_Sodium_Core32_Int32 $j11
56
+		 * @var ParagonIE_Sodium_Core32_Int32 $j12
57
+		 * @var ParagonIE_Sodium_Core32_Int32 $j13
58
+		 * @var ParagonIE_Sodium_Core32_Int32 $j14
59
+		 * @var ParagonIE_Sodium_Core32_Int32 $j15
60
+		 */
61
+		if (self::strlen($k) < 32) {
62
+			throw new RangeException('Key must be 32 bytes long');
63
+		}
64
+		if ($c === null) {
65
+			$x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
66
+			$x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
67
+			$x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
68
+			$x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
69
+		} else {
70
+			$x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4));
71
+			$x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4));
72
+			$x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4));
73
+			$x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4));
74
+		}
75
+		$x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 0, 4));
76
+		$x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 4, 4));
77
+		$x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 8, 4));
78
+		$x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 12, 4));
79
+		$x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4));
80
+		$x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4));
81
+		$x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4));
82
+		$x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4));
83
+		$x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 16, 4));
84
+		$x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 20, 4));
85
+		$x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 24, 4));
86
+		$x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 28, 4));
87 87
 
88
-        for ($i = self::ROUNDS; $i > 0; $i -= 2) {
89
-            $x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
90
-            $x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
91
-            $x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
92
-            $x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
88
+		for ($i = self::ROUNDS; $i > 0; $i -= 2) {
89
+			$x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
90
+			$x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
91
+			$x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
92
+			$x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
93 93
 
94
-            $x9  = $x9->xorInt32($x5->addInt32($x1)->rotateLeft(7));
95
-            $x13 = $x13->xorInt32($x9->addInt32($x5)->rotateLeft(9));
96
-            $x1  = $x1->xorInt32($x13->addInt32($x9)->rotateLeft(13));
97
-            $x5  = $x5->xorInt32($x1->addInt32($x13)->rotateLeft(18));
94
+			$x9  = $x9->xorInt32($x5->addInt32($x1)->rotateLeft(7));
95
+			$x13 = $x13->xorInt32($x9->addInt32($x5)->rotateLeft(9));
96
+			$x1  = $x1->xorInt32($x13->addInt32($x9)->rotateLeft(13));
97
+			$x5  = $x5->xorInt32($x1->addInt32($x13)->rotateLeft(18));
98 98
 
99
-            $x14 = $x14->xorInt32($x10->addInt32($x6)->rotateLeft(7));
100
-            $x2  = $x2->xorInt32($x14->addInt32($x10)->rotateLeft(9));
101
-            $x6  = $x6->xorInt32($x2->addInt32($x14)->rotateLeft(13));
102
-            $x10 = $x10->xorInt32($x6->addInt32($x2)->rotateLeft(18));
99
+			$x14 = $x14->xorInt32($x10->addInt32($x6)->rotateLeft(7));
100
+			$x2  = $x2->xorInt32($x14->addInt32($x10)->rotateLeft(9));
101
+			$x6  = $x6->xorInt32($x2->addInt32($x14)->rotateLeft(13));
102
+			$x10 = $x10->xorInt32($x6->addInt32($x2)->rotateLeft(18));
103 103
 
104
-            $x3  = $x3->xorInt32($x15->addInt32($x11)->rotateLeft(7));
105
-            $x7  = $x7->xorInt32($x3->addInt32($x15)->rotateLeft(9));
106
-            $x11 = $x11->xorInt32($x7->addInt32($x3)->rotateLeft(13));
107
-            $x15 = $x15->xorInt32($x11->addInt32($x7)->rotateLeft(18));
104
+			$x3  = $x3->xorInt32($x15->addInt32($x11)->rotateLeft(7));
105
+			$x7  = $x7->xorInt32($x3->addInt32($x15)->rotateLeft(9));
106
+			$x11 = $x11->xorInt32($x7->addInt32($x3)->rotateLeft(13));
107
+			$x15 = $x15->xorInt32($x11->addInt32($x7)->rotateLeft(18));
108 108
 
109
-            $x1  = $x1->xorInt32($x0->addInt32($x3)->rotateLeft(7));
110
-            $x2  = $x2->xorInt32($x1->addInt32($x0)->rotateLeft(9));
111
-            $x3  = $x3->xorInt32($x2->addInt32($x1)->rotateLeft(13));
112
-            $x0  = $x0->xorInt32($x3->addInt32($x2)->rotateLeft(18));
109
+			$x1  = $x1->xorInt32($x0->addInt32($x3)->rotateLeft(7));
110
+			$x2  = $x2->xorInt32($x1->addInt32($x0)->rotateLeft(9));
111
+			$x3  = $x3->xorInt32($x2->addInt32($x1)->rotateLeft(13));
112
+			$x0  = $x0->xorInt32($x3->addInt32($x2)->rotateLeft(18));
113 113
 
114
-            $x6  = $x6->xorInt32($x5->addInt32($x4)->rotateLeft(7));
115
-            $x7  = $x7->xorInt32($x6->addInt32($x5)->rotateLeft(9));
116
-            $x4  = $x4->xorInt32($x7->addInt32($x6)->rotateLeft(13));
117
-            $x5  = $x5->xorInt32($x4->addInt32($x7)->rotateLeft(18));
114
+			$x6  = $x6->xorInt32($x5->addInt32($x4)->rotateLeft(7));
115
+			$x7  = $x7->xorInt32($x6->addInt32($x5)->rotateLeft(9));
116
+			$x4  = $x4->xorInt32($x7->addInt32($x6)->rotateLeft(13));
117
+			$x5  = $x5->xorInt32($x4->addInt32($x7)->rotateLeft(18));
118 118
 
119
-            $x11 = $x11->xorInt32($x10->addInt32($x9)->rotateLeft(7));
120
-            $x8  = $x8->xorInt32($x11->addInt32($x10)->rotateLeft(9));
121
-            $x9  = $x9->xorInt32($x8->addInt32($x11)->rotateLeft(13));
122
-            $x10 = $x10->xorInt32($x9->addInt32($x8)->rotateLeft(18));
119
+			$x11 = $x11->xorInt32($x10->addInt32($x9)->rotateLeft(7));
120
+			$x8  = $x8->xorInt32($x11->addInt32($x10)->rotateLeft(9));
121
+			$x9  = $x9->xorInt32($x8->addInt32($x11)->rotateLeft(13));
122
+			$x10 = $x10->xorInt32($x9->addInt32($x8)->rotateLeft(18));
123 123
 
124
-            $x12 = $x12->xorInt32($x15->addInt32($x14)->rotateLeft(7));
125
-            $x13 = $x13->xorInt32($x12->addInt32($x15)->rotateLeft(9));
126
-            $x14 = $x14->xorInt32($x13->addInt32($x12)->rotateLeft(13));
127
-            $x15 = $x15->xorInt32($x14->addInt32($x13)->rotateLeft(18));
128
-        }
124
+			$x12 = $x12->xorInt32($x15->addInt32($x14)->rotateLeft(7));
125
+			$x13 = $x13->xorInt32($x12->addInt32($x15)->rotateLeft(9));
126
+			$x14 = $x14->xorInt32($x13->addInt32($x12)->rotateLeft(13));
127
+			$x15 = $x15->xorInt32($x14->addInt32($x13)->rotateLeft(18));
128
+		}
129 129
 
130
-        return $x0->toReverseString() .
131
-            $x5->toReverseString() .
132
-            $x10->toReverseString() .
133
-            $x15->toReverseString() .
134
-            $x6->toReverseString() .
135
-            $x7->toReverseString() .
136
-            $x8->toReverseString() .
137
-            $x9->toReverseString();
138
-    }
130
+		return $x0->toReverseString() .
131
+			$x5->toReverseString() .
132
+			$x10->toReverseString() .
133
+			$x15->toReverseString() .
134
+			$x6->toReverseString() .
135
+			$x7->toReverseString() .
136
+			$x8->toReverseString() .
137
+			$x9->toReverseString();
138
+	}
139 139
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_HSalsa20', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_HSalsa20', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param string|null $c
23 23
      * @return string
24 24
      */
25
-    public static function hsalsa20($in, $k, $c = null)
25
+    public static function hsalsa20( $in, $k, $c = null )
26 26
     {
27 27
         /**
28 28
          * @var ParagonIE_Sodium_Core32_Int32 $x0
@@ -58,73 +58,73 @@  discard block
 block discarded – undo
58 58
          * @var ParagonIE_Sodium_Core32_Int32 $j14
59 59
          * @var ParagonIE_Sodium_Core32_Int32 $j15
60 60
          */
61
-        if (self::strlen($k) < 32) {
62
-            throw new RangeException('Key must be 32 bytes long');
61
+        if ( self::strlen( $k ) < 32 ) {
62
+            throw new RangeException( 'Key must be 32 bytes long' );
63 63
         }
64
-        if ($c === null) {
65
-            $x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
66
-            $x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
67
-            $x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
68
-            $x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
64
+        if ( $c === null ) {
65
+            $x0  = new ParagonIE_Sodium_Core32_Int32( array( 0x6170, 0x7865 ) );
66
+            $x5  = new ParagonIE_Sodium_Core32_Int32( array( 0x3320, 0x646e ) );
67
+            $x10 = new ParagonIE_Sodium_Core32_Int32( array( 0x7962, 0x2d32 ) );
68
+            $x15 = new ParagonIE_Sodium_Core32_Int32( array( 0x6b20, 0x6574 ) );
69 69
         } else {
70
-            $x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4));
71
-            $x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4));
72
-            $x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4));
73
-            $x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4));
70
+            $x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 0, 4 ) );
71
+            $x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 4, 4 ) );
72
+            $x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 8, 4 ) );
73
+            $x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 12, 4 ) );
74 74
         }
75
-        $x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 0, 4));
76
-        $x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 4, 4));
77
-        $x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 8, 4));
78
-        $x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 12, 4));
79
-        $x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4));
80
-        $x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4));
81
-        $x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4));
82
-        $x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4));
83
-        $x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 16, 4));
84
-        $x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 20, 4));
85
-        $x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 24, 4));
86
-        $x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 28, 4));
75
+        $x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 0, 4 ) );
76
+        $x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 4, 4 ) );
77
+        $x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 8, 4 ) );
78
+        $x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 12, 4 ) );
79
+        $x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 0, 4 ) );
80
+        $x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 4, 4 ) );
81
+        $x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 8, 4 ) );
82
+        $x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 12, 4 ) );
83
+        $x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 16, 4 ) );
84
+        $x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 20, 4 ) );
85
+        $x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 24, 4 ) );
86
+        $x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 28, 4 ) );
87 87
 
88
-        for ($i = self::ROUNDS; $i > 0; $i -= 2) {
89
-            $x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
90
-            $x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
91
-            $x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
92
-            $x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
88
+        for ( $i = self::ROUNDS; $i > 0; $i -= 2 ) {
89
+            $x4  = $x4->xorInt32( $x0->addInt32( $x12 )->rotateLeft( 7 ) );
90
+            $x8  = $x8->xorInt32( $x4->addInt32( $x0 )->rotateLeft( 9 ) );
91
+            $x12 = $x12->xorInt32( $x8->addInt32( $x4 )->rotateLeft( 13 ) );
92
+            $x0  = $x0->xorInt32( $x12->addInt32( $x8 )->rotateLeft( 18 ) );
93 93
 
94
-            $x9  = $x9->xorInt32($x5->addInt32($x1)->rotateLeft(7));
95
-            $x13 = $x13->xorInt32($x9->addInt32($x5)->rotateLeft(9));
96
-            $x1  = $x1->xorInt32($x13->addInt32($x9)->rotateLeft(13));
97
-            $x5  = $x5->xorInt32($x1->addInt32($x13)->rotateLeft(18));
94
+            $x9  = $x9->xorInt32( $x5->addInt32( $x1 )->rotateLeft( 7 ) );
95
+            $x13 = $x13->xorInt32( $x9->addInt32( $x5 )->rotateLeft( 9 ) );
96
+            $x1  = $x1->xorInt32( $x13->addInt32( $x9 )->rotateLeft( 13 ) );
97
+            $x5  = $x5->xorInt32( $x1->addInt32( $x13 )->rotateLeft( 18 ) );
98 98
 
99
-            $x14 = $x14->xorInt32($x10->addInt32($x6)->rotateLeft(7));
100
-            $x2  = $x2->xorInt32($x14->addInt32($x10)->rotateLeft(9));
101
-            $x6  = $x6->xorInt32($x2->addInt32($x14)->rotateLeft(13));
102
-            $x10 = $x10->xorInt32($x6->addInt32($x2)->rotateLeft(18));
99
+            $x14 = $x14->xorInt32( $x10->addInt32( $x6 )->rotateLeft( 7 ) );
100
+            $x2  = $x2->xorInt32( $x14->addInt32( $x10 )->rotateLeft( 9 ) );
101
+            $x6  = $x6->xorInt32( $x2->addInt32( $x14 )->rotateLeft( 13 ) );
102
+            $x10 = $x10->xorInt32( $x6->addInt32( $x2 )->rotateLeft( 18 ) );
103 103
 
104
-            $x3  = $x3->xorInt32($x15->addInt32($x11)->rotateLeft(7));
105
-            $x7  = $x7->xorInt32($x3->addInt32($x15)->rotateLeft(9));
106
-            $x11 = $x11->xorInt32($x7->addInt32($x3)->rotateLeft(13));
107
-            $x15 = $x15->xorInt32($x11->addInt32($x7)->rotateLeft(18));
104
+            $x3  = $x3->xorInt32( $x15->addInt32( $x11 )->rotateLeft( 7 ) );
105
+            $x7  = $x7->xorInt32( $x3->addInt32( $x15 )->rotateLeft( 9 ) );
106
+            $x11 = $x11->xorInt32( $x7->addInt32( $x3 )->rotateLeft( 13 ) );
107
+            $x15 = $x15->xorInt32( $x11->addInt32( $x7 )->rotateLeft( 18 ) );
108 108
 
109
-            $x1  = $x1->xorInt32($x0->addInt32($x3)->rotateLeft(7));
110
-            $x2  = $x2->xorInt32($x1->addInt32($x0)->rotateLeft(9));
111
-            $x3  = $x3->xorInt32($x2->addInt32($x1)->rotateLeft(13));
112
-            $x0  = $x0->xorInt32($x3->addInt32($x2)->rotateLeft(18));
109
+            $x1  = $x1->xorInt32( $x0->addInt32( $x3 )->rotateLeft( 7 ) );
110
+            $x2  = $x2->xorInt32( $x1->addInt32( $x0 )->rotateLeft( 9 ) );
111
+            $x3  = $x3->xorInt32( $x2->addInt32( $x1 )->rotateLeft( 13 ) );
112
+            $x0  = $x0->xorInt32( $x3->addInt32( $x2 )->rotateLeft( 18 ) );
113 113
 
114
-            $x6  = $x6->xorInt32($x5->addInt32($x4)->rotateLeft(7));
115
-            $x7  = $x7->xorInt32($x6->addInt32($x5)->rotateLeft(9));
116
-            $x4  = $x4->xorInt32($x7->addInt32($x6)->rotateLeft(13));
117
-            $x5  = $x5->xorInt32($x4->addInt32($x7)->rotateLeft(18));
114
+            $x6  = $x6->xorInt32( $x5->addInt32( $x4 )->rotateLeft( 7 ) );
115
+            $x7  = $x7->xorInt32( $x6->addInt32( $x5 )->rotateLeft( 9 ) );
116
+            $x4  = $x4->xorInt32( $x7->addInt32( $x6 )->rotateLeft( 13 ) );
117
+            $x5  = $x5->xorInt32( $x4->addInt32( $x7 )->rotateLeft( 18 ) );
118 118
 
119
-            $x11 = $x11->xorInt32($x10->addInt32($x9)->rotateLeft(7));
120
-            $x8  = $x8->xorInt32($x11->addInt32($x10)->rotateLeft(9));
121
-            $x9  = $x9->xorInt32($x8->addInt32($x11)->rotateLeft(13));
122
-            $x10 = $x10->xorInt32($x9->addInt32($x8)->rotateLeft(18));
119
+            $x11 = $x11->xorInt32( $x10->addInt32( $x9 )->rotateLeft( 7 ) );
120
+            $x8  = $x8->xorInt32( $x11->addInt32( $x10 )->rotateLeft( 9 ) );
121
+            $x9  = $x9->xorInt32( $x8->addInt32( $x11 )->rotateLeft( 13 ) );
122
+            $x10 = $x10->xorInt32( $x9->addInt32( $x8 )->rotateLeft( 18 ) );
123 123
 
124
-            $x12 = $x12->xorInt32($x15->addInt32($x14)->rotateLeft(7));
125
-            $x13 = $x13->xorInt32($x12->addInt32($x15)->rotateLeft(9));
126
-            $x14 = $x14->xorInt32($x13->addInt32($x12)->rotateLeft(13));
127
-            $x15 = $x15->xorInt32($x14->addInt32($x13)->rotateLeft(18));
124
+            $x12 = $x12->xorInt32( $x15->addInt32( $x14 )->rotateLeft( 7 ) );
125
+            $x13 = $x13->xorInt32( $x12->addInt32( $x15 )->rotateLeft( 9 ) );
126
+            $x14 = $x14->xorInt32( $x13->addInt32( $x12 )->rotateLeft( 13 ) );
127
+            $x15 = $x15->xorInt32( $x14->addInt32( $x13 )->rotateLeft( 18 ) );
128 128
         }
129 129
 
130 130
         return $x0->toReverseString() .
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_HSalsa20
9 9
  */
10
-abstract class ParagonIE_Sodium_Core32_HSalsa20 extends ParagonIE_Sodium_Core32_Salsa20
11
-{
10
+abstract class ParagonIE_Sodium_Core32_HSalsa20 extends ParagonIE_Sodium_Core32_Salsa20 {
12 11
     /**
13 12
      * Calculate an hsalsa20 hash of a single block
14 13
      *
@@ -22,8 +21,7 @@  discard block
 block discarded – undo
22 21
      * @param string|null $c
23 22
      * @return string
24 23
      */
25
-    public static function hsalsa20($in, $k, $c = null)
26
-    {
24
+    public static function hsalsa20($in, $k, $c = null) {
27 25
         /**
28 26
          * @var ParagonIE_Sodium_Core32_Int32 $x0
29 27
          * @var ParagonIE_Sodium_Core32_Int32 $x1
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/Salsa20.php 3 patches
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_Salsa20', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,290 +9,290 @@  discard block
 block discarded – undo
9 9
  */
10 10
 abstract class ParagonIE_Sodium_Core32_Salsa20 extends ParagonIE_Sodium_Core32_Util
11 11
 {
12
-    const ROUNDS = 20;
12
+	const ROUNDS = 20;
13 13
 
14
-    /**
15
-     * Calculate an salsa20 hash of a single block
16
-     *
17
-     * @internal You should not use this directly from another application
18
-     *
19
-     * @param string $in
20
-     * @param string $k
21
-     * @param string|null $c
22
-     * @return string
23
-     */
24
-    public static function core_salsa20($in, $k, $c = null)
25
-    {
26
-        /**
27
-         * @var ParagonIE_Sodium_Core32_Int32 $x0
28
-         * @var ParagonIE_Sodium_Core32_Int32 $x1
29
-         * @var ParagonIE_Sodium_Core32_Int32 $x2
30
-         * @var ParagonIE_Sodium_Core32_Int32 $x3
31
-         * @var ParagonIE_Sodium_Core32_Int32 $x4
32
-         * @var ParagonIE_Sodium_Core32_Int32 $x5
33
-         * @var ParagonIE_Sodium_Core32_Int32 $x6
34
-         * @var ParagonIE_Sodium_Core32_Int32 $x7
35
-         * @var ParagonIE_Sodium_Core32_Int32 $x8
36
-         * @var ParagonIE_Sodium_Core32_Int32 $x9
37
-         * @var ParagonIE_Sodium_Core32_Int32 $x10
38
-         * @var ParagonIE_Sodium_Core32_Int32 $x11
39
-         * @var ParagonIE_Sodium_Core32_Int32 $x12
40
-         * @var ParagonIE_Sodium_Core32_Int32 $x13
41
-         * @var ParagonIE_Sodium_Core32_Int32 $x14
42
-         * @var ParagonIE_Sodium_Core32_Int32 $x15
43
-         * @var ParagonIE_Sodium_Core32_Int32 $j0
44
-         * @var ParagonIE_Sodium_Core32_Int32 $j1
45
-         * @var ParagonIE_Sodium_Core32_Int32 $j2
46
-         * @var ParagonIE_Sodium_Core32_Int32 $j3
47
-         * @var ParagonIE_Sodium_Core32_Int32 $j4
48
-         * @var ParagonIE_Sodium_Core32_Int32 $j5
49
-         * @var ParagonIE_Sodium_Core32_Int32 $j6
50
-         * @var ParagonIE_Sodium_Core32_Int32 $j7
51
-         * @var ParagonIE_Sodium_Core32_Int32 $j8
52
-         * @var ParagonIE_Sodium_Core32_Int32 $j9
53
-         * @var ParagonIE_Sodium_Core32_Int32 $j10
54
-         * @var ParagonIE_Sodium_Core32_Int32 $j11
55
-         * @var ParagonIE_Sodium_Core32_Int32 $j12
56
-         * @var ParagonIE_Sodium_Core32_Int32 $j13
57
-         * @var ParagonIE_Sodium_Core32_Int32 $j14
58
-         * @var ParagonIE_Sodium_Core32_Int32 $j15
59
-         */
60
-        if (self::strlen($k) < 32) {
61
-            throw new RangeException('Key must be 32 bytes long');
62
-        }
63
-        if ($c === null) {
64
-            $x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
65
-            $x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
66
-            $x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
67
-            $x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
68
-        } else {
69
-            $x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4));
70
-            $x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4));
71
-            $x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4));
72
-            $x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4));
73
-        }
74
-        $x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 0, 4));
75
-        $x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 4, 4));
76
-        $x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 8, 4));
77
-        $x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 12, 4));
78
-        $x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4));
79
-        $x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4));
80
-        $x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4));
81
-        $x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4));
82
-        $x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 16, 4));
83
-        $x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 20, 4));
84
-        $x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 24, 4));
85
-        $x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 28, 4));
14
+	/**
15
+	 * Calculate an salsa20 hash of a single block
16
+	 *
17
+	 * @internal You should not use this directly from another application
18
+	 *
19
+	 * @param string $in
20
+	 * @param string $k
21
+	 * @param string|null $c
22
+	 * @return string
23
+	 */
24
+	public static function core_salsa20($in, $k, $c = null)
25
+	{
26
+		/**
27
+		 * @var ParagonIE_Sodium_Core32_Int32 $x0
28
+		 * @var ParagonIE_Sodium_Core32_Int32 $x1
29
+		 * @var ParagonIE_Sodium_Core32_Int32 $x2
30
+		 * @var ParagonIE_Sodium_Core32_Int32 $x3
31
+		 * @var ParagonIE_Sodium_Core32_Int32 $x4
32
+		 * @var ParagonIE_Sodium_Core32_Int32 $x5
33
+		 * @var ParagonIE_Sodium_Core32_Int32 $x6
34
+		 * @var ParagonIE_Sodium_Core32_Int32 $x7
35
+		 * @var ParagonIE_Sodium_Core32_Int32 $x8
36
+		 * @var ParagonIE_Sodium_Core32_Int32 $x9
37
+		 * @var ParagonIE_Sodium_Core32_Int32 $x10
38
+		 * @var ParagonIE_Sodium_Core32_Int32 $x11
39
+		 * @var ParagonIE_Sodium_Core32_Int32 $x12
40
+		 * @var ParagonIE_Sodium_Core32_Int32 $x13
41
+		 * @var ParagonIE_Sodium_Core32_Int32 $x14
42
+		 * @var ParagonIE_Sodium_Core32_Int32 $x15
43
+		 * @var ParagonIE_Sodium_Core32_Int32 $j0
44
+		 * @var ParagonIE_Sodium_Core32_Int32 $j1
45
+		 * @var ParagonIE_Sodium_Core32_Int32 $j2
46
+		 * @var ParagonIE_Sodium_Core32_Int32 $j3
47
+		 * @var ParagonIE_Sodium_Core32_Int32 $j4
48
+		 * @var ParagonIE_Sodium_Core32_Int32 $j5
49
+		 * @var ParagonIE_Sodium_Core32_Int32 $j6
50
+		 * @var ParagonIE_Sodium_Core32_Int32 $j7
51
+		 * @var ParagonIE_Sodium_Core32_Int32 $j8
52
+		 * @var ParagonIE_Sodium_Core32_Int32 $j9
53
+		 * @var ParagonIE_Sodium_Core32_Int32 $j10
54
+		 * @var ParagonIE_Sodium_Core32_Int32 $j11
55
+		 * @var ParagonIE_Sodium_Core32_Int32 $j12
56
+		 * @var ParagonIE_Sodium_Core32_Int32 $j13
57
+		 * @var ParagonIE_Sodium_Core32_Int32 $j14
58
+		 * @var ParagonIE_Sodium_Core32_Int32 $j15
59
+		 */
60
+		if (self::strlen($k) < 32) {
61
+			throw new RangeException('Key must be 32 bytes long');
62
+		}
63
+		if ($c === null) {
64
+			$x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
65
+			$x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
66
+			$x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
67
+			$x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
68
+		} else {
69
+			$x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4));
70
+			$x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4));
71
+			$x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4));
72
+			$x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4));
73
+		}
74
+		$x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 0, 4));
75
+		$x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 4, 4));
76
+		$x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 8, 4));
77
+		$x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 12, 4));
78
+		$x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4));
79
+		$x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4));
80
+		$x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4));
81
+		$x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4));
82
+		$x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 16, 4));
83
+		$x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 20, 4));
84
+		$x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 24, 4));
85
+		$x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 28, 4));
86 86
 
87
-        $j0  = clone $x0;
88
-        $j1  = clone $x1;
89
-        $j2  = clone $x2;
90
-        $j3  = clone $x3;
91
-        $j4  = clone $x4;
92
-        $j5  = clone $x5;
93
-        $j6  = clone $x6;
94
-        $j7  = clone $x7;
95
-        $j8  = clone $x8;
96
-        $j9  = clone $x9;
97
-        $j10  = clone $x10;
98
-        $j11  = clone $x11;
99
-        $j12  = clone $x12;
100
-        $j13  = clone $x13;
101
-        $j14  = clone $x14;
102
-        $j15  = clone $x15;
87
+		$j0  = clone $x0;
88
+		$j1  = clone $x1;
89
+		$j2  = clone $x2;
90
+		$j3  = clone $x3;
91
+		$j4  = clone $x4;
92
+		$j5  = clone $x5;
93
+		$j6  = clone $x6;
94
+		$j7  = clone $x7;
95
+		$j8  = clone $x8;
96
+		$j9  = clone $x9;
97
+		$j10  = clone $x10;
98
+		$j11  = clone $x11;
99
+		$j12  = clone $x12;
100
+		$j13  = clone $x13;
101
+		$j14  = clone $x14;
102
+		$j15  = clone $x15;
103 103
 
104
-        for ($i = self::ROUNDS; $i > 0; $i -= 2) {
105
-            $x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
106
-            $x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
107
-            $x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
108
-            $x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
104
+		for ($i = self::ROUNDS; $i > 0; $i -= 2) {
105
+			$x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
106
+			$x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
107
+			$x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
108
+			$x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
109 109
 
110
-            $x9  = $x9->xorInt32($x5->addInt32($x1)->rotateLeft(7));
111
-            $x13 = $x13->xorInt32($x9->addInt32($x5)->rotateLeft(9));
112
-            $x1  = $x1->xorInt32($x13->addInt32($x9)->rotateLeft(13));
113
-            $x5  = $x5->xorInt32($x1->addInt32($x13)->rotateLeft(18));
110
+			$x9  = $x9->xorInt32($x5->addInt32($x1)->rotateLeft(7));
111
+			$x13 = $x13->xorInt32($x9->addInt32($x5)->rotateLeft(9));
112
+			$x1  = $x1->xorInt32($x13->addInt32($x9)->rotateLeft(13));
113
+			$x5  = $x5->xorInt32($x1->addInt32($x13)->rotateLeft(18));
114 114
 
115
-            $x14 = $x14->xorInt32($x10->addInt32($x6)->rotateLeft(7));
116
-            $x2  = $x2->xorInt32($x14->addInt32($x10)->rotateLeft(9));
117
-            $x6  = $x6->xorInt32($x2->addInt32($x14)->rotateLeft(13));
118
-            $x10 = $x10->xorInt32($x6->addInt32($x2)->rotateLeft(18));
115
+			$x14 = $x14->xorInt32($x10->addInt32($x6)->rotateLeft(7));
116
+			$x2  = $x2->xorInt32($x14->addInt32($x10)->rotateLeft(9));
117
+			$x6  = $x6->xorInt32($x2->addInt32($x14)->rotateLeft(13));
118
+			$x10 = $x10->xorInt32($x6->addInt32($x2)->rotateLeft(18));
119 119
 
120
-            $x3  = $x3->xorInt32($x15->addInt32($x11)->rotateLeft(7));
121
-            $x7  = $x7->xorInt32($x3->addInt32($x15)->rotateLeft(9));
122
-            $x11 = $x11->xorInt32($x7->addInt32($x3)->rotateLeft(13));
123
-            $x15 = $x15->xorInt32($x11->addInt32($x7)->rotateLeft(18));
120
+			$x3  = $x3->xorInt32($x15->addInt32($x11)->rotateLeft(7));
121
+			$x7  = $x7->xorInt32($x3->addInt32($x15)->rotateLeft(9));
122
+			$x11 = $x11->xorInt32($x7->addInt32($x3)->rotateLeft(13));
123
+			$x15 = $x15->xorInt32($x11->addInt32($x7)->rotateLeft(18));
124 124
 
125
-            $x1  = $x1->xorInt32($x0->addInt32($x3)->rotateLeft(7));
126
-            $x2  = $x2->xorInt32($x1->addInt32($x0)->rotateLeft(9));
127
-            $x3  = $x3->xorInt32($x2->addInt32($x1)->rotateLeft(13));
128
-            $x0  = $x0->xorInt32($x3->addInt32($x2)->rotateLeft(18));
125
+			$x1  = $x1->xorInt32($x0->addInt32($x3)->rotateLeft(7));
126
+			$x2  = $x2->xorInt32($x1->addInt32($x0)->rotateLeft(9));
127
+			$x3  = $x3->xorInt32($x2->addInt32($x1)->rotateLeft(13));
128
+			$x0  = $x0->xorInt32($x3->addInt32($x2)->rotateLeft(18));
129 129
 
130
-            $x6  = $x6->xorInt32($x5->addInt32($x4)->rotateLeft(7));
131
-            $x7  = $x7->xorInt32($x6->addInt32($x5)->rotateLeft(9));
132
-            $x4  = $x4->xorInt32($x7->addInt32($x6)->rotateLeft(13));
133
-            $x5  = $x5->xorInt32($x4->addInt32($x7)->rotateLeft(18));
130
+			$x6  = $x6->xorInt32($x5->addInt32($x4)->rotateLeft(7));
131
+			$x7  = $x7->xorInt32($x6->addInt32($x5)->rotateLeft(9));
132
+			$x4  = $x4->xorInt32($x7->addInt32($x6)->rotateLeft(13));
133
+			$x5  = $x5->xorInt32($x4->addInt32($x7)->rotateLeft(18));
134 134
 
135
-            $x11 = $x11->xorInt32($x10->addInt32($x9)->rotateLeft(7));
136
-            $x8  = $x8->xorInt32($x11->addInt32($x10)->rotateLeft(9));
137
-            $x9  = $x9->xorInt32($x8->addInt32($x11)->rotateLeft(13));
138
-            $x10 = $x10->xorInt32($x9->addInt32($x8)->rotateLeft(18));
135
+			$x11 = $x11->xorInt32($x10->addInt32($x9)->rotateLeft(7));
136
+			$x8  = $x8->xorInt32($x11->addInt32($x10)->rotateLeft(9));
137
+			$x9  = $x9->xorInt32($x8->addInt32($x11)->rotateLeft(13));
138
+			$x10 = $x10->xorInt32($x9->addInt32($x8)->rotateLeft(18));
139 139
 
140
-            $x12 = $x12->xorInt32($x15->addInt32($x14)->rotateLeft(7));
141
-            $x13 = $x13->xorInt32($x12->addInt32($x15)->rotateLeft(9));
142
-            $x14 = $x14->xorInt32($x13->addInt32($x12)->rotateLeft(13));
143
-            $x15 = $x15->xorInt32($x14->addInt32($x13)->rotateLeft(18));
144
-        }
140
+			$x12 = $x12->xorInt32($x15->addInt32($x14)->rotateLeft(7));
141
+			$x13 = $x13->xorInt32($x12->addInt32($x15)->rotateLeft(9));
142
+			$x14 = $x14->xorInt32($x13->addInt32($x12)->rotateLeft(13));
143
+			$x15 = $x15->xorInt32($x14->addInt32($x13)->rotateLeft(18));
144
+		}
145 145
 
146
-        $x0  = $x0->addInt32($j0);
147
-        $x1  = $x1->addInt32($j1);
148
-        $x2  = $x2->addInt32($j2);
149
-        $x3  = $x3->addInt32($j3);
150
-        $x4  = $x4->addInt32($j4);
151
-        $x5  = $x5->addInt32($j5);
152
-        $x6  = $x6->addInt32($j6);
153
-        $x7  = $x7->addInt32($j7);
154
-        $x8  = $x8->addInt32($j8);
155
-        $x9  = $x9->addInt32($j9);
156
-        $x10 = $x10->addInt32($j10);
157
-        $x11 = $x11->addInt32($j11);
158
-        $x12 = $x12->addInt32($j12);
159
-        $x13 = $x13->addInt32($j13);
160
-        $x14 = $x14->addInt32($j14);
161
-        $x15 = $x15->addInt32($j15);
146
+		$x0  = $x0->addInt32($j0);
147
+		$x1  = $x1->addInt32($j1);
148
+		$x2  = $x2->addInt32($j2);
149
+		$x3  = $x3->addInt32($j3);
150
+		$x4  = $x4->addInt32($j4);
151
+		$x5  = $x5->addInt32($j5);
152
+		$x6  = $x6->addInt32($j6);
153
+		$x7  = $x7->addInt32($j7);
154
+		$x8  = $x8->addInt32($j8);
155
+		$x9  = $x9->addInt32($j9);
156
+		$x10 = $x10->addInt32($j10);
157
+		$x11 = $x11->addInt32($j11);
158
+		$x12 = $x12->addInt32($j12);
159
+		$x13 = $x13->addInt32($j13);
160
+		$x14 = $x14->addInt32($j14);
161
+		$x15 = $x15->addInt32($j15);
162 162
 
163
-        return $x0->toReverseString() .
164
-            $x1->toReverseString() .
165
-            $x2->toReverseString() .
166
-            $x3->toReverseString() .
167
-            $x4->toReverseString() .
168
-            $x5->toReverseString() .
169
-            $x6->toReverseString() .
170
-            $x7->toReverseString() .
171
-            $x8->toReverseString() .
172
-            $x9->toReverseString() .
173
-            $x10->toReverseString() .
174
-            $x11->toReverseString() .
175
-            $x12->toReverseString() .
176
-            $x13->toReverseString() .
177
-            $x14->toReverseString() .
178
-            $x15->toReverseString();
179
-    }
163
+		return $x0->toReverseString() .
164
+			$x1->toReverseString() .
165
+			$x2->toReverseString() .
166
+			$x3->toReverseString() .
167
+			$x4->toReverseString() .
168
+			$x5->toReverseString() .
169
+			$x6->toReverseString() .
170
+			$x7->toReverseString() .
171
+			$x8->toReverseString() .
172
+			$x9->toReverseString() .
173
+			$x10->toReverseString() .
174
+			$x11->toReverseString() .
175
+			$x12->toReverseString() .
176
+			$x13->toReverseString() .
177
+			$x14->toReverseString() .
178
+			$x15->toReverseString();
179
+	}
180 180
 
181
-    /**
182
-     * @internal You should not use this directly from another application
183
-     *
184
-     * @param int $len
185
-     * @param string $nonce
186
-     * @param string $key
187
-     * @return string
188
-     */
189
-    public static function salsa20($len, $nonce, $key)
190
-    {
191
-        if (self::strlen($key) !== 32) {
192
-            throw new RangeException('Key must be 32 bytes long');
193
-        }
194
-        $kcopy = '' . $key;
195
-        $in = self::substr($nonce, 0, 8) . str_repeat("\0", 8);
196
-        $c = '';
197
-        while ($len >= 64) {
198
-            $c .= self::core_salsa20($in, $kcopy, null);
199
-            $u = 1;
200
-            // Internal counter.
201
-            for ($i = 8; $i < 16; ++$i) {
202
-                $u += self::chrToInt($in[$i]);
203
-                $in[$i] = self::intToChr($u & 0xff);
204
-                $u >>= 8;
205
-            }
206
-            $len -= 64;
207
-        }
208
-        if ($len > 0) {
209
-            $c .= self::substr(
210
-                self::core_salsa20($in, $kcopy, null),
211
-                0,
212
-                $len
213
-            );
214
-        }
215
-        try {
216
-            ParagonIE_Sodium_Compat::memzero($kcopy);
217
-        } catch (Error $ex) {
218
-            $kcopy = null;
219
-        }
220
-        return $c;
221
-    }
181
+	/**
182
+	 * @internal You should not use this directly from another application
183
+	 *
184
+	 * @param int $len
185
+	 * @param string $nonce
186
+	 * @param string $key
187
+	 * @return string
188
+	 */
189
+	public static function salsa20($len, $nonce, $key)
190
+	{
191
+		if (self::strlen($key) !== 32) {
192
+			throw new RangeException('Key must be 32 bytes long');
193
+		}
194
+		$kcopy = '' . $key;
195
+		$in = self::substr($nonce, 0, 8) . str_repeat("\0", 8);
196
+		$c = '';
197
+		while ($len >= 64) {
198
+			$c .= self::core_salsa20($in, $kcopy, null);
199
+			$u = 1;
200
+			// Internal counter.
201
+			for ($i = 8; $i < 16; ++$i) {
202
+				$u += self::chrToInt($in[$i]);
203
+				$in[$i] = self::intToChr($u & 0xff);
204
+				$u >>= 8;
205
+			}
206
+			$len -= 64;
207
+		}
208
+		if ($len > 0) {
209
+			$c .= self::substr(
210
+				self::core_salsa20($in, $kcopy, null),
211
+				0,
212
+				$len
213
+			);
214
+		}
215
+		try {
216
+			ParagonIE_Sodium_Compat::memzero($kcopy);
217
+		} catch (Error $ex) {
218
+			$kcopy = null;
219
+		}
220
+		return $c;
221
+	}
222 222
 
223
-    /**
224
-     * @internal You should not use this directly from another application
225
-     *
226
-     * @param string $m
227
-     * @param string $n
228
-     * @param int $ic
229
-     * @param string $k
230
-     * @return string
231
-     */
232
-    public static function salsa20_xor_ic($m, $n, $ic, $k)
233
-    {
234
-        $mlen = self::strlen($m);
235
-        if ($mlen < 1) {
236
-            return '';
237
-        }
238
-        $kcopy = self::substr($k, 0, 32);
239
-        $in = self::substr($n, 0, 8);
240
-        // Initialize the counter
241
-        $in .= ParagonIE_Sodium_Core32_Util::store64_le($ic);
223
+	/**
224
+	 * @internal You should not use this directly from another application
225
+	 *
226
+	 * @param string $m
227
+	 * @param string $n
228
+	 * @param int $ic
229
+	 * @param string $k
230
+	 * @return string
231
+	 */
232
+	public static function salsa20_xor_ic($m, $n, $ic, $k)
233
+	{
234
+		$mlen = self::strlen($m);
235
+		if ($mlen < 1) {
236
+			return '';
237
+		}
238
+		$kcopy = self::substr($k, 0, 32);
239
+		$in = self::substr($n, 0, 8);
240
+		// Initialize the counter
241
+		$in .= ParagonIE_Sodium_Core32_Util::store64_le($ic);
242 242
 
243
-        $c = '';
244
-        while ($mlen >= 64) {
245
-            $block = self::core_salsa20($in, $kcopy, null);
246
-            $c .= self::xorStrings(
247
-                self::substr($m, 0, 64),
248
-                self::substr($block, 0, 64)
249
-            );
250
-            $u = 1;
251
-            for ($i = 8; $i < 16; ++$i) {
252
-                $u += self::chrToInt($in[$i]);
253
-                $in[$i] = self::intToChr($u & 0xff);
254
-                $u >>= 8;
255
-            }
243
+		$c = '';
244
+		while ($mlen >= 64) {
245
+			$block = self::core_salsa20($in, $kcopy, null);
246
+			$c .= self::xorStrings(
247
+				self::substr($m, 0, 64),
248
+				self::substr($block, 0, 64)
249
+			);
250
+			$u = 1;
251
+			for ($i = 8; $i < 16; ++$i) {
252
+				$u += self::chrToInt($in[$i]);
253
+				$in[$i] = self::intToChr($u & 0xff);
254
+				$u >>= 8;
255
+			}
256 256
 
257
-            $mlen -= 64;
258
-            $m = self::substr($m, 64);
259
-        }
257
+			$mlen -= 64;
258
+			$m = self::substr($m, 64);
259
+		}
260 260
 
261
-        if ($mlen) {
262
-            $block = self::core_salsa20($in, $kcopy, null);
263
-            $c .= self::xorStrings(
264
-                self::substr($m, 0, $mlen),
265
-                self::substr($block, 0, $mlen)
266
-            );
267
-        }
268
-        try {
269
-            ParagonIE_Sodium_Compat::memzero($block);
270
-            ParagonIE_Sodium_Compat::memzero($kcopy);
271
-        } catch (Error $ex) {
272
-            $block = null;
273
-            $kcopy = null;
274
-        }
261
+		if ($mlen) {
262
+			$block = self::core_salsa20($in, $kcopy, null);
263
+			$c .= self::xorStrings(
264
+				self::substr($m, 0, $mlen),
265
+				self::substr($block, 0, $mlen)
266
+			);
267
+		}
268
+		try {
269
+			ParagonIE_Sodium_Compat::memzero($block);
270
+			ParagonIE_Sodium_Compat::memzero($kcopy);
271
+		} catch (Error $ex) {
272
+			$block = null;
273
+			$kcopy = null;
274
+		}
275 275
 
276
-        return $c;
277
-    }
276
+		return $c;
277
+	}
278 278
 
279
-    /**
280
-     * @internal You should not use this directly from another application
281
-     *
282
-     * @param string $message
283
-     * @param string $nonce
284
-     * @param string $key
285
-     * @return string
286
-     */
287
-    public static function salsa20_xor($message, $nonce, $key)
288
-    {
289
-        return self::xorStrings(
290
-            $message,
291
-            self::salsa20(
292
-                self::strlen($message),
293
-                $nonce,
294
-                $key
295
-            )
296
-        );
297
-    }
279
+	/**
280
+	 * @internal You should not use this directly from another application
281
+	 *
282
+	 * @param string $message
283
+	 * @param string $nonce
284
+	 * @param string $key
285
+	 * @return string
286
+	 */
287
+	public static function salsa20_xor($message, $nonce, $key)
288
+	{
289
+		return self::xorStrings(
290
+			$message,
291
+			self::salsa20(
292
+				self::strlen($message),
293
+				$nonce,
294
+				$key
295
+			)
296
+		);
297
+	}
298 298
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_Salsa20', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_Salsa20', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      * @param string|null $c
22 22
      * @return string
23 23
      */
24
-    public static function core_salsa20($in, $k, $c = null)
24
+    public static function core_salsa20( $in, $k, $c = null )
25 25
     {
26 26
         /**
27 27
          * @var ParagonIE_Sodium_Core32_Int32 $x0
@@ -57,32 +57,32 @@  discard block
 block discarded – undo
57 57
          * @var ParagonIE_Sodium_Core32_Int32 $j14
58 58
          * @var ParagonIE_Sodium_Core32_Int32 $j15
59 59
          */
60
-        if (self::strlen($k) < 32) {
61
-            throw new RangeException('Key must be 32 bytes long');
60
+        if ( self::strlen( $k ) < 32 ) {
61
+            throw new RangeException( 'Key must be 32 bytes long' );
62 62
         }
63
-        if ($c === null) {
64
-            $x0  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
65
-            $x5  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
66
-            $x10 = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
67
-            $x15 = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
63
+        if ( $c === null ) {
64
+            $x0  = new ParagonIE_Sodium_Core32_Int32( array( 0x6170, 0x7865 ) );
65
+            $x5  = new ParagonIE_Sodium_Core32_Int32( array( 0x3320, 0x646e ) );
66
+            $x10 = new ParagonIE_Sodium_Core32_Int32( array( 0x7962, 0x2d32 ) );
67
+            $x15 = new ParagonIE_Sodium_Core32_Int32( array( 0x6b20, 0x6574 ) );
68 68
         } else {
69
-            $x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 0, 4));
70
-            $x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 4, 4));
71
-            $x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 8, 4));
72
-            $x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($c, 12, 4));
69
+            $x0  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 0, 4 ) );
70
+            $x5  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 4, 4 ) );
71
+            $x10 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 8, 4 ) );
72
+            $x15 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $c, 12, 4 ) );
73 73
         }
74
-        $x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 0, 4));
75
-        $x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 4, 4));
76
-        $x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 8, 4));
77
-        $x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 12, 4));
78
-        $x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 0, 4));
79
-        $x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 4, 4));
80
-        $x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 8, 4));
81
-        $x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($in, 12, 4));
82
-        $x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 16, 4));
83
-        $x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 20, 4));
84
-        $x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 24, 4));
85
-        $x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($k, 28, 4));
74
+        $x1  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 0, 4 ) );
75
+        $x2  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 4, 4 ) );
76
+        $x3  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 8, 4 ) );
77
+        $x4  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 12, 4 ) );
78
+        $x6  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 0, 4 ) );
79
+        $x7  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 4, 4 ) );
80
+        $x8  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 8, 4 ) );
81
+        $x9  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $in, 12, 4 ) );
82
+        $x11 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 16, 4 ) );
83
+        $x12 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 20, 4 ) );
84
+        $x13 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 24, 4 ) );
85
+        $x14 = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $k, 28, 4 ) );
86 86
 
87 87
         $j0  = clone $x0;
88 88
         $j1  = clone $x1;
@@ -101,64 +101,64 @@  discard block
 block discarded – undo
101 101
         $j14  = clone $x14;
102 102
         $j15  = clone $x15;
103 103
 
104
-        for ($i = self::ROUNDS; $i > 0; $i -= 2) {
105
-            $x4  = $x4->xorInt32($x0->addInt32($x12)->rotateLeft(7));
106
-            $x8  = $x8->xorInt32($x4->addInt32($x0)->rotateLeft(9));
107
-            $x12 = $x12->xorInt32($x8->addInt32($x4)->rotateLeft(13));
108
-            $x0  = $x0->xorInt32($x12->addInt32($x8)->rotateLeft(18));
104
+        for ( $i = self::ROUNDS; $i > 0; $i -= 2 ) {
105
+            $x4  = $x4->xorInt32( $x0->addInt32( $x12 )->rotateLeft( 7 ) );
106
+            $x8  = $x8->xorInt32( $x4->addInt32( $x0 )->rotateLeft( 9 ) );
107
+            $x12 = $x12->xorInt32( $x8->addInt32( $x4 )->rotateLeft( 13 ) );
108
+            $x0  = $x0->xorInt32( $x12->addInt32( $x8 )->rotateLeft( 18 ) );
109 109
 
110
-            $x9  = $x9->xorInt32($x5->addInt32($x1)->rotateLeft(7));
111
-            $x13 = $x13->xorInt32($x9->addInt32($x5)->rotateLeft(9));
112
-            $x1  = $x1->xorInt32($x13->addInt32($x9)->rotateLeft(13));
113
-            $x5  = $x5->xorInt32($x1->addInt32($x13)->rotateLeft(18));
110
+            $x9  = $x9->xorInt32( $x5->addInt32( $x1 )->rotateLeft( 7 ) );
111
+            $x13 = $x13->xorInt32( $x9->addInt32( $x5 )->rotateLeft( 9 ) );
112
+            $x1  = $x1->xorInt32( $x13->addInt32( $x9 )->rotateLeft( 13 ) );
113
+            $x5  = $x5->xorInt32( $x1->addInt32( $x13 )->rotateLeft( 18 ) );
114 114
 
115
-            $x14 = $x14->xorInt32($x10->addInt32($x6)->rotateLeft(7));
116
-            $x2  = $x2->xorInt32($x14->addInt32($x10)->rotateLeft(9));
117
-            $x6  = $x6->xorInt32($x2->addInt32($x14)->rotateLeft(13));
118
-            $x10 = $x10->xorInt32($x6->addInt32($x2)->rotateLeft(18));
115
+            $x14 = $x14->xorInt32( $x10->addInt32( $x6 )->rotateLeft( 7 ) );
116
+            $x2  = $x2->xorInt32( $x14->addInt32( $x10 )->rotateLeft( 9 ) );
117
+            $x6  = $x6->xorInt32( $x2->addInt32( $x14 )->rotateLeft( 13 ) );
118
+            $x10 = $x10->xorInt32( $x6->addInt32( $x2 )->rotateLeft( 18 ) );
119 119
 
120
-            $x3  = $x3->xorInt32($x15->addInt32($x11)->rotateLeft(7));
121
-            $x7  = $x7->xorInt32($x3->addInt32($x15)->rotateLeft(9));
122
-            $x11 = $x11->xorInt32($x7->addInt32($x3)->rotateLeft(13));
123
-            $x15 = $x15->xorInt32($x11->addInt32($x7)->rotateLeft(18));
120
+            $x3  = $x3->xorInt32( $x15->addInt32( $x11 )->rotateLeft( 7 ) );
121
+            $x7  = $x7->xorInt32( $x3->addInt32( $x15 )->rotateLeft( 9 ) );
122
+            $x11 = $x11->xorInt32( $x7->addInt32( $x3 )->rotateLeft( 13 ) );
123
+            $x15 = $x15->xorInt32( $x11->addInt32( $x7 )->rotateLeft( 18 ) );
124 124
 
125
-            $x1  = $x1->xorInt32($x0->addInt32($x3)->rotateLeft(7));
126
-            $x2  = $x2->xorInt32($x1->addInt32($x0)->rotateLeft(9));
127
-            $x3  = $x3->xorInt32($x2->addInt32($x1)->rotateLeft(13));
128
-            $x0  = $x0->xorInt32($x3->addInt32($x2)->rotateLeft(18));
125
+            $x1  = $x1->xorInt32( $x0->addInt32( $x3 )->rotateLeft( 7 ) );
126
+            $x2  = $x2->xorInt32( $x1->addInt32( $x0 )->rotateLeft( 9 ) );
127
+            $x3  = $x3->xorInt32( $x2->addInt32( $x1 )->rotateLeft( 13 ) );
128
+            $x0  = $x0->xorInt32( $x3->addInt32( $x2 )->rotateLeft( 18 ) );
129 129
 
130
-            $x6  = $x6->xorInt32($x5->addInt32($x4)->rotateLeft(7));
131
-            $x7  = $x7->xorInt32($x6->addInt32($x5)->rotateLeft(9));
132
-            $x4  = $x4->xorInt32($x7->addInt32($x6)->rotateLeft(13));
133
-            $x5  = $x5->xorInt32($x4->addInt32($x7)->rotateLeft(18));
130
+            $x6  = $x6->xorInt32( $x5->addInt32( $x4 )->rotateLeft( 7 ) );
131
+            $x7  = $x7->xorInt32( $x6->addInt32( $x5 )->rotateLeft( 9 ) );
132
+            $x4  = $x4->xorInt32( $x7->addInt32( $x6 )->rotateLeft( 13 ) );
133
+            $x5  = $x5->xorInt32( $x4->addInt32( $x7 )->rotateLeft( 18 ) );
134 134
 
135
-            $x11 = $x11->xorInt32($x10->addInt32($x9)->rotateLeft(7));
136
-            $x8  = $x8->xorInt32($x11->addInt32($x10)->rotateLeft(9));
137
-            $x9  = $x9->xorInt32($x8->addInt32($x11)->rotateLeft(13));
138
-            $x10 = $x10->xorInt32($x9->addInt32($x8)->rotateLeft(18));
135
+            $x11 = $x11->xorInt32( $x10->addInt32( $x9 )->rotateLeft( 7 ) );
136
+            $x8  = $x8->xorInt32( $x11->addInt32( $x10 )->rotateLeft( 9 ) );
137
+            $x9  = $x9->xorInt32( $x8->addInt32( $x11 )->rotateLeft( 13 ) );
138
+            $x10 = $x10->xorInt32( $x9->addInt32( $x8 )->rotateLeft( 18 ) );
139 139
 
140
-            $x12 = $x12->xorInt32($x15->addInt32($x14)->rotateLeft(7));
141
-            $x13 = $x13->xorInt32($x12->addInt32($x15)->rotateLeft(9));
142
-            $x14 = $x14->xorInt32($x13->addInt32($x12)->rotateLeft(13));
143
-            $x15 = $x15->xorInt32($x14->addInt32($x13)->rotateLeft(18));
140
+            $x12 = $x12->xorInt32( $x15->addInt32( $x14 )->rotateLeft( 7 ) );
141
+            $x13 = $x13->xorInt32( $x12->addInt32( $x15 )->rotateLeft( 9 ) );
142
+            $x14 = $x14->xorInt32( $x13->addInt32( $x12 )->rotateLeft( 13 ) );
143
+            $x15 = $x15->xorInt32( $x14->addInt32( $x13 )->rotateLeft( 18 ) );
144 144
         }
145 145
 
146
-        $x0  = $x0->addInt32($j0);
147
-        $x1  = $x1->addInt32($j1);
148
-        $x2  = $x2->addInt32($j2);
149
-        $x3  = $x3->addInt32($j3);
150
-        $x4  = $x4->addInt32($j4);
151
-        $x5  = $x5->addInt32($j5);
152
-        $x6  = $x6->addInt32($j6);
153
-        $x7  = $x7->addInt32($j7);
154
-        $x8  = $x8->addInt32($j8);
155
-        $x9  = $x9->addInt32($j9);
156
-        $x10 = $x10->addInt32($j10);
157
-        $x11 = $x11->addInt32($j11);
158
-        $x12 = $x12->addInt32($j12);
159
-        $x13 = $x13->addInt32($j13);
160
-        $x14 = $x14->addInt32($j14);
161
-        $x15 = $x15->addInt32($j15);
146
+        $x0  = $x0->addInt32( $j0 );
147
+        $x1  = $x1->addInt32( $j1 );
148
+        $x2  = $x2->addInt32( $j2 );
149
+        $x3  = $x3->addInt32( $j3 );
150
+        $x4  = $x4->addInt32( $j4 );
151
+        $x5  = $x5->addInt32( $j5 );
152
+        $x6  = $x6->addInt32( $j6 );
153
+        $x7  = $x7->addInt32( $j7 );
154
+        $x8  = $x8->addInt32( $j8 );
155
+        $x9  = $x9->addInt32( $j9 );
156
+        $x10 = $x10->addInt32( $j10 );
157
+        $x11 = $x11->addInt32( $j11 );
158
+        $x12 = $x12->addInt32( $j12 );
159
+        $x13 = $x13->addInt32( $j13 );
160
+        $x14 = $x14->addInt32( $j14 );
161
+        $x15 = $x15->addInt32( $j15 );
162 162
 
163 163
         return $x0->toReverseString() .
164 164
             $x1->toReverseString() .
@@ -186,35 +186,35 @@  discard block
 block discarded – undo
186 186
      * @param string $key
187 187
      * @return string
188 188
      */
189
-    public static function salsa20($len, $nonce, $key)
189
+    public static function salsa20( $len, $nonce, $key )
190 190
     {
191
-        if (self::strlen($key) !== 32) {
192
-            throw new RangeException('Key must be 32 bytes long');
191
+        if ( self::strlen( $key ) !== 32 ) {
192
+            throw new RangeException( 'Key must be 32 bytes long' );
193 193
         }
194 194
         $kcopy = '' . $key;
195
-        $in = self::substr($nonce, 0, 8) . str_repeat("\0", 8);
195
+        $in = self::substr( $nonce, 0, 8 ) . str_repeat( "\0", 8 );
196 196
         $c = '';
197
-        while ($len >= 64) {
198
-            $c .= self::core_salsa20($in, $kcopy, null);
197
+        while ( $len >= 64 ) {
198
+            $c .= self::core_salsa20( $in, $kcopy, null );
199 199
             $u = 1;
200 200
             // Internal counter.
201
-            for ($i = 8; $i < 16; ++$i) {
202
-                $u += self::chrToInt($in[$i]);
203
-                $in[$i] = self::intToChr($u & 0xff);
201
+            for ( $i = 8; $i < 16; ++$i ) {
202
+                $u += self::chrToInt( $in[$i] );
203
+                $in[$i] = self::intToChr( $u & 0xff );
204 204
                 $u >>= 8;
205 205
             }
206 206
             $len -= 64;
207 207
         }
208
-        if ($len > 0) {
208
+        if ( $len > 0 ) {
209 209
             $c .= self::substr(
210
-                self::core_salsa20($in, $kcopy, null),
210
+                self::core_salsa20( $in, $kcopy, null ),
211 211
                 0,
212 212
                 $len
213 213
             );
214 214
         }
215 215
         try {
216
-            ParagonIE_Sodium_Compat::memzero($kcopy);
217
-        } catch (Error $ex) {
216
+            ParagonIE_Sodium_Compat::memzero( $kcopy );
217
+        } catch ( Error $ex ) {
218 218
             $kcopy = null;
219 219
         }
220 220
         return $c;
@@ -229,46 +229,46 @@  discard block
 block discarded – undo
229 229
      * @param string $k
230 230
      * @return string
231 231
      */
232
-    public static function salsa20_xor_ic($m, $n, $ic, $k)
232
+    public static function salsa20_xor_ic( $m, $n, $ic, $k )
233 233
     {
234
-        $mlen = self::strlen($m);
235
-        if ($mlen < 1) {
234
+        $mlen = self::strlen( $m );
235
+        if ( $mlen < 1 ) {
236 236
             return '';
237 237
         }
238
-        $kcopy = self::substr($k, 0, 32);
239
-        $in = self::substr($n, 0, 8);
238
+        $kcopy = self::substr( $k, 0, 32 );
239
+        $in = self::substr( $n, 0, 8 );
240 240
         // Initialize the counter
241
-        $in .= ParagonIE_Sodium_Core32_Util::store64_le($ic);
241
+        $in .= ParagonIE_Sodium_Core32_Util::store64_le( $ic );
242 242
 
243 243
         $c = '';
244
-        while ($mlen >= 64) {
245
-            $block = self::core_salsa20($in, $kcopy, null);
244
+        while ( $mlen >= 64 ) {
245
+            $block = self::core_salsa20( $in, $kcopy, null );
246 246
             $c .= self::xorStrings(
247
-                self::substr($m, 0, 64),
248
-                self::substr($block, 0, 64)
247
+                self::substr( $m, 0, 64 ),
248
+                self::substr( $block, 0, 64 )
249 249
             );
250 250
             $u = 1;
251
-            for ($i = 8; $i < 16; ++$i) {
252
-                $u += self::chrToInt($in[$i]);
253
-                $in[$i] = self::intToChr($u & 0xff);
251
+            for ( $i = 8; $i < 16; ++$i ) {
252
+                $u += self::chrToInt( $in[$i] );
253
+                $in[$i] = self::intToChr( $u & 0xff );
254 254
                 $u >>= 8;
255 255
             }
256 256
 
257 257
             $mlen -= 64;
258
-            $m = self::substr($m, 64);
258
+            $m = self::substr( $m, 64 );
259 259
         }
260 260
 
261
-        if ($mlen) {
262
-            $block = self::core_salsa20($in, $kcopy, null);
261
+        if ( $mlen ) {
262
+            $block = self::core_salsa20( $in, $kcopy, null );
263 263
             $c .= self::xorStrings(
264
-                self::substr($m, 0, $mlen),
265
-                self::substr($block, 0, $mlen)
264
+                self::substr( $m, 0, $mlen ),
265
+                self::substr( $block, 0, $mlen )
266 266
             );
267 267
         }
268 268
         try {
269
-            ParagonIE_Sodium_Compat::memzero($block);
270
-            ParagonIE_Sodium_Compat::memzero($kcopy);
271
-        } catch (Error $ex) {
269
+            ParagonIE_Sodium_Compat::memzero( $block );
270
+            ParagonIE_Sodium_Compat::memzero( $kcopy );
271
+        } catch ( Error $ex ) {
272 272
             $block = null;
273 273
             $kcopy = null;
274 274
         }
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
      * @param string $key
285 285
      * @return string
286 286
      */
287
-    public static function salsa20_xor($message, $nonce, $key)
287
+    public static function salsa20_xor( $message, $nonce, $key )
288 288
     {
289 289
         return self::xorStrings(
290 290
             $message,
291 291
             self::salsa20(
292
-                self::strlen($message),
292
+                self::strlen( $message ),
293 293
                 $nonce,
294 294
                 $key
295 295
             )
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_Salsa20
9 9
  */
10
-abstract class ParagonIE_Sodium_Core32_Salsa20 extends ParagonIE_Sodium_Core32_Util
11
-{
10
+abstract class ParagonIE_Sodium_Core32_Salsa20 extends ParagonIE_Sodium_Core32_Util {
12 11
     const ROUNDS = 20;
13 12
 
14 13
     /**
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
      * @param string|null $c
22 21
      * @return string
23 22
      */
24
-    public static function core_salsa20($in, $k, $c = null)
25
-    {
23
+    public static function core_salsa20($in, $k, $c = null) {
26 24
         /**
27 25
          * @var ParagonIE_Sodium_Core32_Int32 $x0
28 26
          * @var ParagonIE_Sodium_Core32_Int32 $x1
@@ -186,8 +184,7 @@  discard block
 block discarded – undo
186 184
      * @param string $key
187 185
      * @return string
188 186
      */
189
-    public static function salsa20($len, $nonce, $key)
190
-    {
187
+    public static function salsa20($len, $nonce, $key) {
191 188
         if (self::strlen($key) !== 32) {
192 189
             throw new RangeException('Key must be 32 bytes long');
193 190
         }
@@ -229,8 +226,7 @@  discard block
 block discarded – undo
229 226
      * @param string $k
230 227
      * @return string
231 228
      */
232
-    public static function salsa20_xor_ic($m, $n, $ic, $k)
233
-    {
229
+    public static function salsa20_xor_ic($m, $n, $ic, $k) {
234 230
         $mlen = self::strlen($m);
235 231
         if ($mlen < 1) {
236 232
             return '';
@@ -284,8 +280,7 @@  discard block
 block discarded – undo
284 280
      * @param string $key
285 281
      * @return string
286 282
      */
287
-    public static function salsa20_xor($message, $nonce, $key)
288
-    {
283
+    public static function salsa20_xor($message, $nonce, $key) {
289 284
         return self::xorStrings(
290 285
             $message,
291 286
             self::salsa20(
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/XSalsa20.php 3 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_XSalsa20', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,45 +9,45 @@  discard block
 block discarded – undo
9 9
  */
10 10
 abstract class ParagonIE_Sodium_Core32_XSalsa20 extends ParagonIE_Sodium_Core32_HSalsa20
11 11
 {
12
-    /**
13
-     * Expand a key and nonce into an xsalsa20 keystream.
14
-     *
15
-     * @internal You should not use this directly from another application
16
-     *
17
-     * @param int $len
18
-     * @param string $nonce
19
-     * @param string $key
20
-     * @return string
21
-     */
22
-    public static function xsalsa20($len, $nonce, $key)
23
-    {
24
-        $ret = self::salsa20(
25
-            $len,
26
-            self::substr($nonce, 16, 8),
27
-            self::hsalsa20($nonce, $key)
28
-        );
29
-        return $ret;
30
-    }
12
+	/**
13
+	 * Expand a key and nonce into an xsalsa20 keystream.
14
+	 *
15
+	 * @internal You should not use this directly from another application
16
+	 *
17
+	 * @param int $len
18
+	 * @param string $nonce
19
+	 * @param string $key
20
+	 * @return string
21
+	 */
22
+	public static function xsalsa20($len, $nonce, $key)
23
+	{
24
+		$ret = self::salsa20(
25
+			$len,
26
+			self::substr($nonce, 16, 8),
27
+			self::hsalsa20($nonce, $key)
28
+		);
29
+		return $ret;
30
+	}
31 31
 
32
-    /**
33
-     * Encrypt a string with XSalsa20. Doesn't provide integrity.
34
-     *
35
-     * @internal You should not use this directly from another application
36
-     *
37
-     * @param string $message
38
-     * @param string $nonce
39
-     * @param string $key
40
-     * @return string
41
-     */
42
-    public static function xsalsa20_xor($message, $nonce, $key)
43
-    {
44
-        return self::xorStrings(
45
-            $message,
46
-            self::xsalsa20(
47
-                self::strlen($message),
48
-                $nonce,
49
-                $key
50
-            )
51
-        );
52
-    }
32
+	/**
33
+	 * Encrypt a string with XSalsa20. Doesn't provide integrity.
34
+	 *
35
+	 * @internal You should not use this directly from another application
36
+	 *
37
+	 * @param string $message
38
+	 * @param string $nonce
39
+	 * @param string $key
40
+	 * @return string
41
+	 */
42
+	public static function xsalsa20_xor($message, $nonce, $key)
43
+	{
44
+		return self::xorStrings(
45
+			$message,
46
+			self::xsalsa20(
47
+				self::strlen($message),
48
+				$nonce,
49
+				$key
50
+			)
51
+		);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_XSalsa20', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_XSalsa20', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
      * @param string $key
20 20
      * @return string
21 21
      */
22
-    public static function xsalsa20($len, $nonce, $key)
22
+    public static function xsalsa20( $len, $nonce, $key )
23 23
     {
24 24
         $ret = self::salsa20(
25 25
             $len,
26
-            self::substr($nonce, 16, 8),
27
-            self::hsalsa20($nonce, $key)
26
+            self::substr( $nonce, 16, 8 ),
27
+            self::hsalsa20( $nonce, $key )
28 28
         );
29 29
         return $ret;
30 30
     }
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
      * @param string $key
40 40
      * @return string
41 41
      */
42
-    public static function xsalsa20_xor($message, $nonce, $key)
42
+    public static function xsalsa20_xor( $message, $nonce, $key )
43 43
     {
44 44
         return self::xorStrings(
45 45
             $message,
46 46
             self::xsalsa20(
47
-                self::strlen($message),
47
+                self::strlen( $message ),
48 48
                 $nonce,
49 49
                 $key
50 50
             )
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_XSalsa20
9 9
  */
10
-abstract class ParagonIE_Sodium_Core32_XSalsa20 extends ParagonIE_Sodium_Core32_HSalsa20
11
-{
10
+abstract class ParagonIE_Sodium_Core32_XSalsa20 extends ParagonIE_Sodium_Core32_HSalsa20 {
12 11
     /**
13 12
      * Expand a key and nonce into an xsalsa20 keystream.
14 13
      *
@@ -19,8 +18,7 @@  discard block
 block discarded – undo
19 18
      * @param string $key
20 19
      * @return string
21 20
      */
22
-    public static function xsalsa20($len, $nonce, $key)
23
-    {
21
+    public static function xsalsa20($len, $nonce, $key) {
24 22
         $ret = self::salsa20(
25 23
             $len,
26 24
             self::substr($nonce, 16, 8),
@@ -39,8 +37,7 @@  discard block
 block discarded – undo
39 37
      * @param string $key
40 38
      * @return string
41 39
      */
42
-    public static function xsalsa20_xor($message, $nonce, $key)
43
-    {
40
+    public static function xsalsa20_xor($message, $nonce, $key) {
44 41
         return self::xorStrings(
45 42
             $message,
46 43
             self::xsalsa20(
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/ChaCha20.php 3 patches
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_ChaCha20', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,82 +9,82 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class ParagonIE_Sodium_Core32_ChaCha20 extends ParagonIE_Sodium_Core32_Util
11 11
 {
12
-    /**
13
-     * The ChaCha20 quarter round function. Works on four 32-bit integers.
14
-     *
15
-     * @internal You should not use this directly from another application
16
-     *
17
-     * @param ParagonIE_Sodium_Core32_Int32 $a
18
-     * @param ParagonIE_Sodium_Core32_Int32 $b
19
-     * @param ParagonIE_Sodium_Core32_Int32 $c
20
-     * @param ParagonIE_Sodium_Core32_Int32 $d
21
-     * @return array<int, ParagonIE_Sodium_Core32_Int32>
22
-     */
23
-    protected static function quarterRound(
24
-        ParagonIE_Sodium_Core32_Int32 $a,
25
-        ParagonIE_Sodium_Core32_Int32 $b,
26
-        ParagonIE_Sodium_Core32_Int32 $c,
27
-        ParagonIE_Sodium_Core32_Int32 $d
28
-    ) {
29
-        /** @var ParagonIE_Sodium_Core32_Int32 $a */
30
-        /** @var ParagonIE_Sodium_Core32_Int32 $b */
31
-        /** @var ParagonIE_Sodium_Core32_Int32 $c */
32
-        /** @var ParagonIE_Sodium_Core32_Int32 $d */
12
+	/**
13
+	 * The ChaCha20 quarter round function. Works on four 32-bit integers.
14
+	 *
15
+	 * @internal You should not use this directly from another application
16
+	 *
17
+	 * @param ParagonIE_Sodium_Core32_Int32 $a
18
+	 * @param ParagonIE_Sodium_Core32_Int32 $b
19
+	 * @param ParagonIE_Sodium_Core32_Int32 $c
20
+	 * @param ParagonIE_Sodium_Core32_Int32 $d
21
+	 * @return array<int, ParagonIE_Sodium_Core32_Int32>
22
+	 */
23
+	protected static function quarterRound(
24
+		ParagonIE_Sodium_Core32_Int32 $a,
25
+		ParagonIE_Sodium_Core32_Int32 $b,
26
+		ParagonIE_Sodium_Core32_Int32 $c,
27
+		ParagonIE_Sodium_Core32_Int32 $d
28
+	) {
29
+		/** @var ParagonIE_Sodium_Core32_Int32 $a */
30
+		/** @var ParagonIE_Sodium_Core32_Int32 $b */
31
+		/** @var ParagonIE_Sodium_Core32_Int32 $c */
32
+		/** @var ParagonIE_Sodium_Core32_Int32 $d */
33 33
 
34
-        # a = PLUS(a,b); d = ROTATE(XOR(d,a),16);
35
-        $a = $a->addInt32($b);
36
-        $d = $d->xorInt32($a)->rotateLeft(16);
34
+		# a = PLUS(a,b); d = ROTATE(XOR(d,a),16);
35
+		$a = $a->addInt32($b);
36
+		$d = $d->xorInt32($a)->rotateLeft(16);
37 37
 
38
-        # c = PLUS(c,d); b = ROTATE(XOR(b,c),12);
39
-        $c = $c->addInt32($d);
40
-        $b = $b->xorInt32($c)->rotateLeft(12);
38
+		# c = PLUS(c,d); b = ROTATE(XOR(b,c),12);
39
+		$c = $c->addInt32($d);
40
+		$b = $b->xorInt32($c)->rotateLeft(12);
41 41
 
42
-        # a = PLUS(a,b); d = ROTATE(XOR(d,a), 8);
43
-        $a = $a->addInt32($b);
44
-        $d = $d->xorInt32($a)->rotateLeft(8);
42
+		# a = PLUS(a,b); d = ROTATE(XOR(d,a), 8);
43
+		$a = $a->addInt32($b);
44
+		$d = $d->xorInt32($a)->rotateLeft(8);
45 45
 
46
-        # c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
47
-        $c = $c->addInt32($d);
48
-        $b = $b->xorInt32($c)->rotateLeft(7);
46
+		# c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
47
+		$c = $c->addInt32($d);
48
+		$b = $b->xorInt32($c)->rotateLeft(7);
49 49
 
50
-        return array($a, $b, $c, $d);
51
-    }
50
+		return array($a, $b, $c, $d);
51
+	}
52 52
 
53
-    /**
54
-     * @internal You should not use this directly from another application
55
-     *
56
-     * @param ParagonIE_Sodium_Core32_ChaCha20_Ctx $ctx
57
-     * @param string $message
58
-     *
59
-     * @return string
60
-     * @throws Exception
61
-     */
62
-    public static function encryptBytes(
63
-        ParagonIE_Sodium_Core32_ChaCha20_Ctx $ctx,
64
-        $message = ''
65
-    ) {
66
-        $bytes = self::strlen($message);
53
+	/**
54
+	 * @internal You should not use this directly from another application
55
+	 *
56
+	 * @param ParagonIE_Sodium_Core32_ChaCha20_Ctx $ctx
57
+	 * @param string $message
58
+	 *
59
+	 * @return string
60
+	 * @throws Exception
61
+	 */
62
+	public static function encryptBytes(
63
+		ParagonIE_Sodium_Core32_ChaCha20_Ctx $ctx,
64
+		$message = ''
65
+	) {
66
+		$bytes = self::strlen($message);
67 67
 
68
-        /**
69
-         * @var ParagonIE_Sodium_Core32_Int32 $x0
70
-         * @var ParagonIE_Sodium_Core32_Int32 $x1
71
-         * @var ParagonIE_Sodium_Core32_Int32 $x2
72
-         * @var ParagonIE_Sodium_Core32_Int32 $x3
73
-         * @var ParagonIE_Sodium_Core32_Int32 $x4
74
-         * @var ParagonIE_Sodium_Core32_Int32 $x5
75
-         * @var ParagonIE_Sodium_Core32_Int32 $x6
76
-         * @var ParagonIE_Sodium_Core32_Int32 $x7
77
-         * @var ParagonIE_Sodium_Core32_Int32 $x8
78
-         * @var ParagonIE_Sodium_Core32_Int32 $x9
79
-         * @var ParagonIE_Sodium_Core32_Int32 $x10
80
-         * @var ParagonIE_Sodium_Core32_Int32 $x11
81
-         * @var ParagonIE_Sodium_Core32_Int32 $x12
82
-         * @var ParagonIE_Sodium_Core32_Int32 $x13
83
-         * @var ParagonIE_Sodium_Core32_Int32 $x14
84
-         * @var ParagonIE_Sodium_Core32_Int32 $x15
85
-         */
68
+		/**
69
+		 * @var ParagonIE_Sodium_Core32_Int32 $x0
70
+		 * @var ParagonIE_Sodium_Core32_Int32 $x1
71
+		 * @var ParagonIE_Sodium_Core32_Int32 $x2
72
+		 * @var ParagonIE_Sodium_Core32_Int32 $x3
73
+		 * @var ParagonIE_Sodium_Core32_Int32 $x4
74
+		 * @var ParagonIE_Sodium_Core32_Int32 $x5
75
+		 * @var ParagonIE_Sodium_Core32_Int32 $x6
76
+		 * @var ParagonIE_Sodium_Core32_Int32 $x7
77
+		 * @var ParagonIE_Sodium_Core32_Int32 $x8
78
+		 * @var ParagonIE_Sodium_Core32_Int32 $x9
79
+		 * @var ParagonIE_Sodium_Core32_Int32 $x10
80
+		 * @var ParagonIE_Sodium_Core32_Int32 $x11
81
+		 * @var ParagonIE_Sodium_Core32_Int32 $x12
82
+		 * @var ParagonIE_Sodium_Core32_Int32 $x13
83
+		 * @var ParagonIE_Sodium_Core32_Int32 $x14
84
+		 * @var ParagonIE_Sodium_Core32_Int32 $x15
85
+		 */
86 86
 
87
-        /*
87
+		/*
88 88
         j0 = ctx->input[0];
89 89
         j1 = ctx->input[1];
90 90
         j2 = ctx->input[2];
@@ -102,73 +102,73 @@  discard block
 block discarded – undo
102 102
         j14 = ctx->input[14];
103 103
         j15 = ctx->input[15];
104 104
         */
105
-        $j0  = $ctx[0];
106
-        $j1  = $ctx[1];
107
-        $j2  = $ctx[2];
108
-        $j3  = $ctx[3];
109
-        $j4  = $ctx[4];
110
-        $j5  = $ctx[5];
111
-        $j6  = $ctx[6];
112
-        $j7  = $ctx[7];
113
-        $j8  = $ctx[8];
114
-        $j9  = $ctx[9];
115
-        $j10 = $ctx[10];
116
-        $j11 = $ctx[11];
117
-        $j12 = $ctx[12];
118
-        $j13 = $ctx[13];
119
-        $j14 = $ctx[14];
120
-        $j15 = $ctx[15];
105
+		$j0  = $ctx[0];
106
+		$j1  = $ctx[1];
107
+		$j2  = $ctx[2];
108
+		$j3  = $ctx[3];
109
+		$j4  = $ctx[4];
110
+		$j5  = $ctx[5];
111
+		$j6  = $ctx[6];
112
+		$j7  = $ctx[7];
113
+		$j8  = $ctx[8];
114
+		$j9  = $ctx[9];
115
+		$j10 = $ctx[10];
116
+		$j11 = $ctx[11];
117
+		$j12 = $ctx[12];
118
+		$j13 = $ctx[13];
119
+		$j14 = $ctx[14];
120
+		$j15 = $ctx[15];
121 121
 
122
-        $c = '';
123
-        for (;;) {
124
-            if ($bytes < 64) {
125
-                $message .= str_repeat("\x00", 64 - $bytes);
126
-            }
122
+		$c = '';
123
+		for (;;) {
124
+			if ($bytes < 64) {
125
+				$message .= str_repeat("\x00", 64 - $bytes);
126
+			}
127 127
 
128
-            $x0 =  clone $j0;
129
-            $x1 =  clone $j1;
130
-            $x2 =  clone $j2;
131
-            $x3 =  clone $j3;
132
-            $x4 =  clone $j4;
133
-            $x5 =  clone $j5;
134
-            $x6 =  clone $j6;
135
-            $x7 =  clone $j7;
136
-            $x8 =  clone $j8;
137
-            $x9 =  clone $j9;
138
-            $x10 = clone $j10;
139
-            $x11 = clone $j11;
140
-            $x12 = clone $j12;
141
-            $x13 = clone $j13;
142
-            $x14 = clone $j14;
143
-            $x15 = clone $j15;
128
+			$x0 =  clone $j0;
129
+			$x1 =  clone $j1;
130
+			$x2 =  clone $j2;
131
+			$x3 =  clone $j3;
132
+			$x4 =  clone $j4;
133
+			$x5 =  clone $j5;
134
+			$x6 =  clone $j6;
135
+			$x7 =  clone $j7;
136
+			$x8 =  clone $j8;
137
+			$x9 =  clone $j9;
138
+			$x10 = clone $j10;
139
+			$x11 = clone $j11;
140
+			$x12 = clone $j12;
141
+			$x13 = clone $j13;
142
+			$x14 = clone $j14;
143
+			$x15 = clone $j15;
144 144
 
145
-            # for (i = 20; i > 0; i -= 2) {
146
-            for ($i = 20; $i > 0; $i -= 2) {
147
-                # QUARTERROUND( x0,  x4,  x8,  x12)
148
-                list($x0, $x4, $x8, $x12) = self::quarterRound($x0, $x4, $x8, $x12);
145
+			# for (i = 20; i > 0; i -= 2) {
146
+			for ($i = 20; $i > 0; $i -= 2) {
147
+				# QUARTERROUND( x0,  x4,  x8,  x12)
148
+				list($x0, $x4, $x8, $x12) = self::quarterRound($x0, $x4, $x8, $x12);
149 149
 
150
-                # QUARTERROUND( x1,  x5,  x9,  x13)
151
-                list($x1, $x5, $x9, $x13) = self::quarterRound($x1, $x5, $x9, $x13);
150
+				# QUARTERROUND( x1,  x5,  x9,  x13)
151
+				list($x1, $x5, $x9, $x13) = self::quarterRound($x1, $x5, $x9, $x13);
152 152
 
153
-                # QUARTERROUND( x2,  x6,  x10,  x14)
154
-                list($x2, $x6, $x10, $x14) = self::quarterRound($x2, $x6, $x10, $x14);
153
+				# QUARTERROUND( x2,  x6,  x10,  x14)
154
+				list($x2, $x6, $x10, $x14) = self::quarterRound($x2, $x6, $x10, $x14);
155 155
 
156
-                # QUARTERROUND( x3,  x7,  x11,  x15)
157
-                list($x3, $x7, $x11, $x15) = self::quarterRound($x3, $x7, $x11, $x15);
156
+				# QUARTERROUND( x3,  x7,  x11,  x15)
157
+				list($x3, $x7, $x11, $x15) = self::quarterRound($x3, $x7, $x11, $x15);
158 158
 
159
-                # QUARTERROUND( x0,  x5,  x10,  x15)
160
-                list($x0, $x5, $x10, $x15) = self::quarterRound($x0, $x5, $x10, $x15);
159
+				# QUARTERROUND( x0,  x5,  x10,  x15)
160
+				list($x0, $x5, $x10, $x15) = self::quarterRound($x0, $x5, $x10, $x15);
161 161
 
162
-                # QUARTERROUND( x1,  x6,  x11,  x12)
163
-                list($x1, $x6, $x11, $x12) = self::quarterRound($x1, $x6, $x11, $x12);
162
+				# QUARTERROUND( x1,  x6,  x11,  x12)
163
+				list($x1, $x6, $x11, $x12) = self::quarterRound($x1, $x6, $x11, $x12);
164 164
 
165
-                # QUARTERROUND( x2,  x7,  x8,  x13)
166
-                list($x2, $x7, $x8, $x13) = self::quarterRound($x2, $x7, $x8, $x13);
165
+				# QUARTERROUND( x2,  x7,  x8,  x13)
166
+				list($x2, $x7, $x8, $x13) = self::quarterRound($x2, $x7, $x8, $x13);
167 167
 
168
-                # QUARTERROUND( x3,  x4,  x9,  x14)
169
-                list($x3, $x4, $x9, $x14) = self::quarterRound($x3, $x4, $x9, $x14);
170
-            }
171
-            /*
168
+				# QUARTERROUND( x3,  x4,  x9,  x14)
169
+				list($x3, $x4, $x9, $x14) = self::quarterRound($x3, $x4, $x9, $x14);
170
+			}
171
+			/*
172 172
             x0 = PLUS(x0, j0);
173 173
             x1 = PLUS(x1, j1);
174 174
             x2 = PLUS(x2, j2);
@@ -186,24 +186,24 @@  discard block
 block discarded – undo
186 186
             x14 = PLUS(x14, j14);
187 187
             x15 = PLUS(x15, j15);
188 188
             */
189
-            $x0 = $x0->addInt32($j0);
190
-            $x1 = $x1->addInt32($j1);
191
-            $x2 = $x2->addInt32($j2);
192
-            $x3 = $x3->addInt32($j3);
193
-            $x4 = $x4->addInt32($j4);
194
-            $x5 = $x5->addInt32($j5);
195
-            $x6 = $x6->addInt32($j6);
196
-            $x7 = $x7->addInt32($j7);
197
-            $x8 = $x8->addInt32($j8);
198
-            $x9 = $x9->addInt32($j9);
199
-            $x10 = $x10->addInt32($j10);
200
-            $x11 = $x11->addInt32($j11);
201
-            $x12 = $x12->addInt32($j12);
202
-            $x13 = $x13->addInt32($j13);
203
-            $x14 = $x14->addInt32($j14);
204
-            $x15 = $x15->addInt32($j15);
189
+			$x0 = $x0->addInt32($j0);
190
+			$x1 = $x1->addInt32($j1);
191
+			$x2 = $x2->addInt32($j2);
192
+			$x3 = $x3->addInt32($j3);
193
+			$x4 = $x4->addInt32($j4);
194
+			$x5 = $x5->addInt32($j5);
195
+			$x6 = $x6->addInt32($j6);
196
+			$x7 = $x7->addInt32($j7);
197
+			$x8 = $x8->addInt32($j8);
198
+			$x9 = $x9->addInt32($j9);
199
+			$x10 = $x10->addInt32($j10);
200
+			$x11 = $x11->addInt32($j11);
201
+			$x12 = $x12->addInt32($j12);
202
+			$x13 = $x13->addInt32($j13);
203
+			$x14 = $x14->addInt32($j14);
204
+			$x15 = $x15->addInt32($j15);
205 205
 
206
-            /*
206
+			/*
207 207
             x0 = XOR(x0, LOAD32_LE(m + 0));
208 208
             x1 = XOR(x1, LOAD32_LE(m + 4));
209 209
             x2 = XOR(x2, LOAD32_LE(m + 8));
@@ -221,36 +221,36 @@  discard block
 block discarded – undo
221 221
             x14 = XOR(x14, LOAD32_LE(m + 56));
222 222
             x15 = XOR(x15, LOAD32_LE(m + 60));
223 223
             */
224
-            $x0  =  $x0->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  0, 4)));
225
-            $x1  =  $x1->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  4, 4)));
226
-            $x2  =  $x2->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  8, 4)));
227
-            $x3  =  $x3->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 12, 4)));
228
-            $x4  =  $x4->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 16, 4)));
229
-            $x5  =  $x5->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 20, 4)));
230
-            $x6  =  $x6->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 24, 4)));
231
-            $x7  =  $x7->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 28, 4)));
232
-            $x8  =  $x8->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 32, 4)));
233
-            $x9  =  $x9->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 36, 4)));
234
-            $x10 = $x10->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 40, 4)));
235
-            $x11 = $x11->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 44, 4)));
236
-            $x12 = $x12->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 48, 4)));
237
-            $x13 = $x13->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 52, 4)));
238
-            $x14 = $x14->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 56, 4)));
239
-            $x15 = $x15->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 60, 4)));
224
+			$x0  =  $x0->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  0, 4)));
225
+			$x1  =  $x1->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  4, 4)));
226
+			$x2  =  $x2->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  8, 4)));
227
+			$x3  =  $x3->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 12, 4)));
228
+			$x4  =  $x4->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 16, 4)));
229
+			$x5  =  $x5->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 20, 4)));
230
+			$x6  =  $x6->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 24, 4)));
231
+			$x7  =  $x7->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 28, 4)));
232
+			$x8  =  $x8->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 32, 4)));
233
+			$x9  =  $x9->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 36, 4)));
234
+			$x10 = $x10->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 40, 4)));
235
+			$x11 = $x11->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 44, 4)));
236
+			$x12 = $x12->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 48, 4)));
237
+			$x13 = $x13->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 52, 4)));
238
+			$x14 = $x14->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 56, 4)));
239
+			$x15 = $x15->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 60, 4)));
240 240
 
241
-            /*
241
+			/*
242 242
                 j12 = PLUSONE(j12);
243 243
                 if (!j12) {
244 244
                     j13 = PLUSONE(j13);
245 245
                 }
246 246
              */
247
-            /** @var ParagonIE_Sodium_Core32_Int32 $j12 */
248
-            $j12 = $j12->addInt(1);
249
-            if ($j12->limbs[0] === 0 && $j12->limbs[1] === 0) {
250
-                $j13 = $j13->addInt(1);
251
-            }
247
+			/** @var ParagonIE_Sodium_Core32_Int32 $j12 */
248
+			$j12 = $j12->addInt(1);
249
+			if ($j12->limbs[0] === 0 && $j12->limbs[1] === 0) {
250
+				$j13 = $j13->addInt(1);
251
+			}
252 252
 
253
-            /*
253
+			/*
254 254
             STORE32_LE(c + 0, x0);
255 255
             STORE32_LE(c + 4, x1);
256 256
             STORE32_LE(c + 8, x2);
@@ -269,107 +269,107 @@  discard block
 block discarded – undo
269 269
             STORE32_LE(c + 60, x15);
270 270
             */
271 271
 
272
-            $block = $x0->toReverseString() .
273
-                $x1->toReverseString() .
274
-                $x2->toReverseString() .
275
-                $x3->toReverseString() .
276
-                $x4->toReverseString() .
277
-                $x5->toReverseString() .
278
-                $x6->toReverseString() .
279
-                $x7->toReverseString() .
280
-                $x8->toReverseString() .
281
-                $x9->toReverseString() .
282
-                $x10->toReverseString() .
283
-                $x11->toReverseString() .
284
-                $x12->toReverseString() .
285
-                $x13->toReverseString() .
286
-                $x14->toReverseString() .
287
-                $x15->toReverseString();
272
+			$block = $x0->toReverseString() .
273
+				$x1->toReverseString() .
274
+				$x2->toReverseString() .
275
+				$x3->toReverseString() .
276
+				$x4->toReverseString() .
277
+				$x5->toReverseString() .
278
+				$x6->toReverseString() .
279
+				$x7->toReverseString() .
280
+				$x8->toReverseString() .
281
+				$x9->toReverseString() .
282
+				$x10->toReverseString() .
283
+				$x11->toReverseString() .
284
+				$x12->toReverseString() .
285
+				$x13->toReverseString() .
286
+				$x14->toReverseString() .
287
+				$x15->toReverseString();
288 288
 
289
-            /* Partial block */
290
-            if ($bytes < 64) {
291
-                $c .= self::substr($block, 0, $bytes);
292
-                break;
293
-            }
289
+			/* Partial block */
290
+			if ($bytes < 64) {
291
+				$c .= self::substr($block, 0, $bytes);
292
+				break;
293
+			}
294 294
 
295
-            /* Full block */
296
-            $c .= $block;
297
-            $bytes -= 64;
298
-            if ($bytes <= 0) {
299
-                break;
300
-            }
301
-            $message = self::substr($message, 64);
302
-        }
303
-        /* end for(;;) loop */
295
+			/* Full block */
296
+			$c .= $block;
297
+			$bytes -= 64;
298
+			if ($bytes <= 0) {
299
+				break;
300
+			}
301
+			$message = self::substr($message, 64);
302
+		}
303
+		/* end for(;;) loop */
304 304
 
305
-        $ctx[12] = $j12;
306
-        $ctx[13] = $j13;
307
-        return $c;
308
-    }
305
+		$ctx[12] = $j12;
306
+		$ctx[13] = $j13;
307
+		return $c;
308
+	}
309 309
 
310
-    /**
311
-     * @internal You should not use this directly from another application
312
-     *
313
-     * @param int $len
314
-     * @param string $nonce
315
-     * @param string $key
316
-     * @return string
317
-     */
318
-    public static function stream($len = 64, $nonce = '', $key = '')
319
-    {
320
-        return self::encryptBytes(
321
-            new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce),
322
-            str_repeat("\x00", $len)
323
-        );
324
-    }
310
+	/**
311
+	 * @internal You should not use this directly from another application
312
+	 *
313
+	 * @param int $len
314
+	 * @param string $nonce
315
+	 * @param string $key
316
+	 * @return string
317
+	 */
318
+	public static function stream($len = 64, $nonce = '', $key = '')
319
+	{
320
+		return self::encryptBytes(
321
+			new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce),
322
+			str_repeat("\x00", $len)
323
+		);
324
+	}
325 325
 
326
-    /**
327
-     * @internal You should not use this directly from another application
328
-     *
329
-     * @param int $len
330
-     * @param string $nonce
331
-     * @param string $key
332
-     * @return string
333
-     */
334
-    public static function ietfStream($len, $nonce = '', $key = '')
335
-    {
336
-        return self::encryptBytes(
337
-            new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce),
338
-            str_repeat("\x00", $len)
339
-        );
340
-    }
326
+	/**
327
+	 * @internal You should not use this directly from another application
328
+	 *
329
+	 * @param int $len
330
+	 * @param string $nonce
331
+	 * @param string $key
332
+	 * @return string
333
+	 */
334
+	public static function ietfStream($len, $nonce = '', $key = '')
335
+	{
336
+		return self::encryptBytes(
337
+			new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce),
338
+			str_repeat("\x00", $len)
339
+		);
340
+	}
341 341
 
342
-    /**
343
-     * @internal You should not use this directly from another application
344
-     *
345
-     * @param string $message
346
-     * @param string $nonce
347
-     * @param string $key
348
-     * @param string $ic
349
-     * @return string
350
-     */
351
-    public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '')
352
-    {
353
-        return self::encryptBytes(
354
-            new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce, $ic),
355
-            $message
356
-        );
357
-    }
342
+	/**
343
+	 * @internal You should not use this directly from another application
344
+	 *
345
+	 * @param string $message
346
+	 * @param string $nonce
347
+	 * @param string $key
348
+	 * @param string $ic
349
+	 * @return string
350
+	 */
351
+	public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '')
352
+	{
353
+		return self::encryptBytes(
354
+			new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce, $ic),
355
+			$message
356
+		);
357
+	}
358 358
 
359
-    /**
360
-     * @internal You should not use this directly from another application
361
-     *
362
-     * @param string $message
363
-     * @param string $nonce
364
-     * @param string $key
365
-     * @param string $ic
366
-     * @return string
367
-     */
368
-    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
369
-    {
370
-        return self::encryptBytes(
371
-            new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce, $ic),
372
-            $message
373
-        );
374
-    }
359
+	/**
360
+	 * @internal You should not use this directly from another application
361
+	 *
362
+	 * @param string $message
363
+	 * @param string $nonce
364
+	 * @param string $key
365
+	 * @param string $ic
366
+	 * @return string
367
+	 */
368
+	public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
369
+	{
370
+		return self::encryptBytes(
371
+			new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce, $ic),
372
+			$message
373
+		);
374
+	}
375 375
 }
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_ChaCha20', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_ChaCha20', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
         /** @var ParagonIE_Sodium_Core32_Int32 $d */
33 33
 
34 34
         # a = PLUS(a,b); d = ROTATE(XOR(d,a),16);
35
-        $a = $a->addInt32($b);
36
-        $d = $d->xorInt32($a)->rotateLeft(16);
35
+        $a = $a->addInt32( $b );
36
+        $d = $d->xorInt32( $a )->rotateLeft( 16 );
37 37
 
38 38
         # c = PLUS(c,d); b = ROTATE(XOR(b,c),12);
39
-        $c = $c->addInt32($d);
40
-        $b = $b->xorInt32($c)->rotateLeft(12);
39
+        $c = $c->addInt32( $d );
40
+        $b = $b->xorInt32( $c )->rotateLeft( 12 );
41 41
 
42 42
         # a = PLUS(a,b); d = ROTATE(XOR(d,a), 8);
43
-        $a = $a->addInt32($b);
44
-        $d = $d->xorInt32($a)->rotateLeft(8);
43
+        $a = $a->addInt32( $b );
44
+        $d = $d->xorInt32( $a )->rotateLeft( 8 );
45 45
 
46 46
         # c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
47
-        $c = $c->addInt32($d);
48
-        $b = $b->xorInt32($c)->rotateLeft(7);
47
+        $c = $c->addInt32( $d );
48
+        $b = $b->xorInt32( $c )->rotateLeft( 7 );
49 49
 
50
-        return array($a, $b, $c, $d);
50
+        return array( $a, $b, $c, $d );
51 51
     }
52 52
 
53 53
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         ParagonIE_Sodium_Core32_ChaCha20_Ctx $ctx,
64 64
         $message = ''
65 65
     ) {
66
-        $bytes = self::strlen($message);
66
+        $bytes = self::strlen( $message );
67 67
 
68 68
         /**
69 69
          * @var ParagonIE_Sodium_Core32_Int32 $x0
@@ -120,21 +120,21 @@  discard block
 block discarded – undo
120 120
         $j15 = $ctx[15];
121 121
 
122 122
         $c = '';
123
-        for (;;) {
124
-            if ($bytes < 64) {
125
-                $message .= str_repeat("\x00", 64 - $bytes);
123
+        for ( ;; ) {
124
+            if ( $bytes < 64 ) {
125
+                $message .= str_repeat( "\x00", 64 - $bytes );
126 126
             }
127 127
 
128
-            $x0 =  clone $j0;
129
-            $x1 =  clone $j1;
130
-            $x2 =  clone $j2;
131
-            $x3 =  clone $j3;
132
-            $x4 =  clone $j4;
133
-            $x5 =  clone $j5;
134
-            $x6 =  clone $j6;
135
-            $x7 =  clone $j7;
136
-            $x8 =  clone $j8;
137
-            $x9 =  clone $j9;
128
+            $x0 = clone $j0;
129
+            $x1 = clone $j1;
130
+            $x2 = clone $j2;
131
+            $x3 = clone $j3;
132
+            $x4 = clone $j4;
133
+            $x5 = clone $j5;
134
+            $x6 = clone $j6;
135
+            $x7 = clone $j7;
136
+            $x8 = clone $j8;
137
+            $x9 = clone $j9;
138 138
             $x10 = clone $j10;
139 139
             $x11 = clone $j11;
140 140
             $x12 = clone $j12;
@@ -143,30 +143,30 @@  discard block
 block discarded – undo
143 143
             $x15 = clone $j15;
144 144
 
145 145
             # for (i = 20; i > 0; i -= 2) {
146
-            for ($i = 20; $i > 0; $i -= 2) {
146
+            for ( $i = 20; $i > 0; $i -= 2 ) {
147 147
                 # QUARTERROUND( x0,  x4,  x8,  x12)
148
-                list($x0, $x4, $x8, $x12) = self::quarterRound($x0, $x4, $x8, $x12);
148
+                list( $x0, $x4, $x8, $x12 ) = self::quarterRound( $x0, $x4, $x8, $x12 );
149 149
 
150 150
                 # QUARTERROUND( x1,  x5,  x9,  x13)
151
-                list($x1, $x5, $x9, $x13) = self::quarterRound($x1, $x5, $x9, $x13);
151
+                list( $x1, $x5, $x9, $x13 ) = self::quarterRound( $x1, $x5, $x9, $x13 );
152 152
 
153 153
                 # QUARTERROUND( x2,  x6,  x10,  x14)
154
-                list($x2, $x6, $x10, $x14) = self::quarterRound($x2, $x6, $x10, $x14);
154
+                list( $x2, $x6, $x10, $x14 ) = self::quarterRound( $x2, $x6, $x10, $x14 );
155 155
 
156 156
                 # QUARTERROUND( x3,  x7,  x11,  x15)
157
-                list($x3, $x7, $x11, $x15) = self::quarterRound($x3, $x7, $x11, $x15);
157
+                list( $x3, $x7, $x11, $x15 ) = self::quarterRound( $x3, $x7, $x11, $x15 );
158 158
 
159 159
                 # QUARTERROUND( x0,  x5,  x10,  x15)
160
-                list($x0, $x5, $x10, $x15) = self::quarterRound($x0, $x5, $x10, $x15);
160
+                list( $x0, $x5, $x10, $x15 ) = self::quarterRound( $x0, $x5, $x10, $x15 );
161 161
 
162 162
                 # QUARTERROUND( x1,  x6,  x11,  x12)
163
-                list($x1, $x6, $x11, $x12) = self::quarterRound($x1, $x6, $x11, $x12);
163
+                list( $x1, $x6, $x11, $x12 ) = self::quarterRound( $x1, $x6, $x11, $x12 );
164 164
 
165 165
                 # QUARTERROUND( x2,  x7,  x8,  x13)
166
-                list($x2, $x7, $x8, $x13) = self::quarterRound($x2, $x7, $x8, $x13);
166
+                list( $x2, $x7, $x8, $x13 ) = self::quarterRound( $x2, $x7, $x8, $x13 );
167 167
 
168 168
                 # QUARTERROUND( x3,  x4,  x9,  x14)
169
-                list($x3, $x4, $x9, $x14) = self::quarterRound($x3, $x4, $x9, $x14);
169
+                list( $x3, $x4, $x9, $x14 ) = self::quarterRound( $x3, $x4, $x9, $x14 );
170 170
             }
171 171
             /*
172 172
             x0 = PLUS(x0, j0);
@@ -186,22 +186,22 @@  discard block
 block discarded – undo
186 186
             x14 = PLUS(x14, j14);
187 187
             x15 = PLUS(x15, j15);
188 188
             */
189
-            $x0 = $x0->addInt32($j0);
190
-            $x1 = $x1->addInt32($j1);
191
-            $x2 = $x2->addInt32($j2);
192
-            $x3 = $x3->addInt32($j3);
193
-            $x4 = $x4->addInt32($j4);
194
-            $x5 = $x5->addInt32($j5);
195
-            $x6 = $x6->addInt32($j6);
196
-            $x7 = $x7->addInt32($j7);
197
-            $x8 = $x8->addInt32($j8);
198
-            $x9 = $x9->addInt32($j9);
199
-            $x10 = $x10->addInt32($j10);
200
-            $x11 = $x11->addInt32($j11);
201
-            $x12 = $x12->addInt32($j12);
202
-            $x13 = $x13->addInt32($j13);
203
-            $x14 = $x14->addInt32($j14);
204
-            $x15 = $x15->addInt32($j15);
189
+            $x0 = $x0->addInt32( $j0 );
190
+            $x1 = $x1->addInt32( $j1 );
191
+            $x2 = $x2->addInt32( $j2 );
192
+            $x3 = $x3->addInt32( $j3 );
193
+            $x4 = $x4->addInt32( $j4 );
194
+            $x5 = $x5->addInt32( $j5 );
195
+            $x6 = $x6->addInt32( $j6 );
196
+            $x7 = $x7->addInt32( $j7 );
197
+            $x8 = $x8->addInt32( $j8 );
198
+            $x9 = $x9->addInt32( $j9 );
199
+            $x10 = $x10->addInt32( $j10 );
200
+            $x11 = $x11->addInt32( $j11 );
201
+            $x12 = $x12->addInt32( $j12 );
202
+            $x13 = $x13->addInt32( $j13 );
203
+            $x14 = $x14->addInt32( $j14 );
204
+            $x15 = $x15->addInt32( $j15 );
205 205
 
206 206
             /*
207 207
             x0 = XOR(x0, LOAD32_LE(m + 0));
@@ -221,22 +221,22 @@  discard block
 block discarded – undo
221 221
             x14 = XOR(x14, LOAD32_LE(m + 56));
222 222
             x15 = XOR(x15, LOAD32_LE(m + 60));
223 223
             */
224
-            $x0  =  $x0->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  0, 4)));
225
-            $x1  =  $x1->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  4, 4)));
226
-            $x2  =  $x2->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message,  8, 4)));
227
-            $x3  =  $x3->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 12, 4)));
228
-            $x4  =  $x4->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 16, 4)));
229
-            $x5  =  $x5->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 20, 4)));
230
-            $x6  =  $x6->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 24, 4)));
231
-            $x7  =  $x7->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 28, 4)));
232
-            $x8  =  $x8->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 32, 4)));
233
-            $x9  =  $x9->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 36, 4)));
234
-            $x10 = $x10->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 40, 4)));
235
-            $x11 = $x11->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 44, 4)));
236
-            $x12 = $x12->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 48, 4)));
237
-            $x13 = $x13->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 52, 4)));
238
-            $x14 = $x14->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 56, 4)));
239
-            $x15 = $x15->xorInt32(ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 60, 4)));
224
+            $x0  = $x0->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 0, 4 ) ) );
225
+            $x1  = $x1->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 4, 4 ) ) );
226
+            $x2  = $x2->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 8, 4 ) ) );
227
+            $x3  = $x3->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 12, 4 ) ) );
228
+            $x4  = $x4->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 16, 4 ) ) );
229
+            $x5  = $x5->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 20, 4 ) ) );
230
+            $x6  = $x6->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 24, 4 ) ) );
231
+            $x7  = $x7->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 28, 4 ) ) );
232
+            $x8  = $x8->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 32, 4 ) ) );
233
+            $x9  = $x9->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 36, 4 ) ) );
234
+            $x10 = $x10->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 40, 4 ) ) );
235
+            $x11 = $x11->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 44, 4 ) ) );
236
+            $x12 = $x12->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 48, 4 ) ) );
237
+            $x13 = $x13->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 52, 4 ) ) );
238
+            $x14 = $x14->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 56, 4 ) ) );
239
+            $x15 = $x15->xorInt32( ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $message, 60, 4 ) ) );
240 240
 
241 241
             /*
242 242
                 j12 = PLUSONE(j12);
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
                 }
246 246
              */
247 247
             /** @var ParagonIE_Sodium_Core32_Int32 $j12 */
248
-            $j12 = $j12->addInt(1);
249
-            if ($j12->limbs[0] === 0 && $j12->limbs[1] === 0) {
250
-                $j13 = $j13->addInt(1);
248
+            $j12 = $j12->addInt( 1 );
249
+            if ( $j12->limbs[0] === 0 && $j12->limbs[1] === 0 ) {
250
+                $j13 = $j13->addInt( 1 );
251 251
             }
252 252
 
253 253
             /*
@@ -287,18 +287,18 @@  discard block
 block discarded – undo
287 287
                 $x15->toReverseString();
288 288
 
289 289
             /* Partial block */
290
-            if ($bytes < 64) {
291
-                $c .= self::substr($block, 0, $bytes);
290
+            if ( $bytes < 64 ) {
291
+                $c .= self::substr( $block, 0, $bytes );
292 292
                 break;
293 293
             }
294 294
 
295 295
             /* Full block */
296 296
             $c .= $block;
297 297
             $bytes -= 64;
298
-            if ($bytes <= 0) {
298
+            if ( $bytes <= 0 ) {
299 299
                 break;
300 300
             }
301
-            $message = self::substr($message, 64);
301
+            $message = self::substr( $message, 64 );
302 302
         }
303 303
         /* end for(;;) loop */
304 304
 
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
      * @param string $key
316 316
      * @return string
317 317
      */
318
-    public static function stream($len = 64, $nonce = '', $key = '')
318
+    public static function stream( $len = 64, $nonce = '', $key = '' )
319 319
     {
320 320
         return self::encryptBytes(
321
-            new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce),
322
-            str_repeat("\x00", $len)
321
+            new ParagonIE_Sodium_Core32_ChaCha20_Ctx( $key, $nonce ),
322
+            str_repeat( "\x00", $len )
323 323
         );
324 324
     }
325 325
 
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
      * @param string $key
332 332
      * @return string
333 333
      */
334
-    public static function ietfStream($len, $nonce = '', $key = '')
334
+    public static function ietfStream( $len, $nonce = '', $key = '' )
335 335
     {
336 336
         return self::encryptBytes(
337
-            new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce),
338
-            str_repeat("\x00", $len)
337
+            new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx( $key, $nonce ),
338
+            str_repeat( "\x00", $len )
339 339
         );
340 340
     }
341 341
 
@@ -348,10 +348,10 @@  discard block
 block discarded – undo
348 348
      * @param string $ic
349 349
      * @return string
350 350
      */
351
-    public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '')
351
+    public static function ietfStreamXorIc( $message, $nonce = '', $key = '', $ic = '' )
352 352
     {
353 353
         return self::encryptBytes(
354
-            new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce, $ic),
354
+            new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx( $key, $nonce, $ic ),
355 355
             $message
356 356
         );
357 357
     }
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
      * @param string $ic
366 366
      * @return string
367 367
      */
368
-    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
368
+    public static function streamXorIc( $message, $nonce = '', $key = '', $ic = '' )
369 369
     {
370 370
         return self::encryptBytes(
371
-            new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce, $ic),
371
+            new ParagonIE_Sodium_Core32_ChaCha20_Ctx( $key, $nonce, $ic ),
372 372
             $message
373 373
         );
374 374
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_ChaCha20
9 9
  */
10
-class ParagonIE_Sodium_Core32_ChaCha20 extends ParagonIE_Sodium_Core32_Util
11
-{
10
+class ParagonIE_Sodium_Core32_ChaCha20 extends ParagonIE_Sodium_Core32_Util {
12 11
     /**
13 12
      * The ChaCha20 quarter round function. Works on four 32-bit integers.
14 13
      *
@@ -315,8 +314,7 @@  discard block
 block discarded – undo
315 314
      * @param string $key
316 315
      * @return string
317 316
      */
318
-    public static function stream($len = 64, $nonce = '', $key = '')
319
-    {
317
+    public static function stream($len = 64, $nonce = '', $key = '') {
320 318
         return self::encryptBytes(
321 319
             new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce),
322 320
             str_repeat("\x00", $len)
@@ -331,8 +329,7 @@  discard block
 block discarded – undo
331 329
      * @param string $key
332 330
      * @return string
333 331
      */
334
-    public static function ietfStream($len, $nonce = '', $key = '')
335
-    {
332
+    public static function ietfStream($len, $nonce = '', $key = '') {
336 333
         return self::encryptBytes(
337 334
             new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce),
338 335
             str_repeat("\x00", $len)
@@ -348,8 +345,7 @@  discard block
 block discarded – undo
348 345
      * @param string $ic
349 346
      * @return string
350 347
      */
351
-    public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '')
352
-    {
348
+    public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') {
353 349
         return self::encryptBytes(
354 350
             new ParagonIE_Sodium_Core32_ChaCha20_IetfCtx($key, $nonce, $ic),
355 351
             $message
@@ -365,8 +361,7 @@  discard block
 block discarded – undo
365 361
      * @param string $ic
366 362
      * @return string
367 363
      */
368
-    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '')
369
-    {
364
+    public static function streamXorIc($message, $nonce = '', $key = '', $ic = '') {
370 365
         return self::encryptBytes(
371 366
             new ParagonIE_Sodium_Core32_ChaCha20_Ctx($key, $nonce, $ic),
372 367
             $message
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/X25519.php 3 patches
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core32_X25519', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,118 +9,118 @@  discard block
 block discarded – undo
9 9
  */
10 10
 abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Curve25519
11 11
 {
12
-    /**
13
-     * Alters the objects passed to this method in place.
14
-     *
15
-     * @internal You should not use this directly from another application
16
-     *
17
-     * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f
18
-     * @param ParagonIE_Sodium_Core32_Curve25519_Fe $g
19
-     * @param int $b
20
-     * @return void
21
-     */
22
-    public static function fe_cswap(
23
-        ParagonIE_Sodium_Core32_Curve25519_Fe $f,
24
-        ParagonIE_Sodium_Core32_Curve25519_Fe $g,
25
-        $b = 0
26
-    ) {
27
-        $f0 = (int) $f[0]->toInt();
28
-        $f1 = (int) $f[1]->toInt();
29
-        $f2 = (int) $f[2]->toInt();
30
-        $f3 = (int) $f[3]->toInt();
31
-        $f4 = (int) $f[4]->toInt();
32
-        $f5 = (int) $f[5]->toInt();
33
-        $f6 = (int) $f[6]->toInt();
34
-        $f7 = (int) $f[7]->toInt();
35
-        $f8 = (int) $f[8]->toInt();
36
-        $f9 = (int) $f[9]->toInt();
37
-        $g0 = (int) $g[0]->toInt();
38
-        $g1 = (int) $g[1]->toInt();
39
-        $g2 = (int) $g[2]->toInt();
40
-        $g3 = (int) $g[3]->toInt();
41
-        $g4 = (int) $g[4]->toInt();
42
-        $g5 = (int) $g[5]->toInt();
43
-        $g6 = (int) $g[6]->toInt();
44
-        $g7 = (int) $g[7]->toInt();
45
-        $g8 = (int) $g[8]->toInt();
46
-        $g9 = (int) $g[9]->toInt();
47
-        $b = -$b;
48
-        $x0 = ($f0 ^ $g0) & $b;
49
-        $x1 = ($f1 ^ $g1) & $b;
50
-        $x2 = ($f2 ^ $g2) & $b;
51
-        $x3 = ($f3 ^ $g3) & $b;
52
-        $x4 = ($f4 ^ $g4) & $b;
53
-        $x5 = ($f5 ^ $g5) & $b;
54
-        $x6 = ($f6 ^ $g6) & $b;
55
-        $x7 = ($f7 ^ $g7) & $b;
56
-        $x8 = ($f8 ^ $g8) & $b;
57
-        $x9 = ($f9 ^ $g9) & $b;
58
-        $f[0] = ParagonIE_Sodium_Core32_Int32::fromInt($f0 ^ $x0);
59
-        $f[1] = ParagonIE_Sodium_Core32_Int32::fromInt($f1 ^ $x1);
60
-        $f[2] = ParagonIE_Sodium_Core32_Int32::fromInt($f2 ^ $x2);
61
-        $f[3] = ParagonIE_Sodium_Core32_Int32::fromInt($f3 ^ $x3);
62
-        $f[4] = ParagonIE_Sodium_Core32_Int32::fromInt($f4 ^ $x4);
63
-        $f[5] = ParagonIE_Sodium_Core32_Int32::fromInt($f5 ^ $x5);
64
-        $f[6] = ParagonIE_Sodium_Core32_Int32::fromInt($f6 ^ $x6);
65
-        $f[7] = ParagonIE_Sodium_Core32_Int32::fromInt($f7 ^ $x7);
66
-        $f[8] = ParagonIE_Sodium_Core32_Int32::fromInt($f8 ^ $x8);
67
-        $f[9] = ParagonIE_Sodium_Core32_Int32::fromInt($f9 ^ $x9);
68
-        $g[0] = ParagonIE_Sodium_Core32_Int32::fromInt($g0 ^ $x0);
69
-        $g[1] = ParagonIE_Sodium_Core32_Int32::fromInt($g1 ^ $x1);
70
-        $g[2] = ParagonIE_Sodium_Core32_Int32::fromInt($g2 ^ $x2);
71
-        $g[3] = ParagonIE_Sodium_Core32_Int32::fromInt($g3 ^ $x3);
72
-        $g[4] = ParagonIE_Sodium_Core32_Int32::fromInt($g4 ^ $x4);
73
-        $g[5] = ParagonIE_Sodium_Core32_Int32::fromInt($g5 ^ $x5);
74
-        $g[6] = ParagonIE_Sodium_Core32_Int32::fromInt($g6 ^ $x6);
75
-        $g[7] = ParagonIE_Sodium_Core32_Int32::fromInt($g7 ^ $x7);
76
-        $g[8] = ParagonIE_Sodium_Core32_Int32::fromInt($g8 ^ $x8);
77
-        $g[9] = ParagonIE_Sodium_Core32_Int32::fromInt($g9 ^ $x9);
78
-    }
79
-
80
-    /**
81
-     * @internal You should not use this directly from another application
82
-     *
83
-     * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f
84
-     * @return ParagonIE_Sodium_Core32_Curve25519_Fe
85
-     */
86
-    public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f)
87
-    {
88
-        /** @var ParagonIE_Sodium_Core32_Int32[] $h */
89
-        $h = array(
90
-            $f[0]->mulInt(121666),
91
-            $f[1]->mulInt(121666),
92
-            $f[2]->mulInt(121666),
93
-            $f[3]->mulInt(121666),
94
-            $f[4]->mulInt(121666),
95
-            $f[5]->mulInt(121666),
96
-            $f[6]->mulInt(121666),
97
-            $f[7]->mulInt(121666),
98
-            $f[8]->mulInt(121666),
99
-            $f[9]->mulInt(121666),
100
-        );
101
-
102
-        /** @var ParagonIE_Sodium_Core32_Int32 $carry9 */
103
-        $carry9 = $h[9]->addInt(1 << 24)->shiftRight(25);
104
-        $h[0] = $carry9->mulInt(19);
105
-        $h[9] = $h[9]->subInt32($carry9->shiftLeft(25));
106
-
107
-        $carry1 = $h[1]->addInt(1 << 24)->shiftRight(25);
108
-        $h[2] = $h[2]->addInt32($carry1);
109
-        $h[1] = $h[1]->subInt32($carry1->shiftLeft(25));
110
-
111
-        $carry3 = $h[3]->addInt(1 << 24)->shiftRight(25);
112
-        $h[4] = $h[4]->addInt32($carry3);
113
-        $h[3] = $h[3]->subInt32($carry3->shiftLeft(25));
114
-
115
-        $carry5 = $h[3]->addInt(1 << 24)->shiftRight(25);
116
-        $h[6] = $h[6]->addInt32($carry5);
117
-        $h[5] = $h[5]->subInt32($carry5->shiftLeft(25));
118
-
119
-        $carry7 = $h[3]->addInt(1 << 24)->shiftRight(25);
120
-        $h[8] = $h[8]->addInt32($carry7);
121
-        $h[7] = $h[7]->subInt32($carry7->shiftLeft(25));
122
-
123
-        /*
12
+	/**
13
+	 * Alters the objects passed to this method in place.
14
+	 *
15
+	 * @internal You should not use this directly from another application
16
+	 *
17
+	 * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f
18
+	 * @param ParagonIE_Sodium_Core32_Curve25519_Fe $g
19
+	 * @param int $b
20
+	 * @return void
21
+	 */
22
+	public static function fe_cswap(
23
+		ParagonIE_Sodium_Core32_Curve25519_Fe $f,
24
+		ParagonIE_Sodium_Core32_Curve25519_Fe $g,
25
+		$b = 0
26
+	) {
27
+		$f0 = (int) $f[0]->toInt();
28
+		$f1 = (int) $f[1]->toInt();
29
+		$f2 = (int) $f[2]->toInt();
30
+		$f3 = (int) $f[3]->toInt();
31
+		$f4 = (int) $f[4]->toInt();
32
+		$f5 = (int) $f[5]->toInt();
33
+		$f6 = (int) $f[6]->toInt();
34
+		$f7 = (int) $f[7]->toInt();
35
+		$f8 = (int) $f[8]->toInt();
36
+		$f9 = (int) $f[9]->toInt();
37
+		$g0 = (int) $g[0]->toInt();
38
+		$g1 = (int) $g[1]->toInt();
39
+		$g2 = (int) $g[2]->toInt();
40
+		$g3 = (int) $g[3]->toInt();
41
+		$g4 = (int) $g[4]->toInt();
42
+		$g5 = (int) $g[5]->toInt();
43
+		$g6 = (int) $g[6]->toInt();
44
+		$g7 = (int) $g[7]->toInt();
45
+		$g8 = (int) $g[8]->toInt();
46
+		$g9 = (int) $g[9]->toInt();
47
+		$b = -$b;
48
+		$x0 = ($f0 ^ $g0) & $b;
49
+		$x1 = ($f1 ^ $g1) & $b;
50
+		$x2 = ($f2 ^ $g2) & $b;
51
+		$x3 = ($f3 ^ $g3) & $b;
52
+		$x4 = ($f4 ^ $g4) & $b;
53
+		$x5 = ($f5 ^ $g5) & $b;
54
+		$x6 = ($f6 ^ $g6) & $b;
55
+		$x7 = ($f7 ^ $g7) & $b;
56
+		$x8 = ($f8 ^ $g8) & $b;
57
+		$x9 = ($f9 ^ $g9) & $b;
58
+		$f[0] = ParagonIE_Sodium_Core32_Int32::fromInt($f0 ^ $x0);
59
+		$f[1] = ParagonIE_Sodium_Core32_Int32::fromInt($f1 ^ $x1);
60
+		$f[2] = ParagonIE_Sodium_Core32_Int32::fromInt($f2 ^ $x2);
61
+		$f[3] = ParagonIE_Sodium_Core32_Int32::fromInt($f3 ^ $x3);
62
+		$f[4] = ParagonIE_Sodium_Core32_Int32::fromInt($f4 ^ $x4);
63
+		$f[5] = ParagonIE_Sodium_Core32_Int32::fromInt($f5 ^ $x5);
64
+		$f[6] = ParagonIE_Sodium_Core32_Int32::fromInt($f6 ^ $x6);
65
+		$f[7] = ParagonIE_Sodium_Core32_Int32::fromInt($f7 ^ $x7);
66
+		$f[8] = ParagonIE_Sodium_Core32_Int32::fromInt($f8 ^ $x8);
67
+		$f[9] = ParagonIE_Sodium_Core32_Int32::fromInt($f9 ^ $x9);
68
+		$g[0] = ParagonIE_Sodium_Core32_Int32::fromInt($g0 ^ $x0);
69
+		$g[1] = ParagonIE_Sodium_Core32_Int32::fromInt($g1 ^ $x1);
70
+		$g[2] = ParagonIE_Sodium_Core32_Int32::fromInt($g2 ^ $x2);
71
+		$g[3] = ParagonIE_Sodium_Core32_Int32::fromInt($g3 ^ $x3);
72
+		$g[4] = ParagonIE_Sodium_Core32_Int32::fromInt($g4 ^ $x4);
73
+		$g[5] = ParagonIE_Sodium_Core32_Int32::fromInt($g5 ^ $x5);
74
+		$g[6] = ParagonIE_Sodium_Core32_Int32::fromInt($g6 ^ $x6);
75
+		$g[7] = ParagonIE_Sodium_Core32_Int32::fromInt($g7 ^ $x7);
76
+		$g[8] = ParagonIE_Sodium_Core32_Int32::fromInt($g8 ^ $x8);
77
+		$g[9] = ParagonIE_Sodium_Core32_Int32::fromInt($g9 ^ $x9);
78
+	}
79
+
80
+	/**
81
+	 * @internal You should not use this directly from another application
82
+	 *
83
+	 * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f
84
+	 * @return ParagonIE_Sodium_Core32_Curve25519_Fe
85
+	 */
86
+	public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f)
87
+	{
88
+		/** @var ParagonIE_Sodium_Core32_Int32[] $h */
89
+		$h = array(
90
+			$f[0]->mulInt(121666),
91
+			$f[1]->mulInt(121666),
92
+			$f[2]->mulInt(121666),
93
+			$f[3]->mulInt(121666),
94
+			$f[4]->mulInt(121666),
95
+			$f[5]->mulInt(121666),
96
+			$f[6]->mulInt(121666),
97
+			$f[7]->mulInt(121666),
98
+			$f[8]->mulInt(121666),
99
+			$f[9]->mulInt(121666),
100
+		);
101
+
102
+		/** @var ParagonIE_Sodium_Core32_Int32 $carry9 */
103
+		$carry9 = $h[9]->addInt(1 << 24)->shiftRight(25);
104
+		$h[0] = $carry9->mulInt(19);
105
+		$h[9] = $h[9]->subInt32($carry9->shiftLeft(25));
106
+
107
+		$carry1 = $h[1]->addInt(1 << 24)->shiftRight(25);
108
+		$h[2] = $h[2]->addInt32($carry1);
109
+		$h[1] = $h[1]->subInt32($carry1->shiftLeft(25));
110
+
111
+		$carry3 = $h[3]->addInt(1 << 24)->shiftRight(25);
112
+		$h[4] = $h[4]->addInt32($carry3);
113
+		$h[3] = $h[3]->subInt32($carry3->shiftLeft(25));
114
+
115
+		$carry5 = $h[3]->addInt(1 << 24)->shiftRight(25);
116
+		$h[6] = $h[6]->addInt32($carry5);
117
+		$h[5] = $h[5]->subInt32($carry5->shiftLeft(25));
118
+
119
+		$carry7 = $h[3]->addInt(1 << 24)->shiftRight(25);
120
+		$h[8] = $h[8]->addInt32($carry7);
121
+		$h[7] = $h[7]->subInt32($carry7->shiftLeft(25));
122
+
123
+		/*
124 124
         $carry9 = ($h[9] + (1 << 24)) >> 25;
125 125
         $h[0] += self::mul($carry9, 19);
126 126
         $h[9] -= $carry9 << 25;
@@ -138,27 +138,27 @@  discard block
 block discarded – undo
138 138
         $h[7] -= $carry7 << 25;
139 139
         */
140 140
 
141
-        $carry0 = $h[0]->addInt(1 << 25)->shiftRight(26);
142
-        $h[1] = $h[1]->addInt32($carry0);
143
-        $h[0] = $h[0]->subInt32($carry0->shiftLeft(26));
141
+		$carry0 = $h[0]->addInt(1 << 25)->shiftRight(26);
142
+		$h[1] = $h[1]->addInt32($carry0);
143
+		$h[0] = $h[0]->subInt32($carry0->shiftLeft(26));
144 144
 
145
-        $carry2 = $h[2]->addInt(1 << 25)->shiftRight(26);
146
-        $h[3] = $h[3]->addInt32($carry2);
147
-        $h[2] = $h[2]->subInt32($carry2->shiftLeft(26));
145
+		$carry2 = $h[2]->addInt(1 << 25)->shiftRight(26);
146
+		$h[3] = $h[3]->addInt32($carry2);
147
+		$h[2] = $h[2]->subInt32($carry2->shiftLeft(26));
148 148
 
149
-        $carry4 = $h[4]->addInt(1 << 25)->shiftRight(26);
150
-        $h[5] = $h[5]->addInt32($carry4);
151
-        $h[4] = $h[4]->subInt32($carry4->shiftLeft(26));
149
+		$carry4 = $h[4]->addInt(1 << 25)->shiftRight(26);
150
+		$h[5] = $h[5]->addInt32($carry4);
151
+		$h[4] = $h[4]->subInt32($carry4->shiftLeft(26));
152 152
 
153
-        $carry6 = $h[6]->addInt(1 << 25)->shiftRight(26);
154
-        $h[7] = $h[7]->addInt32($carry6);
155
-        $h[6] = $h[6]->subInt32($carry6->shiftLeft(26));
153
+		$carry6 = $h[6]->addInt(1 << 25)->shiftRight(26);
154
+		$h[7] = $h[7]->addInt32($carry6);
155
+		$h[6] = $h[6]->subInt32($carry6->shiftLeft(26));
156 156
 
157
-        $carry8 = $h[8]->addInt(1 << 25)->shiftRight(26);
158
-        $h[9] = $h[9]->addInt32($carry8);
159
-        $h[8] = $h[8]->subInt32($carry8->shiftLeft(26));
157
+		$carry8 = $h[8]->addInt(1 << 25)->shiftRight(26);
158
+		$h[9] = $h[9]->addInt32($carry8);
159
+		$h[8] = $h[8]->subInt32($carry8->shiftLeft(26));
160 160
 
161
-        /*
161
+		/*
162 162
         $carry0 = ($h[0] + (1 << 25)) >> 26;
163 163
         $h[1] += $carry0;
164 164
         $h[0] -= $carry0 << 26;
@@ -176,179 +176,179 @@  discard block
 block discarded – undo
176 176
         $h[8] -= $carry8 << 26;
177 177
         */
178 178
 
179
-        return ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray($h);
180
-    }
181
-
182
-    /**
183
-     * @internal You should not use this directly from another application
184
-     *
185
-     * Inline comments preceded by # are from libsodium's ref10 code.
186
-     *
187
-     * @param string $n
188
-     * @param string $p
189
-     * @return string
190
-     */
191
-    public static function crypto_scalarmult_curve25519_ref10($n, $p)
192
-    {
193
-        # for (i = 0;i < 32;++i) e[i] = n[i];
194
-        $e = '' . $n;
195
-        # e[0] &= 248;
196
-        $e[0] = self::intToChr(
197
-            self::chrToInt($e[0]) & 248
198
-        );
199
-        # e[31] &= 127;
200
-        # e[31] |= 64;
201
-        $e[31] = self::intToChr(
202
-            (self::chrToInt($e[31]) & 127) | 64
203
-        );
204
-        # fe_frombytes(x1,p);
205
-        $x1 = self::fe_frombytes($p);
206
-        # fe_1(x2);
207
-        $x2 = self::fe_1();
208
-        # fe_0(z2);
209
-        $z2 = self::fe_0();
210
-        # fe_copy(x3,x1);
211
-        $x3 = self::fe_copy($x1);
212
-        # fe_1(z3);
213
-        $z3 = self::fe_1();
214
-
215
-        # swap = 0;
216
-        $swap = 0;
217
-
218
-        # for (pos = 254;pos >= 0;--pos) {
219
-        for ($pos = 254; $pos >= 0; --$pos) {
220
-            # b = e[pos / 8] >> (pos & 7);
221
-            $b = self::chrToInt(
222
-                    $e[(int) floor($pos / 8)]
223
-                ) >> ($pos & 7);
224
-            # b &= 1;
225
-            $b &= 1;
226
-            # swap ^= b;
227
-            $swap ^= $b;
228
-            # fe_cswap(x2,x3,swap);
229
-            self::fe_cswap($x2, $x3, $swap);
230
-            # fe_cswap(z2,z3,swap);
231
-            self::fe_cswap($z2, $z3, $swap);
232
-            # swap = b;
233
-            $swap = $b;
234
-            # fe_sub(tmp0,x3,z3);
235
-            $tmp0 = self::fe_sub($x3, $z3);
236
-            # fe_sub(tmp1,x2,z2);
237
-            $tmp1 = self::fe_sub($x2, $z2);
238
-
239
-            # fe_add(x2,x2,z2);
240
-            $x2 = self::fe_add($x2, $z2);
241
-
242
-            # fe_add(z2,x3,z3);
243
-            $z2 = self::fe_add($x3, $z3);
244
-
245
-            # fe_mul(z3,tmp0,x2);
246
-            $z3 = self::fe_mul($tmp0, $x2);
247
-
248
-            # fe_mul(z2,z2,tmp1);
249
-            $z2 = self::fe_mul($z2, $tmp1);
250
-
251
-            # fe_sq(tmp0,tmp1);
252
-            $tmp0 = self::fe_sq($tmp1);
253
-
254
-            # fe_sq(tmp1,x2);
255
-            $tmp1 = self::fe_sq($x2);
256
-
257
-            # fe_add(x3,z3,z2);
258
-            $x3 = self::fe_add($z3, $z2);
259
-
260
-            # fe_sub(z2,z3,z2);
261
-            $z2 = self::fe_sub($z3, $z2);
262
-
263
-            # fe_mul(x2,tmp1,tmp0);
264
-            $x2 = self::fe_mul($tmp1, $tmp0);
265
-
266
-            # fe_sub(tmp1,tmp1,tmp0);
267
-            $tmp1 = self::fe_sub($tmp1, $tmp0);
268
-
269
-            # fe_sq(z2,z2);
270
-            $z2 = self::fe_sq($z2);
271
-
272
-            # fe_mul121666(z3,tmp1);
273
-            $z3 = self::fe_mul121666($tmp1);
274
-
275
-            # fe_sq(x3,x3);
276
-            $x3 = self::fe_sq($x3);
277
-
278
-            # fe_add(tmp0,tmp0,z3);
279
-            $tmp0 = self::fe_add($tmp0, $z3);
280
-
281
-            # fe_mul(z3,x1,z2);
282
-            $z3 = self::fe_mul($x1, $z2);
283
-
284
-            # fe_mul(z2,tmp1,tmp0);
285
-            $z2 = self::fe_mul($tmp1, $tmp0);
286
-        }
287
-
288
-        # fe_cswap(x2,x3,swap);
289
-        self::fe_cswap($x2, $x3, $swap);
290
-
291
-        # fe_cswap(z2,z3,swap);
292
-        self::fe_cswap($z2, $z3, $swap);
293
-
294
-        # fe_invert(z2,z2);
295
-        $z2 = self::fe_invert($z2);
296
-
297
-        # fe_mul(x2,x2,z2);
298
-        $x2 = self::fe_mul($x2, $z2);
299
-        # fe_tobytes(q,x2);
300
-        return self::fe_tobytes($x2);
301
-    }
302
-
303
-    /**
304
-     * @internal You should not use this directly from another application
305
-     *
306
-     * @param ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsY
307
-     * @param ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsZ
308
-     * @return ParagonIE_Sodium_Core32_Curve25519_Fe
309
-     */
310
-    public static function edwards_to_montgomery(
311
-        ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsY,
312
-        ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsZ
313
-    ) {
314
-        $tempX = self::fe_add($edwardsZ, $edwardsY);
315
-        $tempZ = self::fe_sub($edwardsZ, $edwardsY);
316
-        $tempZ = self::fe_invert($tempZ);
317
-        return self::fe_mul($tempX, $tempZ);
318
-    }
319
-
320
-    /**
321
-     * @internal You should not use this directly from another application
322
-     *
323
-     * @param string $n
324
-     * @return string
325
-     * @throws TypeError
326
-     */
327
-    public static function crypto_scalarmult_curve25519_ref10_base($n)
328
-    {
329
-        # for (i = 0;i < 32;++i) e[i] = n[i];
330
-        $e = '' . $n;
331
-
332
-        # e[0] &= 248;
333
-        $e[0] = self::intToChr(
334
-            self::chrToInt($e[0]) & 248
335
-        );
336
-
337
-        # e[31] &= 127;
338
-        # e[31] |= 64;
339
-        $e[31] = self::intToChr(
340
-            (self::chrToInt($e[31]) & 127) | 64
341
-        );
342
-
343
-        $A = self::ge_scalarmult_base($e);
344
-        if (
345
-            !($A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
346
-            ||
347
-            !($A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
348
-        ) {
349
-            throw new TypeError('Null points encountered');
350
-        }
351
-        $pk = self::edwards_to_montgomery($A->Y, $A->Z);
352
-        return self::fe_tobytes($pk);
353
-    }
179
+		return ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray($h);
180
+	}
181
+
182
+	/**
183
+	 * @internal You should not use this directly from another application
184
+	 *
185
+	 * Inline comments preceded by # are from libsodium's ref10 code.
186
+	 *
187
+	 * @param string $n
188
+	 * @param string $p
189
+	 * @return string
190
+	 */
191
+	public static function crypto_scalarmult_curve25519_ref10($n, $p)
192
+	{
193
+		# for (i = 0;i < 32;++i) e[i] = n[i];
194
+		$e = '' . $n;
195
+		# e[0] &= 248;
196
+		$e[0] = self::intToChr(
197
+			self::chrToInt($e[0]) & 248
198
+		);
199
+		# e[31] &= 127;
200
+		# e[31] |= 64;
201
+		$e[31] = self::intToChr(
202
+			(self::chrToInt($e[31]) & 127) | 64
203
+		);
204
+		# fe_frombytes(x1,p);
205
+		$x1 = self::fe_frombytes($p);
206
+		# fe_1(x2);
207
+		$x2 = self::fe_1();
208
+		# fe_0(z2);
209
+		$z2 = self::fe_0();
210
+		# fe_copy(x3,x1);
211
+		$x3 = self::fe_copy($x1);
212
+		# fe_1(z3);
213
+		$z3 = self::fe_1();
214
+
215
+		# swap = 0;
216
+		$swap = 0;
217
+
218
+		# for (pos = 254;pos >= 0;--pos) {
219
+		for ($pos = 254; $pos >= 0; --$pos) {
220
+			# b = e[pos / 8] >> (pos & 7);
221
+			$b = self::chrToInt(
222
+					$e[(int) floor($pos / 8)]
223
+				) >> ($pos & 7);
224
+			# b &= 1;
225
+			$b &= 1;
226
+			# swap ^= b;
227
+			$swap ^= $b;
228
+			# fe_cswap(x2,x3,swap);
229
+			self::fe_cswap($x2, $x3, $swap);
230
+			# fe_cswap(z2,z3,swap);
231
+			self::fe_cswap($z2, $z3, $swap);
232
+			# swap = b;
233
+			$swap = $b;
234
+			# fe_sub(tmp0,x3,z3);
235
+			$tmp0 = self::fe_sub($x3, $z3);
236
+			# fe_sub(tmp1,x2,z2);
237
+			$tmp1 = self::fe_sub($x2, $z2);
238
+
239
+			# fe_add(x2,x2,z2);
240
+			$x2 = self::fe_add($x2, $z2);
241
+
242
+			# fe_add(z2,x3,z3);
243
+			$z2 = self::fe_add($x3, $z3);
244
+
245
+			# fe_mul(z3,tmp0,x2);
246
+			$z3 = self::fe_mul($tmp0, $x2);
247
+
248
+			# fe_mul(z2,z2,tmp1);
249
+			$z2 = self::fe_mul($z2, $tmp1);
250
+
251
+			# fe_sq(tmp0,tmp1);
252
+			$tmp0 = self::fe_sq($tmp1);
253
+
254
+			# fe_sq(tmp1,x2);
255
+			$tmp1 = self::fe_sq($x2);
256
+
257
+			# fe_add(x3,z3,z2);
258
+			$x3 = self::fe_add($z3, $z2);
259
+
260
+			# fe_sub(z2,z3,z2);
261
+			$z2 = self::fe_sub($z3, $z2);
262
+
263
+			# fe_mul(x2,tmp1,tmp0);
264
+			$x2 = self::fe_mul($tmp1, $tmp0);
265
+
266
+			# fe_sub(tmp1,tmp1,tmp0);
267
+			$tmp1 = self::fe_sub($tmp1, $tmp0);
268
+
269
+			# fe_sq(z2,z2);
270
+			$z2 = self::fe_sq($z2);
271
+
272
+			# fe_mul121666(z3,tmp1);
273
+			$z3 = self::fe_mul121666($tmp1);
274
+
275
+			# fe_sq(x3,x3);
276
+			$x3 = self::fe_sq($x3);
277
+
278
+			# fe_add(tmp0,tmp0,z3);
279
+			$tmp0 = self::fe_add($tmp0, $z3);
280
+
281
+			# fe_mul(z3,x1,z2);
282
+			$z3 = self::fe_mul($x1, $z2);
283
+
284
+			# fe_mul(z2,tmp1,tmp0);
285
+			$z2 = self::fe_mul($tmp1, $tmp0);
286
+		}
287
+
288
+		# fe_cswap(x2,x3,swap);
289
+		self::fe_cswap($x2, $x3, $swap);
290
+
291
+		# fe_cswap(z2,z3,swap);
292
+		self::fe_cswap($z2, $z3, $swap);
293
+
294
+		# fe_invert(z2,z2);
295
+		$z2 = self::fe_invert($z2);
296
+
297
+		# fe_mul(x2,x2,z2);
298
+		$x2 = self::fe_mul($x2, $z2);
299
+		# fe_tobytes(q,x2);
300
+		return self::fe_tobytes($x2);
301
+	}
302
+
303
+	/**
304
+	 * @internal You should not use this directly from another application
305
+	 *
306
+	 * @param ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsY
307
+	 * @param ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsZ
308
+	 * @return ParagonIE_Sodium_Core32_Curve25519_Fe
309
+	 */
310
+	public static function edwards_to_montgomery(
311
+		ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsY,
312
+		ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsZ
313
+	) {
314
+		$tempX = self::fe_add($edwardsZ, $edwardsY);
315
+		$tempZ = self::fe_sub($edwardsZ, $edwardsY);
316
+		$tempZ = self::fe_invert($tempZ);
317
+		return self::fe_mul($tempX, $tempZ);
318
+	}
319
+
320
+	/**
321
+	 * @internal You should not use this directly from another application
322
+	 *
323
+	 * @param string $n
324
+	 * @return string
325
+	 * @throws TypeError
326
+	 */
327
+	public static function crypto_scalarmult_curve25519_ref10_base($n)
328
+	{
329
+		# for (i = 0;i < 32;++i) e[i] = n[i];
330
+		$e = '' . $n;
331
+
332
+		# e[0] &= 248;
333
+		$e[0] = self::intToChr(
334
+			self::chrToInt($e[0]) & 248
335
+		);
336
+
337
+		# e[31] &= 127;
338
+		# e[31] |= 64;
339
+		$e[31] = self::intToChr(
340
+			(self::chrToInt($e[31]) & 127) | 64
341
+		);
342
+
343
+		$A = self::ge_scalarmult_base($e);
344
+		if (
345
+			!($A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
346
+			||
347
+			!($A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
348
+		) {
349
+			throw new TypeError('Null points encountered');
350
+		}
351
+		$pk = self::edwards_to_montgomery($A->Y, $A->Z);
352
+		return self::fe_tobytes($pk);
353
+	}
354 354
 }
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core32_X25519', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core32_X25519', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -45,36 +45,36 @@  discard block
 block discarded – undo
45 45
         $g8 = (int) $g[8]->toInt();
46 46
         $g9 = (int) $g[9]->toInt();
47 47
         $b = -$b;
48
-        $x0 = ($f0 ^ $g0) & $b;
49
-        $x1 = ($f1 ^ $g1) & $b;
50
-        $x2 = ($f2 ^ $g2) & $b;
51
-        $x3 = ($f3 ^ $g3) & $b;
52
-        $x4 = ($f4 ^ $g4) & $b;
53
-        $x5 = ($f5 ^ $g5) & $b;
54
-        $x6 = ($f6 ^ $g6) & $b;
55
-        $x7 = ($f7 ^ $g7) & $b;
56
-        $x8 = ($f8 ^ $g8) & $b;
57
-        $x9 = ($f9 ^ $g9) & $b;
58
-        $f[0] = ParagonIE_Sodium_Core32_Int32::fromInt($f0 ^ $x0);
59
-        $f[1] = ParagonIE_Sodium_Core32_Int32::fromInt($f1 ^ $x1);
60
-        $f[2] = ParagonIE_Sodium_Core32_Int32::fromInt($f2 ^ $x2);
61
-        $f[3] = ParagonIE_Sodium_Core32_Int32::fromInt($f3 ^ $x3);
62
-        $f[4] = ParagonIE_Sodium_Core32_Int32::fromInt($f4 ^ $x4);
63
-        $f[5] = ParagonIE_Sodium_Core32_Int32::fromInt($f5 ^ $x5);
64
-        $f[6] = ParagonIE_Sodium_Core32_Int32::fromInt($f6 ^ $x6);
65
-        $f[7] = ParagonIE_Sodium_Core32_Int32::fromInt($f7 ^ $x7);
66
-        $f[8] = ParagonIE_Sodium_Core32_Int32::fromInt($f8 ^ $x8);
67
-        $f[9] = ParagonIE_Sodium_Core32_Int32::fromInt($f9 ^ $x9);
68
-        $g[0] = ParagonIE_Sodium_Core32_Int32::fromInt($g0 ^ $x0);
69
-        $g[1] = ParagonIE_Sodium_Core32_Int32::fromInt($g1 ^ $x1);
70
-        $g[2] = ParagonIE_Sodium_Core32_Int32::fromInt($g2 ^ $x2);
71
-        $g[3] = ParagonIE_Sodium_Core32_Int32::fromInt($g3 ^ $x3);
72
-        $g[4] = ParagonIE_Sodium_Core32_Int32::fromInt($g4 ^ $x4);
73
-        $g[5] = ParagonIE_Sodium_Core32_Int32::fromInt($g5 ^ $x5);
74
-        $g[6] = ParagonIE_Sodium_Core32_Int32::fromInt($g6 ^ $x6);
75
-        $g[7] = ParagonIE_Sodium_Core32_Int32::fromInt($g7 ^ $x7);
76
-        $g[8] = ParagonIE_Sodium_Core32_Int32::fromInt($g8 ^ $x8);
77
-        $g[9] = ParagonIE_Sodium_Core32_Int32::fromInt($g9 ^ $x9);
48
+        $x0 = ( $f0 ^ $g0 ) & $b;
49
+        $x1 = ( $f1 ^ $g1 ) & $b;
50
+        $x2 = ( $f2 ^ $g2 ) & $b;
51
+        $x3 = ( $f3 ^ $g3 ) & $b;
52
+        $x4 = ( $f4 ^ $g4 ) & $b;
53
+        $x5 = ( $f5 ^ $g5 ) & $b;
54
+        $x6 = ( $f6 ^ $g6 ) & $b;
55
+        $x7 = ( $f7 ^ $g7 ) & $b;
56
+        $x8 = ( $f8 ^ $g8 ) & $b;
57
+        $x9 = ( $f9 ^ $g9 ) & $b;
58
+        $f[0] = ParagonIE_Sodium_Core32_Int32::fromInt( $f0 ^ $x0 );
59
+        $f[1] = ParagonIE_Sodium_Core32_Int32::fromInt( $f1 ^ $x1 );
60
+        $f[2] = ParagonIE_Sodium_Core32_Int32::fromInt( $f2 ^ $x2 );
61
+        $f[3] = ParagonIE_Sodium_Core32_Int32::fromInt( $f3 ^ $x3 );
62
+        $f[4] = ParagonIE_Sodium_Core32_Int32::fromInt( $f4 ^ $x4 );
63
+        $f[5] = ParagonIE_Sodium_Core32_Int32::fromInt( $f5 ^ $x5 );
64
+        $f[6] = ParagonIE_Sodium_Core32_Int32::fromInt( $f6 ^ $x6 );
65
+        $f[7] = ParagonIE_Sodium_Core32_Int32::fromInt( $f7 ^ $x7 );
66
+        $f[8] = ParagonIE_Sodium_Core32_Int32::fromInt( $f8 ^ $x8 );
67
+        $f[9] = ParagonIE_Sodium_Core32_Int32::fromInt( $f9 ^ $x9 );
68
+        $g[0] = ParagonIE_Sodium_Core32_Int32::fromInt( $g0 ^ $x0 );
69
+        $g[1] = ParagonIE_Sodium_Core32_Int32::fromInt( $g1 ^ $x1 );
70
+        $g[2] = ParagonIE_Sodium_Core32_Int32::fromInt( $g2 ^ $x2 );
71
+        $g[3] = ParagonIE_Sodium_Core32_Int32::fromInt( $g3 ^ $x3 );
72
+        $g[4] = ParagonIE_Sodium_Core32_Int32::fromInt( $g4 ^ $x4 );
73
+        $g[5] = ParagonIE_Sodium_Core32_Int32::fromInt( $g5 ^ $x5 );
74
+        $g[6] = ParagonIE_Sodium_Core32_Int32::fromInt( $g6 ^ $x6 );
75
+        $g[7] = ParagonIE_Sodium_Core32_Int32::fromInt( $g7 ^ $x7 );
76
+        $g[8] = ParagonIE_Sodium_Core32_Int32::fromInt( $g8 ^ $x8 );
77
+        $g[9] = ParagonIE_Sodium_Core32_Int32::fromInt( $g9 ^ $x9 );
78 78
     }
79 79
 
80 80
     /**
@@ -83,42 +83,42 @@  discard block
 block discarded – undo
83 83
      * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f
84 84
      * @return ParagonIE_Sodium_Core32_Curve25519_Fe
85 85
      */
86
-    public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f)
86
+    public static function fe_mul121666( ParagonIE_Sodium_Core32_Curve25519_Fe $f )
87 87
     {
88 88
         /** @var ParagonIE_Sodium_Core32_Int32[] $h */
89 89
         $h = array(
90
-            $f[0]->mulInt(121666),
91
-            $f[1]->mulInt(121666),
92
-            $f[2]->mulInt(121666),
93
-            $f[3]->mulInt(121666),
94
-            $f[4]->mulInt(121666),
95
-            $f[5]->mulInt(121666),
96
-            $f[6]->mulInt(121666),
97
-            $f[7]->mulInt(121666),
98
-            $f[8]->mulInt(121666),
99
-            $f[9]->mulInt(121666),
90
+            $f[0]->mulInt( 121666 ),
91
+            $f[1]->mulInt( 121666 ),
92
+            $f[2]->mulInt( 121666 ),
93
+            $f[3]->mulInt( 121666 ),
94
+            $f[4]->mulInt( 121666 ),
95
+            $f[5]->mulInt( 121666 ),
96
+            $f[6]->mulInt( 121666 ),
97
+            $f[7]->mulInt( 121666 ),
98
+            $f[8]->mulInt( 121666 ),
99
+            $f[9]->mulInt( 121666 ),
100 100
         );
101 101
 
102 102
         /** @var ParagonIE_Sodium_Core32_Int32 $carry9 */
103
-        $carry9 = $h[9]->addInt(1 << 24)->shiftRight(25);
104
-        $h[0] = $carry9->mulInt(19);
105
-        $h[9] = $h[9]->subInt32($carry9->shiftLeft(25));
103
+        $carry9 = $h[9]->addInt( 1 << 24 )->shiftRight( 25 );
104
+        $h[0] = $carry9->mulInt( 19 );
105
+        $h[9] = $h[9]->subInt32( $carry9->shiftLeft( 25 ) );
106 106
 
107
-        $carry1 = $h[1]->addInt(1 << 24)->shiftRight(25);
108
-        $h[2] = $h[2]->addInt32($carry1);
109
-        $h[1] = $h[1]->subInt32($carry1->shiftLeft(25));
107
+        $carry1 = $h[1]->addInt( 1 << 24 )->shiftRight( 25 );
108
+        $h[2] = $h[2]->addInt32( $carry1 );
109
+        $h[1] = $h[1]->subInt32( $carry1->shiftLeft( 25 ) );
110 110
 
111
-        $carry3 = $h[3]->addInt(1 << 24)->shiftRight(25);
112
-        $h[4] = $h[4]->addInt32($carry3);
113
-        $h[3] = $h[3]->subInt32($carry3->shiftLeft(25));
111
+        $carry3 = $h[3]->addInt( 1 << 24 )->shiftRight( 25 );
112
+        $h[4] = $h[4]->addInt32( $carry3 );
113
+        $h[3] = $h[3]->subInt32( $carry3->shiftLeft( 25 ) );
114 114
 
115
-        $carry5 = $h[3]->addInt(1 << 24)->shiftRight(25);
116
-        $h[6] = $h[6]->addInt32($carry5);
117
-        $h[5] = $h[5]->subInt32($carry5->shiftLeft(25));
115
+        $carry5 = $h[3]->addInt( 1 << 24 )->shiftRight( 25 );
116
+        $h[6] = $h[6]->addInt32( $carry5 );
117
+        $h[5] = $h[5]->subInt32( $carry5->shiftLeft( 25 ) );
118 118
 
119
-        $carry7 = $h[3]->addInt(1 << 24)->shiftRight(25);
120
-        $h[8] = $h[8]->addInt32($carry7);
121
-        $h[7] = $h[7]->subInt32($carry7->shiftLeft(25));
119
+        $carry7 = $h[3]->addInt( 1 << 24 )->shiftRight( 25 );
120
+        $h[8] = $h[8]->addInt32( $carry7 );
121
+        $h[7] = $h[7]->subInt32( $carry7->shiftLeft( 25 ) );
122 122
 
123 123
         /*
124 124
         $carry9 = ($h[9] + (1 << 24)) >> 25;
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
         $h[7] -= $carry7 << 25;
139 139
         */
140 140
 
141
-        $carry0 = $h[0]->addInt(1 << 25)->shiftRight(26);
142
-        $h[1] = $h[1]->addInt32($carry0);
143
-        $h[0] = $h[0]->subInt32($carry0->shiftLeft(26));
141
+        $carry0 = $h[0]->addInt( 1 << 25 )->shiftRight( 26 );
142
+        $h[1] = $h[1]->addInt32( $carry0 );
143
+        $h[0] = $h[0]->subInt32( $carry0->shiftLeft( 26 ) );
144 144
 
145
-        $carry2 = $h[2]->addInt(1 << 25)->shiftRight(26);
146
-        $h[3] = $h[3]->addInt32($carry2);
147
-        $h[2] = $h[2]->subInt32($carry2->shiftLeft(26));
145
+        $carry2 = $h[2]->addInt( 1 << 25 )->shiftRight( 26 );
146
+        $h[3] = $h[3]->addInt32( $carry2 );
147
+        $h[2] = $h[2]->subInt32( $carry2->shiftLeft( 26 ) );
148 148
 
149
-        $carry4 = $h[4]->addInt(1 << 25)->shiftRight(26);
150
-        $h[5] = $h[5]->addInt32($carry4);
151
-        $h[4] = $h[4]->subInt32($carry4->shiftLeft(26));
149
+        $carry4 = $h[4]->addInt( 1 << 25 )->shiftRight( 26 );
150
+        $h[5] = $h[5]->addInt32( $carry4 );
151
+        $h[4] = $h[4]->subInt32( $carry4->shiftLeft( 26 ) );
152 152
 
153
-        $carry6 = $h[6]->addInt(1 << 25)->shiftRight(26);
154
-        $h[7] = $h[7]->addInt32($carry6);
155
-        $h[6] = $h[6]->subInt32($carry6->shiftLeft(26));
153
+        $carry6 = $h[6]->addInt( 1 << 25 )->shiftRight( 26 );
154
+        $h[7] = $h[7]->addInt32( $carry6 );
155
+        $h[6] = $h[6]->subInt32( $carry6->shiftLeft( 26 ) );
156 156
 
157
-        $carry8 = $h[8]->addInt(1 << 25)->shiftRight(26);
158
-        $h[9] = $h[9]->addInt32($carry8);
159
-        $h[8] = $h[8]->subInt32($carry8->shiftLeft(26));
157
+        $carry8 = $h[8]->addInt( 1 << 25 )->shiftRight( 26 );
158
+        $h[9] = $h[9]->addInt32( $carry8 );
159
+        $h[8] = $h[8]->subInt32( $carry8->shiftLeft( 26 ) );
160 160
 
161 161
         /*
162 162
         $carry0 = ($h[0] + (1 << 25)) >> 26;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         $h[8] -= $carry8 << 26;
177 177
         */
178 178
 
179
-        return ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray($h);
179
+        return ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray( $h );
180 180
     }
181 181
 
182 182
     /**
@@ -188,27 +188,27 @@  discard block
 block discarded – undo
188 188
      * @param string $p
189 189
      * @return string
190 190
      */
191
-    public static function crypto_scalarmult_curve25519_ref10($n, $p)
191
+    public static function crypto_scalarmult_curve25519_ref10( $n, $p )
192 192
     {
193 193
         # for (i = 0;i < 32;++i) e[i] = n[i];
194 194
         $e = '' . $n;
195 195
         # e[0] &= 248;
196 196
         $e[0] = self::intToChr(
197
-            self::chrToInt($e[0]) & 248
197
+            self::chrToInt( $e[0] ) & 248
198 198
         );
199 199
         # e[31] &= 127;
200 200
         # e[31] |= 64;
201 201
         $e[31] = self::intToChr(
202
-            (self::chrToInt($e[31]) & 127) | 64
202
+            ( self::chrToInt( $e[31] ) & 127 ) | 64
203 203
         );
204 204
         # fe_frombytes(x1,p);
205
-        $x1 = self::fe_frombytes($p);
205
+        $x1 = self::fe_frombytes( $p );
206 206
         # fe_1(x2);
207 207
         $x2 = self::fe_1();
208 208
         # fe_0(z2);
209 209
         $z2 = self::fe_0();
210 210
         # fe_copy(x3,x1);
211
-        $x3 = self::fe_copy($x1);
211
+        $x3 = self::fe_copy( $x1 );
212 212
         # fe_1(z3);
213 213
         $z3 = self::fe_1();
214 214
 
@@ -216,88 +216,88 @@  discard block
 block discarded – undo
216 216
         $swap = 0;
217 217
 
218 218
         # for (pos = 254;pos >= 0;--pos) {
219
-        for ($pos = 254; $pos >= 0; --$pos) {
219
+        for ( $pos = 254; $pos >= 0; --$pos ) {
220 220
             # b = e[pos / 8] >> (pos & 7);
221 221
             $b = self::chrToInt(
222
-                    $e[(int) floor($pos / 8)]
223
-                ) >> ($pos & 7);
222
+                    $e[(int) floor( $pos / 8 )]
223
+                ) >> ( $pos & 7 );
224 224
             # b &= 1;
225 225
             $b &= 1;
226 226
             # swap ^= b;
227 227
             $swap ^= $b;
228 228
             # fe_cswap(x2,x3,swap);
229
-            self::fe_cswap($x2, $x3, $swap);
229
+            self::fe_cswap( $x2, $x3, $swap );
230 230
             # fe_cswap(z2,z3,swap);
231
-            self::fe_cswap($z2, $z3, $swap);
231
+            self::fe_cswap( $z2, $z3, $swap );
232 232
             # swap = b;
233 233
             $swap = $b;
234 234
             # fe_sub(tmp0,x3,z3);
235
-            $tmp0 = self::fe_sub($x3, $z3);
235
+            $tmp0 = self::fe_sub( $x3, $z3 );
236 236
             # fe_sub(tmp1,x2,z2);
237
-            $tmp1 = self::fe_sub($x2, $z2);
237
+            $tmp1 = self::fe_sub( $x2, $z2 );
238 238
 
239 239
             # fe_add(x2,x2,z2);
240
-            $x2 = self::fe_add($x2, $z2);
240
+            $x2 = self::fe_add( $x2, $z2 );
241 241
 
242 242
             # fe_add(z2,x3,z3);
243
-            $z2 = self::fe_add($x3, $z3);
243
+            $z2 = self::fe_add( $x3, $z3 );
244 244
 
245 245
             # fe_mul(z3,tmp0,x2);
246
-            $z3 = self::fe_mul($tmp0, $x2);
246
+            $z3 = self::fe_mul( $tmp0, $x2 );
247 247
 
248 248
             # fe_mul(z2,z2,tmp1);
249
-            $z2 = self::fe_mul($z2, $tmp1);
249
+            $z2 = self::fe_mul( $z2, $tmp1 );
250 250
 
251 251
             # fe_sq(tmp0,tmp1);
252
-            $tmp0 = self::fe_sq($tmp1);
252
+            $tmp0 = self::fe_sq( $tmp1 );
253 253
 
254 254
             # fe_sq(tmp1,x2);
255
-            $tmp1 = self::fe_sq($x2);
255
+            $tmp1 = self::fe_sq( $x2 );
256 256
 
257 257
             # fe_add(x3,z3,z2);
258
-            $x3 = self::fe_add($z3, $z2);
258
+            $x3 = self::fe_add( $z3, $z2 );
259 259
 
260 260
             # fe_sub(z2,z3,z2);
261
-            $z2 = self::fe_sub($z3, $z2);
261
+            $z2 = self::fe_sub( $z3, $z2 );
262 262
 
263 263
             # fe_mul(x2,tmp1,tmp0);
264
-            $x2 = self::fe_mul($tmp1, $tmp0);
264
+            $x2 = self::fe_mul( $tmp1, $tmp0 );
265 265
 
266 266
             # fe_sub(tmp1,tmp1,tmp0);
267
-            $tmp1 = self::fe_sub($tmp1, $tmp0);
267
+            $tmp1 = self::fe_sub( $tmp1, $tmp0 );
268 268
 
269 269
             # fe_sq(z2,z2);
270
-            $z2 = self::fe_sq($z2);
270
+            $z2 = self::fe_sq( $z2 );
271 271
 
272 272
             # fe_mul121666(z3,tmp1);
273
-            $z3 = self::fe_mul121666($tmp1);
273
+            $z3 = self::fe_mul121666( $tmp1 );
274 274
 
275 275
             # fe_sq(x3,x3);
276
-            $x3 = self::fe_sq($x3);
276
+            $x3 = self::fe_sq( $x3 );
277 277
 
278 278
             # fe_add(tmp0,tmp0,z3);
279
-            $tmp0 = self::fe_add($tmp0, $z3);
279
+            $tmp0 = self::fe_add( $tmp0, $z3 );
280 280
 
281 281
             # fe_mul(z3,x1,z2);
282
-            $z3 = self::fe_mul($x1, $z2);
282
+            $z3 = self::fe_mul( $x1, $z2 );
283 283
 
284 284
             # fe_mul(z2,tmp1,tmp0);
285
-            $z2 = self::fe_mul($tmp1, $tmp0);
285
+            $z2 = self::fe_mul( $tmp1, $tmp0 );
286 286
         }
287 287
 
288 288
         # fe_cswap(x2,x3,swap);
289
-        self::fe_cswap($x2, $x3, $swap);
289
+        self::fe_cswap( $x2, $x3, $swap );
290 290
 
291 291
         # fe_cswap(z2,z3,swap);
292
-        self::fe_cswap($z2, $z3, $swap);
292
+        self::fe_cswap( $z2, $z3, $swap );
293 293
 
294 294
         # fe_invert(z2,z2);
295
-        $z2 = self::fe_invert($z2);
295
+        $z2 = self::fe_invert( $z2 );
296 296
 
297 297
         # fe_mul(x2,x2,z2);
298
-        $x2 = self::fe_mul($x2, $z2);
298
+        $x2 = self::fe_mul( $x2, $z2 );
299 299
         # fe_tobytes(q,x2);
300
-        return self::fe_tobytes($x2);
300
+        return self::fe_tobytes( $x2 );
301 301
     }
302 302
 
303 303
     /**
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
         ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsY,
312 312
         ParagonIE_Sodium_Core32_Curve25519_Fe $edwardsZ
313 313
     ) {
314
-        $tempX = self::fe_add($edwardsZ, $edwardsY);
315
-        $tempZ = self::fe_sub($edwardsZ, $edwardsY);
316
-        $tempZ = self::fe_invert($tempZ);
317
-        return self::fe_mul($tempX, $tempZ);
314
+        $tempX = self::fe_add( $edwardsZ, $edwardsY );
315
+        $tempZ = self::fe_sub( $edwardsZ, $edwardsY );
316
+        $tempZ = self::fe_invert( $tempZ );
317
+        return self::fe_mul( $tempX, $tempZ );
318 318
     }
319 319
 
320 320
     /**
@@ -324,31 +324,31 @@  discard block
 block discarded – undo
324 324
      * @return string
325 325
      * @throws TypeError
326 326
      */
327
-    public static function crypto_scalarmult_curve25519_ref10_base($n)
327
+    public static function crypto_scalarmult_curve25519_ref10_base( $n )
328 328
     {
329 329
         # for (i = 0;i < 32;++i) e[i] = n[i];
330 330
         $e = '' . $n;
331 331
 
332 332
         # e[0] &= 248;
333 333
         $e[0] = self::intToChr(
334
-            self::chrToInt($e[0]) & 248
334
+            self::chrToInt( $e[0] ) & 248
335 335
         );
336 336
 
337 337
         # e[31] &= 127;
338 338
         # e[31] |= 64;
339 339
         $e[31] = self::intToChr(
340
-            (self::chrToInt($e[31]) & 127) | 64
340
+            ( self::chrToInt( $e[31] ) & 127 ) | 64
341 341
         );
342 342
 
343
-        $A = self::ge_scalarmult_base($e);
343
+        $A = self::ge_scalarmult_base( $e );
344 344
         if (
345
-            !($A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
345
+            ! ( $A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe )
346 346
             ||
347
-            !($A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
347
+            ! ( $A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe )
348 348
         ) {
349
-            throw new TypeError('Null points encountered');
349
+            throw new TypeError( 'Null points encountered' );
350 350
         }
351
-        $pk = self::edwards_to_montgomery($A->Y, $A->Z);
352
-        return self::fe_tobytes($pk);
351
+        $pk = self::edwards_to_montgomery( $A->Y, $A->Z );
352
+        return self::fe_tobytes( $pk );
353 353
     }
354 354
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_X25519
9 9
  */
10
-abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Curve25519
11
-{
10
+abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Curve25519 {
12 11
     /**
13 12
      * Alters the objects passed to this method in place.
14 13
      *
@@ -83,8 +82,7 @@  discard block
 block discarded – undo
83 82
      * @param ParagonIE_Sodium_Core32_Curve25519_Fe $f
84 83
      * @return ParagonIE_Sodium_Core32_Curve25519_Fe
85 84
      */
86
-    public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f)
87
-    {
85
+    public static function fe_mul121666(ParagonIE_Sodium_Core32_Curve25519_Fe $f) {
88 86
         /** @var ParagonIE_Sodium_Core32_Int32[] $h */
89 87
         $h = array(
90 88
             $f[0]->mulInt(121666),
@@ -188,8 +186,7 @@  discard block
 block discarded – undo
188 186
      * @param string $p
189 187
      * @return string
190 188
      */
191
-    public static function crypto_scalarmult_curve25519_ref10($n, $p)
192
-    {
189
+    public static function crypto_scalarmult_curve25519_ref10($n, $p) {
193 190
         # for (i = 0;i < 32;++i) e[i] = n[i];
194 191
         $e = '' . $n;
195 192
         # e[0] &= 248;
@@ -324,8 +321,7 @@  discard block
 block discarded – undo
324 321
      * @return string
325 322
      * @throws TypeError
326 323
      */
327
-    public static function crypto_scalarmult_curve25519_ref10_base($n)
328
-    {
324
+    public static function crypto_scalarmult_curve25519_ref10_base($n) {
329 325
         # for (i = 0;i < 32;++i) e[i] = n[i];
330 326
         $e = '' . $n;
331 327
 
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/ChaCha20/IetfCtx.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core_ChaCha20_IetfCtx', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,29 +9,29 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class ParagonIE_Sodium_Core32_ChaCha20_IetfCtx extends ParagonIE_Sodium_Core32_ChaCha20_Ctx
11 11
 {
12
-    /**
13
-     * ParagonIE_Sodium_Core_ChaCha20_IetfCtx constructor.
14
-     *
15
-     * @internal You should not use this directly from another application
16
-     *
17
-     * @param string $key     ChaCha20 key.
18
-     * @param string $iv      Initialization Vector (a.k.a. nonce).
19
-     * @param string $counter The initial counter value.
20
-     *                        Defaults to 4 0x00 bytes.
21
-     * @throws InvalidArgumentException
22
-     */
23
-    public function __construct($key = '', $iv = '', $counter = '')
24
-    {
25
-        if (self::strlen($iv) !== 12) {
26
-            throw new InvalidArgumentException('ChaCha20 expects a 96-bit nonce in IETF mode.');
27
-        }
28
-        parent::__construct($key, self::substr($iv, 0, 8), $counter);
12
+	/**
13
+	 * ParagonIE_Sodium_Core_ChaCha20_IetfCtx constructor.
14
+	 *
15
+	 * @internal You should not use this directly from another application
16
+	 *
17
+	 * @param string $key     ChaCha20 key.
18
+	 * @param string $iv      Initialization Vector (a.k.a. nonce).
19
+	 * @param string $counter The initial counter value.
20
+	 *                        Defaults to 4 0x00 bytes.
21
+	 * @throws InvalidArgumentException
22
+	 */
23
+	public function __construct($key = '', $iv = '', $counter = '')
24
+	{
25
+		if (self::strlen($iv) !== 12) {
26
+			throw new InvalidArgumentException('ChaCha20 expects a 96-bit nonce in IETF mode.');
27
+		}
28
+		parent::__construct($key, self::substr($iv, 0, 8), $counter);
29 29
 
30
-        if (!empty($counter)) {
31
-            $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($counter, 0, 4));
32
-        }
33
-        $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 0, 4));
34
-        $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 4, 4));
35
-        $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 4, 4));
36
-    }
30
+		if (!empty($counter)) {
31
+			$this->container[12] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($counter, 0, 4));
32
+		}
33
+		$this->container[13] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 0, 4));
34
+		$this->container[14] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 4, 4));
35
+		$this->container[15] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 4, 4));
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core_ChaCha20_IetfCtx', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core_ChaCha20_IetfCtx', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
      *                        Defaults to 4 0x00 bytes.
21 21
      * @throws InvalidArgumentException
22 22
      */
23
-    public function __construct($key = '', $iv = '', $counter = '')
23
+    public function __construct( $key = '', $iv = '', $counter = '' )
24 24
     {
25
-        if (self::strlen($iv) !== 12) {
26
-            throw new InvalidArgumentException('ChaCha20 expects a 96-bit nonce in IETF mode.');
25
+        if ( self::strlen( $iv ) !== 12 ) {
26
+            throw new InvalidArgumentException( 'ChaCha20 expects a 96-bit nonce in IETF mode.' );
27 27
         }
28
-        parent::__construct($key, self::substr($iv, 0, 8), $counter);
28
+        parent::__construct( $key, self::substr( $iv, 0, 8 ), $counter );
29 29
 
30
-        if (!empty($counter)) {
31
-            $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($counter, 0, 4));
30
+        if ( ! empty( $counter ) ) {
31
+            $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromString( self::substr( $counter, 0, 4 ) );
32 32
         }
33
-        $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 0, 4));
34
-        $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 4, 4));
35
-        $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromString(self::substr($iv, 4, 4));
33
+        $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromString( self::substr( $iv, 0, 4 ) );
34
+        $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromString( self::substr( $iv, 4, 4 ) );
35
+        $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromString( self::substr( $iv, 4, 4 ) );
36 36
     }
37 37
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_ChaCha20_IetfCtx
9 9
  */
10
-class ParagonIE_Sodium_Core32_ChaCha20_IetfCtx extends ParagonIE_Sodium_Core32_ChaCha20_Ctx
11
-{
10
+class ParagonIE_Sodium_Core32_ChaCha20_IetfCtx extends ParagonIE_Sodium_Core32_ChaCha20_Ctx {
12 11
     /**
13 12
      * ParagonIE_Sodium_Core_ChaCha20_IetfCtx constructor.
14 13
      *
@@ -20,8 +19,7 @@  discard block
 block discarded – undo
20 19
      *                        Defaults to 4 0x00 bytes.
21 20
      * @throws InvalidArgumentException
22 21
      */
23
-    public function __construct($key = '', $iv = '', $counter = '')
24
-    {
22
+    public function __construct($key = '', $iv = '', $counter = '') {
25 23
         if (self::strlen($iv) !== 12) {
26 24
             throw new InvalidArgumentException('ChaCha20 expects a 96-bit nonce in IETF mode.');
27 25
         }
Please login to merge, or discard this patch.
src/library/sodium_compat/src/Core32/ChaCha20/Ctx.php 3 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -9,113 +9,113 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class ParagonIE_Sodium_Core32_ChaCha20_Ctx extends ParagonIE_Sodium_Core32_Util implements ArrayAccess
11 11
 {
12
-    /**
13
-     * @var SplFixedArray<int, ParagonIE_Sodium_Core32_Int32>
14
-     */
15
-    protected $container;
12
+	/**
13
+	 * @var SplFixedArray<int, ParagonIE_Sodium_Core32_Int32>
14
+	 */
15
+	protected $container;
16 16
 
17
-    /**
18
-     * ParagonIE_Sodium_Core_ChaCha20_Ctx constructor.
19
-     *
20
-     * @internal You should not use this directly from another application
21
-     *
22
-     * @param string $key     ChaCha20 key.
23
-     * @param string $iv      Initialization Vector (a.k.a. nonce).
24
-     * @param string $counter The initial counter value.
25
-     *                        Defaults to 8 0x00 bytes.
26
-     * @throws InvalidArgumentException
27
-     */
28
-    public function __construct($key = '', $iv = '', $counter = '')
29
-    {
30
-        if (self::strlen($key) !== 32) {
31
-            throw new InvalidArgumentException('ChaCha20 expects a 256-bit key.');
32
-        }
33
-        if (self::strlen($iv) !== 8) {
34
-            throw new InvalidArgumentException('ChaCha20 expects a 64-bit nonce.');
35
-        }
36
-        $this->container = new SplFixedArray(16);
17
+	/**
18
+	 * ParagonIE_Sodium_Core_ChaCha20_Ctx constructor.
19
+	 *
20
+	 * @internal You should not use this directly from another application
21
+	 *
22
+	 * @param string $key     ChaCha20 key.
23
+	 * @param string $iv      Initialization Vector (a.k.a. nonce).
24
+	 * @param string $counter The initial counter value.
25
+	 *                        Defaults to 8 0x00 bytes.
26
+	 * @throws InvalidArgumentException
27
+	 */
28
+	public function __construct($key = '', $iv = '', $counter = '')
29
+	{
30
+		if (self::strlen($key) !== 32) {
31
+			throw new InvalidArgumentException('ChaCha20 expects a 256-bit key.');
32
+		}
33
+		if (self::strlen($iv) !== 8) {
34
+			throw new InvalidArgumentException('ChaCha20 expects a 64-bit nonce.');
35
+		}
36
+		$this->container = new SplFixedArray(16);
37 37
 
38
-        /* "expand 32-byte k" as per ChaCha20 spec */
39
-        $this->container[0]  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
40
-        $this->container[1]  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
41
-        $this->container[2]  = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
42
-        $this->container[3]  = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
38
+		/* "expand 32-byte k" as per ChaCha20 spec */
39
+		$this->container[0]  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
40
+		$this->container[1]  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
41
+		$this->container[2]  = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
42
+		$this->container[3]  = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
43 43
 
44
-        $this->container[4]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 0, 4));
45
-        $this->container[5]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 4, 4));
46
-        $this->container[6]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 8, 4));
47
-        $this->container[7]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 12, 4));
48
-        $this->container[8]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 16, 4));
49
-        $this->container[9]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 20, 4));
50
-        $this->container[10] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 24, 4));
51
-        $this->container[11] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 28, 4));
44
+		$this->container[4]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 0, 4));
45
+		$this->container[5]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 4, 4));
46
+		$this->container[6]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 8, 4));
47
+		$this->container[7]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 12, 4));
48
+		$this->container[8]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 16, 4));
49
+		$this->container[9]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 20, 4));
50
+		$this->container[10] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 24, 4));
51
+		$this->container[11] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 28, 4));
52 52
 
53
-        if (empty($counter)) {
54
-            $this->container[12] = new ParagonIE_Sodium_Core32_Int32();
55
-            $this->container[13] = new ParagonIE_Sodium_Core32_Int32();
56
-        } else {
57
-            $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 0, 4));
58
-            $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 4, 4));
59
-        }
60
-        $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 0, 4));
61
-        $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 4, 4));
62
-    }
53
+		if (empty($counter)) {
54
+			$this->container[12] = new ParagonIE_Sodium_Core32_Int32();
55
+			$this->container[13] = new ParagonIE_Sodium_Core32_Int32();
56
+		} else {
57
+			$this->container[12] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 0, 4));
58
+			$this->container[13] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 4, 4));
59
+		}
60
+		$this->container[14] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 0, 4));
61
+		$this->container[15] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 4, 4));
62
+	}
63 63
 
64
-    /**
65
-     * @internal You should not use this directly from another application
66
-     *
67
-     * @param int $offset
68
-     * @param int|ParagonIE_Sodium_Core32_Int32 $value
69
-     * @return void
70
-     */
71
-    public function offsetSet($offset, $value)
72
-    {
73
-        if (!is_int($offset)) {
74
-            throw new InvalidArgumentException('Expected an integer');
75
-        }
76
-        if ($value instanceof ParagonIE_Sodium_Core32_Int32) {
77
-            /*
64
+	/**
65
+	 * @internal You should not use this directly from another application
66
+	 *
67
+	 * @param int $offset
68
+	 * @param int|ParagonIE_Sodium_Core32_Int32 $value
69
+	 * @return void
70
+	 */
71
+	public function offsetSet($offset, $value)
72
+	{
73
+		if (!is_int($offset)) {
74
+			throw new InvalidArgumentException('Expected an integer');
75
+		}
76
+		if ($value instanceof ParagonIE_Sodium_Core32_Int32) {
77
+			/*
78 78
         } elseif (is_int($value)) {
79 79
             $value = ParagonIE_Sodium_Core32_Int32::fromInt($value);
80 80
             */
81
-        } else {
82
-            throw new InvalidArgumentException('Expected an integer');
83
-        }
84
-        $this->container[$offset] = $value;
85
-    }
81
+		} else {
82
+			throw new InvalidArgumentException('Expected an integer');
83
+		}
84
+		$this->container[$offset] = $value;
85
+	}
86 86
 
87
-    /**
88
-     * @internal You should not use this directly from another application
89
-     *
90
-     * @param mixed $offset
91
-     * @return bool
92
-     */
93
-    public function offsetExists($offset)
94
-    {
95
-        return isset($this->container[$offset]);
96
-    }
87
+	/**
88
+	 * @internal You should not use this directly from another application
89
+	 *
90
+	 * @param mixed $offset
91
+	 * @return bool
92
+	 */
93
+	public function offsetExists($offset)
94
+	{
95
+		return isset($this->container[$offset]);
96
+	}
97 97
 
98
-    /**
99
-     * @internal You should not use this directly from another application
100
-     *
101
-     * @param mixed $offset
102
-     * @return void
103
-     */
104
-    public function offsetUnset($offset)
105
-    {
106
-        unset($this->container[$offset]);
107
-    }
98
+	/**
99
+	 * @internal You should not use this directly from another application
100
+	 *
101
+	 * @param mixed $offset
102
+	 * @return void
103
+	 */
104
+	public function offsetUnset($offset)
105
+	{
106
+		unset($this->container[$offset]);
107
+	}
108 108
 
109
-    /**
110
-     * @internal You should not use this directly from another application
111
-     *
112
-     * @param mixed $offset
113
-     * @return mixed|null
114
-     */
115
-    public function offsetGet($offset)
116
-    {
117
-        return isset($this->container[$offset])
118
-            ? $this->container[$offset]
119
-            : null;
120
-    }
109
+	/**
110
+	 * @internal You should not use this directly from another application
111
+	 *
112
+	 * @param mixed $offset
113
+	 * @return mixed|null
114
+	 */
115
+	public function offsetGet($offset)
116
+	{
117
+		return isset($this->container[$offset])
118
+			? $this->container[$offset]
119
+			: null;
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) {
3
+if ( class_exists( 'ParagonIE_Sodium_Core_ChaCha20_Ctx', false ) ) {
4 4
     return;
5 5
 }
6 6
 
@@ -25,40 +25,40 @@  discard block
 block discarded – undo
25 25
      *                        Defaults to 8 0x00 bytes.
26 26
      * @throws InvalidArgumentException
27 27
      */
28
-    public function __construct($key = '', $iv = '', $counter = '')
28
+    public function __construct( $key = '', $iv = '', $counter = '' )
29 29
     {
30
-        if (self::strlen($key) !== 32) {
31
-            throw new InvalidArgumentException('ChaCha20 expects a 256-bit key.');
30
+        if ( self::strlen( $key ) !== 32 ) {
31
+            throw new InvalidArgumentException( 'ChaCha20 expects a 256-bit key.' );
32 32
         }
33
-        if (self::strlen($iv) !== 8) {
34
-            throw new InvalidArgumentException('ChaCha20 expects a 64-bit nonce.');
33
+        if ( self::strlen( $iv ) !== 8 ) {
34
+            throw new InvalidArgumentException( 'ChaCha20 expects a 64-bit nonce.' );
35 35
         }
36
-        $this->container = new SplFixedArray(16);
36
+        $this->container = new SplFixedArray( 16 );
37 37
 
38 38
         /* "expand 32-byte k" as per ChaCha20 spec */
39
-        $this->container[0]  = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865));
40
-        $this->container[1]  = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e));
41
-        $this->container[2]  = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32));
42
-        $this->container[3]  = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574));
39
+        $this->container[0]  = new ParagonIE_Sodium_Core32_Int32( array( 0x6170, 0x7865 ) );
40
+        $this->container[1]  = new ParagonIE_Sodium_Core32_Int32( array( 0x3320, 0x646e ) );
41
+        $this->container[2]  = new ParagonIE_Sodium_Core32_Int32( array( 0x7962, 0x2d32 ) );
42
+        $this->container[3]  = new ParagonIE_Sodium_Core32_Int32( array( 0x6b20, 0x6574 ) );
43 43
 
44
-        $this->container[4]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 0, 4));
45
-        $this->container[5]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 4, 4));
46
-        $this->container[6]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 8, 4));
47
-        $this->container[7]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 12, 4));
48
-        $this->container[8]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 16, 4));
49
-        $this->container[9]  = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 20, 4));
50
-        $this->container[10] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 24, 4));
51
-        $this->container[11] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 28, 4));
44
+        $this->container[4]  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 0, 4 ) );
45
+        $this->container[5]  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 4, 4 ) );
46
+        $this->container[6]  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 8, 4 ) );
47
+        $this->container[7]  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 12, 4 ) );
48
+        $this->container[8]  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 16, 4 ) );
49
+        $this->container[9]  = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 20, 4 ) );
50
+        $this->container[10] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 24, 4 ) );
51
+        $this->container[11] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 28, 4 ) );
52 52
 
53
-        if (empty($counter)) {
53
+        if ( empty( $counter ) ) {
54 54
             $this->container[12] = new ParagonIE_Sodium_Core32_Int32();
55 55
             $this->container[13] = new ParagonIE_Sodium_Core32_Int32();
56 56
         } else {
57
-            $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 0, 4));
58
-            $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 4, 4));
57
+            $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $counter, 0, 4 ) );
58
+            $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $counter, 4, 4 ) );
59 59
         }
60
-        $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 0, 4));
61
-        $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 4, 4));
60
+        $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $iv, 0, 4 ) );
61
+        $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $iv, 4, 4 ) );
62 62
     }
63 63
 
64 64
     /**
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
      * @param int|ParagonIE_Sodium_Core32_Int32 $value
69 69
      * @return void
70 70
      */
71
-    public function offsetSet($offset, $value)
71
+    public function offsetSet( $offset, $value )
72 72
     {
73
-        if (!is_int($offset)) {
74
-            throw new InvalidArgumentException('Expected an integer');
73
+        if ( ! is_int( $offset ) ) {
74
+            throw new InvalidArgumentException( 'Expected an integer' );
75 75
         }
76
-        if ($value instanceof ParagonIE_Sodium_Core32_Int32) {
76
+        if ( $value instanceof ParagonIE_Sodium_Core32_Int32 ) {
77 77
             /*
78 78
         } elseif (is_int($value)) {
79 79
             $value = ParagonIE_Sodium_Core32_Int32::fromInt($value);
80 80
             */
81 81
         } else {
82
-            throw new InvalidArgumentException('Expected an integer');
82
+            throw new InvalidArgumentException( 'Expected an integer' );
83 83
         }
84 84
         $this->container[$offset] = $value;
85 85
     }
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      * @param mixed $offset
91 91
      * @return bool
92 92
      */
93
-    public function offsetExists($offset)
93
+    public function offsetExists( $offset )
94 94
     {
95
-        return isset($this->container[$offset]);
95
+        return isset( $this->container[$offset] );
96 96
     }
97 97
 
98 98
     /**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      * @param mixed $offset
102 102
      * @return void
103 103
      */
104
-    public function offsetUnset($offset)
104
+    public function offsetUnset( $offset )
105 105
     {
106
-        unset($this->container[$offset]);
106
+        unset( $this->container[$offset] );
107 107
     }
108 108
 
109 109
     /**
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
      * @param mixed $offset
113 113
      * @return mixed|null
114 114
      */
115
-    public function offsetGet($offset)
115
+    public function offsetGet( $offset )
116 116
     {
117
-        return isset($this->container[$offset])
117
+        return isset( $this->container[$offset] )
118 118
             ? $this->container[$offset]
119 119
             : null;
120 120
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 /**
8 8
  * Class ParagonIE_Sodium_Core32_ChaCha20_Ctx
9 9
  */
10
-class ParagonIE_Sodium_Core32_ChaCha20_Ctx extends ParagonIE_Sodium_Core32_Util implements ArrayAccess
11
-{
10
+class ParagonIE_Sodium_Core32_ChaCha20_Ctx extends ParagonIE_Sodium_Core32_Util implements ArrayAccess {
12 11
     /**
13 12
      * @var SplFixedArray<int, ParagonIE_Sodium_Core32_Int32>
14 13
      */
@@ -25,8 +24,7 @@  discard block
 block discarded – undo
25 24
      *                        Defaults to 8 0x00 bytes.
26 25
      * @throws InvalidArgumentException
27 26
      */
28
-    public function __construct($key = '', $iv = '', $counter = '')
29
-    {
27
+    public function __construct($key = '', $iv = '', $counter = '') {
30 28
         if (self::strlen($key) !== 32) {
31 29
             throw new InvalidArgumentException('ChaCha20 expects a 256-bit key.');
32 30
         }
@@ -68,8 +66,7 @@  discard block
 block discarded – undo
68 66
      * @param int|ParagonIE_Sodium_Core32_Int32 $value
69 67
      * @return void
70 68
      */
71
-    public function offsetSet($offset, $value)
72
-    {
69
+    public function offsetSet($offset, $value) {
73 70
         if (!is_int($offset)) {
74 71
             throw new InvalidArgumentException('Expected an integer');
75 72
         }
@@ -90,8 +87,7 @@  discard block
 block discarded – undo
90 87
      * @param mixed $offset
91 88
      * @return bool
92 89
      */
93
-    public function offsetExists($offset)
94
-    {
90
+    public function offsetExists($offset) {
95 91
         return isset($this->container[$offset]);
96 92
     }
97 93
 
@@ -101,8 +97,7 @@  discard block
 block discarded – undo
101 97
      * @param mixed $offset
102 98
      * @return void
103 99
      */
104
-    public function offsetUnset($offset)
105
-    {
100
+    public function offsetUnset($offset) {
106 101
         unset($this->container[$offset]);
107 102
     }
108 103
 
@@ -112,8 +107,7 @@  discard block
 block discarded – undo
112 107
      * @param mixed $offset
113 108
      * @return mixed|null
114 109
      */
115
-    public function offsetGet($offset)
116
-    {
110
+    public function offsetGet($offset) {
117 111
         return isset($this->container[$offset])
118 112
             ? $this->container[$offset]
119 113
             : null;
Please login to merge, or discard this patch.