Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
-
 
2
declare(strict_types=1);
2
namespace ParagonIE\ConstantTime;
3
namespace ParagonIE\ConstantTime;
Línea -... Línea 4...
-
 
4
 
-
 
5
use InvalidArgumentException;
-
 
6
use RangeException;
-
 
7
use TypeError;
3
 
8
 
4
/**
9
/**
5
 *  Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
10
 *  Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
6
 *  Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
11
 *  Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
7
 *
12
 *
8
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
13
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
9
 *  of this software and associated documentation files (the "Software"), to deal
14
 *  of this software and associated documentation files (the "Software"), to deal
Línea 33... Línea 38...
33
abstract class Base32 implements EncoderInterface
38
abstract class Base32 implements EncoderInterface
34
{
39
{
35
    /**
40
    /**
36
     * Decode a Base32-encoded string into raw binary
41
     * Decode a Base32-encoded string into raw binary
37
     *
42
     *
38
     * @param string $src
43
     * @param string $encodedString
39
     * @param bool $strictPadding
44
     * @param bool $strictPadding
40
     * @return string
45
     * @return string
41
     */
46
     */
42
    public static function decode($src, $strictPadding = \false)
47
    public static function decode(
-
 
48
        #[\SensitiveParameter]
-
 
49
        string $encodedString,
-
 
50
        bool $strictPadding = false
43
    {
51
    ): string {
44
        return static::doDecode($src, \false, $strictPadding);
52
        return static::doDecode($encodedString, false, $strictPadding);
45
    }
53
    }
Línea 46... Línea 54...
46
 
54
 
47
    /**
55
    /**
48
     * Decode an uppercase Base32-encoded string into raw binary
56
     * Decode an uppercase Base32-encoded string into raw binary
49
     *
57
     *
50
     * @param string $src
58
     * @param string $src
51
     * @param bool $strictPadding
59
     * @param bool $strictPadding
52
     * @return string
60
     * @return string
53
     */
61
     */
-
 
62
    public static function decodeUpper(
-
 
63
        #[\SensitiveParameter]
-
 
64
        string $src,
54
    public static function decodeUpper($src, $strictPadding = \false)
65
        bool $strictPadding = false
55
    {
66
    ): string {
56
        return static::doDecode($src, \true, $strictPadding);
67
        return static::doDecode($src, true, $strictPadding);
Línea 57... Línea 68...
57
    }
68
    }
58
 
69
 
59
    /**
70
    /**
60
     * Encode into Base32 (RFC 4648)
71
     * Encode into Base32 (RFC 4648)
61
     *
72
     *
-
 
73
     * @param string $binString
62
     * @param string $src
74
     * @return string
63
     * @return string
75
     * @throws TypeError
-
 
76
     */
-
 
77
    public static function encode(
64
     */
78
        #[\SensitiveParameter]
65
    public static function encode($src)
79
        string $binString
66
    {
80
    ): string {
Línea 67... Línea 81...
67
        return static::doEncode($src, \false);
81
        return static::doEncode($binString, false, true);
68
    }
82
    }
69
 
83
 
70
    /**
84
    /**
71
     * Encode into Base32 (RFC 4648)
85
     * Encode into Base32 (RFC 4648)
72
     *
86
     *
73
     * @param string $src
87
     * @param string $src
74
     * @return string
88
     * @return string
-
 
89
     * @throws TypeError
-
 
90
     */
75
     * @throws \TypeError
91
    public static function encodeUnpadded(
76
     */
92
        #[\SensitiveParameter]
77
    public static function encodeUnpadded($src)
93
        string $src
Línea 78... Línea 94...
78
    {
94
    ): string {
79
        return static::doEncode($src, false, false);
95
        return static::doEncode($src, false, false);
80
    }
96
    }
81
 
97
 
82
    /**
98
    /**
-
 
99
     * Encode into uppercase Base32 (RFC 4648)
83
     * Encode into uppercase Base32 (RFC 4648)
100
     *
84
     *
101
     * @param string $src
-
 
102
     * @return string
-
 
103
     * @throws TypeError
85
     * @param string $src
104
     */
86
     * @return string
105
    public static function encodeUpper(
87
     */
106
        #[\SensitiveParameter]
Línea 88... Línea 107...
88
    public static function encodeUpper($src)
107
        string $src
89
    {
108
    ): string {
90
        return static::doEncode($src, \true);
109
        return static::doEncode($src, true, true);
91
    }
110
    }
92
 
111
 
93
    /**
112
    /**
94
     * Encode into uppercase Base32 (RFC 4648)
113
     * Encode into uppercase Base32 (RFC 4648)
95
     *
114
     *
-
 
115
     * @param string $src
-
 
116
     * @return string
96
     * @param string $src
117
     * @throws TypeError
97
     * @return string
118
     */
98
     * @throws \TypeError
119
    public static function encodeUpperUnpadded(
Línea 99... Línea 120...
99
     */
120
        #[\SensitiveParameter]
100
    public static function encodeUpperUnpadded($src)
121
        string $src
101
    {
122
    ): string {
102
        return static::doEncode($src, true, false);
123
        return static::doEncode($src, true, false);
103
    }
124
    }
104
 
125
 
105
    /**
126
    /**
106
     * Uses bitwise operators instead of table-lookups to turn 5-bit integers
127
     * Uses bitwise operators instead of table-lookups to turn 5-bit integers
107
     * into 8-bit integers.
128
     * into 8-bit integers.
108
     *
129
     *
Línea 109... Línea 130...
109
     * @param int $src
130
     * @param int $src
110
     * @return int
131
     * @return int
Línea 129... Línea 150...
129
     * Uppercase variant.
150
     * Uppercase variant.
130
     *
151
     *
131
     * @param int $src
152
     * @param int $src
132
     * @return int
153
     * @return int
133
     */
154
     */
134
    protected static function decode5BitsUpper($src)
155
    protected static function decode5BitsUpper(int $src): int
135
    {
156
    {
136
        $ret = -1;
157
        $ret = -1;
Línea 137... Línea 158...
137
 
158
 
138
        // if ($src > 64 && $src < 91) $ret += $src - 65 + 1; // -64
159
        // if ($src > 64 && $src < 91) $ret += $src - 65 + 1; // -64
Línea 149... Línea 170...
149
     * into 5-bit integers.
170
     * into 5-bit integers.
150
     *
171
     *
151
     * @param int $src
172
     * @param int $src
152
     * @return string
173
     * @return string
153
     */
174
     */
154
    protected static function encode5Bits($src)
175
    protected static function encode5Bits(int $src): string
155
    {
176
    {
156
        $diff = 0x61;
177
        $diff = 0x61;
Línea 157... Línea 178...
157
 
178
 
158
        // if ($src > 25) $ret -= 72;
179
        // if ($src > 25) $ret -= 72;
Línea 168... Línea 189...
168
     * Uppercase variant.
189
     * Uppercase variant.
169
     *
190
     *
170
     * @param int $src
191
     * @param int $src
171
     * @return string
192
     * @return string
172
     */
193
     */
173
    protected static function encode5BitsUpper($src)
194
    protected static function encode5BitsUpper(int $src): string
174
    {
195
    {
175
        $diff = 0x41;
196
        $diff = 0x41;
Línea 176... Línea 197...
176
 
197
 
177
        // if ($src > 25) $ret -= 40;
198
        // if ($src > 25) $ret -= 40;
Línea 178... Línea 199...
178
        $diff -= ((25 - $src) >> 8) & 41;
199
        $diff -= ((25 - $src) >> 8) & 41;
179
 
200
 
Línea -... Línea 201...
-
 
201
        return \pack('C', $src + $diff);
-
 
202
    }
-
 
203
 
-
 
204
    /**
-
 
205
     * @param string $encodedString
-
 
206
     * @param bool $upper
-
 
207
     * @return string
-
 
208
     */
-
 
209
    public static function decodeNoPadding(
-
 
210
        #[\SensitiveParameter]
-
 
211
        string $encodedString,
-
 
212
        bool $upper = false
-
 
213
    ): string {
-
 
214
        $srcLen = Binary::safeStrlen($encodedString);
-
 
215
        if ($srcLen === 0) {
-
 
216
            return '';
-
 
217
        }
-
 
218
        if (($srcLen & 7) === 0) {
-
 
219
            for ($j = 0; $j < 7 && $j < $srcLen; ++$j) {
-
 
220
                if ($encodedString[$srcLen - $j - 1] === '=') {
-
 
221
                    throw new InvalidArgumentException(
-
 
222
                        "decodeNoPadding() doesn't tolerate padding"
-
 
223
                    );
-
 
224
                }
-
 
225
            }
-
 
226
        }
-
 
227
        return static::doDecode(
-
 
228
            $encodedString,
-
 
229
            $upper,
Línea 180... Línea 230...
180
        return \pack('C', $src + $diff);
230
            true
181
    }
231
        );
182
 
232
    }
183
 
233
 
184
    /**
234
    /**
185
     * Base32 decoding
235
     * Base32 decoding
186
     *
236
     *
-
 
237
     * @param string $src
-
 
238
     * @param bool $upper
187
     * @param string $src
239
     * @param bool $strictPadding
188
     * @param bool $upper
240
     * @return string
-
 
241
     *
-
 
242
     * @throws TypeError
-
 
243
     */
-
 
244
    protected static function doDecode(
189
     * @param bool $strictPadding
245
        #[\SensitiveParameter]
190
     * @return string
246
        string $src,
191
     */
247
        bool $upper = false,
192
    protected static function doDecode($src, $upper = \false, $strictPadding = \true)
248
        bool $strictPadding = false
193
    {
249
    ): string {
Línea 210... Línea 266...
210
                        break;
266
                        break;
211
                    }
267
                    }
212
                }
268
                }
213
            }
269
            }
214
            if (($srcLen & 7) === 1) {
270
            if (($srcLen & 7) === 1) {
215
                throw new \RangeException(
271
                throw new RangeException(
216
                    'Incorrect padding'
272
                    'Incorrect padding'
217
                );
273
                );
218
            }
274
            }
219
        } else {
275
        } else {
220
            $src = \rtrim($src, '=');
276
            $src = \rtrim($src, '=');
Línea 223... Línea 279...
223
 
279
 
224
        $err = 0;
280
        $err = 0;
225
        $dest = '';
281
        $dest = '';
226
        // Main loop (no padding):
282
        // Main loop (no padding):
-
 
283
        for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
227
        for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
284
            /** @var array<int, int> $chunk */
-
 
285
            $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 8));
228
            $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 8));
286
            /** @var int $c0 */
-
 
287
            $c0 = static::$method($chunk[1]);
229
            $c0 = static::$method($chunk[1]);
288
            /** @var int $c1 */
-
 
289
            $c1 = static::$method($chunk[2]);
230
            $c1 = static::$method($chunk[2]);
290
            /** @var int $c2 */
-
 
291
            $c2 = static::$method($chunk[3]);
231
            $c2 = static::$method($chunk[3]);
292
            /** @var int $c3 */
-
 
293
            $c3 = static::$method($chunk[4]);
232
            $c3 = static::$method($chunk[4]);
294
            /** @var int $c4 */
-
 
295
            $c4 = static::$method($chunk[5]);
233
            $c4 = static::$method($chunk[5]);
296
            /** @var int $c5 */
-
 
297
            $c5 = static::$method($chunk[6]);
234
            $c5 = static::$method($chunk[6]);
298
            /** @var int $c6 */
-
 
299
            $c6 = static::$method($chunk[7]);
235
            $c6 = static::$method($chunk[7]);
300
            /** @var int $c7 */
Línea 236... Línea 301...
236
            $c7 = static::$method($chunk[8]);
301
            $c7 = static::$method($chunk[8]);
237
 
302
 
238
            $dest .= \pack(
303
            $dest .= \pack(
Línea 245... Línea 310...
245
            );
310
            );
246
            $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6 | $c7) >> 8;
311
            $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6 | $c7) >> 8;
247
        }
312
        }
248
        // The last chunk, which may have padding:
313
        // The last chunk, which may have padding:
249
        if ($i < $srcLen) {
314
        if ($i < $srcLen) {
-
 
315
            /** @var array<int, int> $chunk */
250
            $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
316
            $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
-
 
317
            /** @var int $c0 */
251
            $c0 = static::$method($chunk[1]);
318
            $c0 = static::$method($chunk[1]);
Línea 252... Línea 319...
252
 
319
 
-
 
320
            if ($i + 6 < $srcLen) {
253
            if ($i + 6 < $srcLen) {
321
                /** @var int $c1 */
-
 
322
                $c1 = static::$method($chunk[2]);
254
                $c1 = static::$method($chunk[2]);
323
                /** @var int $c2 */
-
 
324
                $c2 = static::$method($chunk[3]);
255
                $c2 = static::$method($chunk[3]);
325
                /** @var int $c3 */
-
 
326
                $c3 = static::$method($chunk[4]);
256
                $c3 = static::$method($chunk[4]);
327
                /** @var int $c4 */
-
 
328
                $c4 = static::$method($chunk[5]);
257
                $c4 = static::$method($chunk[5]);
329
                /** @var int $c5 */
-
 
330
                $c5 = static::$method($chunk[6]);
258
                $c5 = static::$method($chunk[6]);
331
                /** @var int $c6 */
Línea 259... Línea 332...
259
                $c6 = static::$method($chunk[7]);
332
                $c6 = static::$method($chunk[7]);
260
 
333
 
261
                $dest .= \pack(
334
                $dest .= \pack(
262
                    'CCCC',
335
                    'CCCC',
263
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
336
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
264
                    (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
337
                    (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
265
                    (($c3 << 4) | ($c4 >> 1)             ) & 0xff,
338
                    (($c3 << 4) | ($c4 >> 1)             ) & 0xff,
266
                    (($c4 << 7) | ($c5 << 2) | ($c6 >> 3)) & 0xff
339
                    (($c4 << 7) | ($c5 << 2) | ($c6 >> 3)) & 0xff
-
 
340
                );
-
 
341
                $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6) >> 8;
-
 
342
                if ($strictPadding) {
267
                );
343
                    $err |= ($c6 << 5) & 0xff;
-
 
344
                }
268
                $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6) >> 8;
345
            } elseif ($i + 5 < $srcLen) {
-
 
346
                /** @var int $c1 */
269
            } elseif ($i + 5 < $srcLen) {
347
                $c1 = static::$method($chunk[2]);
-
 
348
                /** @var int $c2 */
270
                $c1 = static::$method($chunk[2]);
349
                $c2 = static::$method($chunk[3]);
-
 
350
                /** @var int $c3 */
271
                $c2 = static::$method($chunk[3]);
351
                $c3 = static::$method($chunk[4]);
-
 
352
                /** @var int $c4 */
272
                $c3 = static::$method($chunk[4]);
353
                $c4 = static::$method($chunk[5]);
Línea 273... Línea 354...
273
                $c4 = static::$method($chunk[5]);
354
                /** @var int $c5 */
274
                $c5 = static::$method($chunk[6]);
355
                $c5 = static::$method($chunk[6]);
275
 
356
 
Línea 280... Línea 361...
280
                    (($c3 << 4) | ($c4 >> 1)             ) & 0xff,
361
                    (($c3 << 4) | ($c4 >> 1)             ) & 0xff,
281
                    (($c4 << 7) | ($c5 << 2)             ) & 0xff
362
                    (($c4 << 7) | ($c5 << 2)             ) & 0xff
282
                );
363
                );
283
                $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5) >> 8;
364
                $err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5) >> 8;
284
            } elseif ($i + 4 < $srcLen) {
365
            } elseif ($i + 4 < $srcLen) {
-
 
366
                /** @var int $c1 */
285
                $c1 = static::$method($chunk[2]);
367
                $c1 = static::$method($chunk[2]);
-
 
368
                /** @var int $c2 */
286
                $c2 = static::$method($chunk[3]);
369
                $c2 = static::$method($chunk[3]);
-
 
370
                /** @var int $c3 */
287
                $c3 = static::$method($chunk[4]);
371
                $c3 = static::$method($chunk[4]);
-
 
372
                /** @var int $c4 */
288
                $c4 = static::$method($chunk[5]);
373
                $c4 = static::$method($chunk[5]);
Línea 289... Línea 374...
289
 
374
 
290
                $dest .= \pack(
375
                $dest .= \pack(
291
                    'CCC',
376
                    'CCC',
292
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
377
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
293
                    (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
378
                    (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
294
                    (($c3 << 4) | ($c4 >> 1)             ) & 0xff
379
                    (($c3 << 4) | ($c4 >> 1)             ) & 0xff
295
                );
380
                );
-
 
381
                $err |= ($c0 | $c1 | $c2 | $c3 | $c4) >> 8;
-
 
382
                if ($strictPadding) {
-
 
383
                    $err |= ($c4 << 7) & 0xff;
296
                $err |= ($c0 | $c1 | $c2 | $c3 | $c4) >> 8;
384
                }
-
 
385
            } elseif ($i + 3 < $srcLen) {
297
            } elseif ($i + 3 < $srcLen) {
386
                /** @var int $c1 */
-
 
387
                $c1 = static::$method($chunk[2]);
298
                $c1 = static::$method($chunk[2]);
388
                /** @var int $c2 */
-
 
389
                $c2 = static::$method($chunk[3]);
299
                $c2 = static::$method($chunk[3]);
390
                /** @var int $c3 */
Línea 300... Línea 391...
300
                $c3 = static::$method($chunk[4]);
391
                $c3 = static::$method($chunk[4]);
301
 
392
 
302
                $dest .= \pack(
393
                $dest .= \pack(
303
                    'CC',
394
                    'CC',
304
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
395
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
305
                    (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff
396
                    (($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff
-
 
397
                );
-
 
398
                $err |= ($c0 | $c1 | $c2 | $c3) >> 8;
-
 
399
                if ($strictPadding) {
306
                );
400
                    $err |= ($c3 << 4) & 0xff;
-
 
401
                }
307
                $err |= ($c0 | $c1 | $c2 | $c3) >> 8;
402
            } elseif ($i + 2 < $srcLen) {
-
 
403
                /** @var int $c1 */
308
            } elseif ($i + 2 < $srcLen) {
404
                $c1 = static::$method($chunk[2]);
Línea 309... Línea 405...
309
                $c1 = static::$method($chunk[2]);
405
                /** @var int $c2 */
310
                $c2 = static::$method($chunk[3]);
406
                $c2 = static::$method($chunk[3]);
311
 
407
 
312
                $dest .= \pack(
408
                $dest .= \pack(
313
                    'CC',
409
                    'CC',
314
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
410
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff,
-
 
411
                    (($c1 << 6) | ($c2 << 1)             ) & 0xff
-
 
412
                );
-
 
413
                $err |= ($c0 | $c1 | $c2) >> 8;
315
                    (($c1 << 6) | ($c2 << 1)             ) & 0xff
414
                if ($strictPadding) {
-
 
415
                    $err |= ($c2 << 6) & 0xff;
316
                );
416
                }
Línea 317... Línea 417...
317
                $err |= ($c0 | $c1 | $c2) >> 8;
417
            } elseif ($i + 1 < $srcLen) {
318
            } elseif ($i + 1 < $srcLen) {
418
                /** @var int $c1 */
319
                $c1 = static::$method($chunk[2]);
419
                $c1 = static::$method($chunk[2]);
320
 
420
 
321
                $dest .= \pack(
421
                $dest .= \pack(
-
 
422
                    'C',
-
 
423
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff
-
 
424
                );
322
                    'C',
425
                $err |= ($c0 | $c1) >> 8;
323
                    (($c0 << 3) | ($c1 >> 2)             ) & 0xff
426
                if ($strictPadding) {
324
                );
427
                    $err |= ($c1 << 6) & 0xff;
325
                $err |= ($c0 | $c1) >> 8;
428
                }
326
            } else {
429
            } else {
327
                $dest .= \pack(
430
                $dest .= \pack(
328
                    'C',
431
                    'C',
329
                    (($c0 << 3)                          ) & 0xff
432
                    (($c0 << 3)                          ) & 0xff
330
                );
433
                );
-
 
434
                $err |= ($c0) >> 8;
331
                $err |= ($c0) >> 8;
435
            }
332
            }
436
        }
333
        }
437
        $check = ($err === 0);
334
        if ($err !== 0) {
438
        if (!$check) {
335
            throw new \RangeException(
439
            throw new RangeException(
336
                'Base32::doDecode() only expects characters in the correct base32 alphabet'
440
                'Base32::doDecode() only expects characters in the correct base32 alphabet'
Línea 337... Línea 441...
337
            );
441
            );
338
        }
442
        }
339
        return $dest;
443
        return $dest;
340
    }
444
    }
341
 
445
 
342
    /**
446
    /**
343
     * Base32 Decoding
447
     * Base32 Encoding
-
 
448
     *
344
     *
449
     * @param string $src
345
     * @param string $src
450
     * @param bool $upper
-
 
451
     * @param bool $pad
-
 
452
     * @return string
-
 
453
     * @throws TypeError
-
 
454
     */
346
     * @param bool $upper
455
    protected static function doEncode(
347
     * @param bool $pad
456
        #[\SensitiveParameter]
348
     * @return string
457
        string $src,
349
     */
458
        bool $upper = false,
350
    protected static function doEncode($src, $upper = \false, $pad = \true)
459
        $pad = true
351
    {
460
    ): string {
352
        // We do this to reduce code duplication:
461
        // We do this to reduce code duplication:
353
        $method = $upper
462
        $method = $upper
Línea 354... Línea 463...
354
            ? 'encode5BitsUpper'
463
            ? 'encode5BitsUpper'
355
            : 'encode5Bits';
464
            : 'encode5Bits';
-
 
465
        
356
 
466
        $dest = '';
357
        $dest = '';
467
        $srcLen = Binary::safeStrlen($src);
358
        $srcLen = Binary::safeStrlen($src);
468
 
359
 
469
        // Main loop (no padding):
360
        // Main loop (no padding):
470
        for ($i = 0; $i + 5 <= $srcLen; $i += 5) {
Línea 375... Línea 485...
375
                static::$method((($b3 << 3) | ($b4 >> 5)) & 31) .
485
                static::$method((($b3 << 3) | ($b4 >> 5)) & 31) .
376
                static::$method(  $b4                     & 31);
486
                static::$method(  $b4                     & 31);
377
        }
487
        }
378
        // The last chunk, which may have padding:
488
        // The last chunk, which may have padding:
379
        if ($i < $srcLen) {
489
        if ($i < $srcLen) {
-
 
490
            /** @var array<int, int> $chunk */
380
            $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
491
            $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
381
            $b0 = $chunk[1];
492
            $b0 = $chunk[1];
382
            if ($i + 3 < $srcLen) {
493
            if ($i + 3 < $srcLen) {
383
                $b1 = $chunk[2];
494
                $b1 = $chunk[2];
384
                $b2 = $chunk[3];
495
                $b2 = $chunk[3];
Línea 425... Línea 536...
425
                }
536
                }
426
            }
537
            }
427
        }
538
        }
428
        return $dest;
539
        return $dest;
429
    }
540
    }
430
}
-
 
431
541
}
-
 
542