Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
constant_time_encoding
Commits
f49da04f
Unverified
Commit
f49da04f
authored
3 years ago
by
P.I.E. Security Team
Committed by
GitHub
3 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #37 from paragonie/v2-cleanup
Clean up unnecessary annotations
parents
0fe5aaec
5ebee1a2
master
v2.6.3
v2.6.2
v2.6.1
v2.6.0
v2.5.0
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Base32.php
+0
-1
src/Base32.php
src/Base64.php
+1
-2
src/Base64.php
src/Binary.php
+2
-2
src/Binary.php
src/Hex.php
+0
-18
src/Hex.php
with
3 additions
and
23 deletions
+3
-23
src/Base32.php
+
0
−
1
View file @
f49da04f
...
...
@@ -367,7 +367,6 @@ abstract class Base32 implements EncoderInterface
$err
|=
(
$c0
)
>>
8
;
}
}
/** @var bool $check */
$check
=
(
$err
===
0
);
if
(
!
$check
)
{
throw
new
\
RangeException
(
...
...
This diff is collapsed.
Click to expand it.
src/Base64.php
+
1
−
2
View file @
f49da04f
...
...
@@ -196,11 +196,10 @@ abstract class Base64 implements EncoderInterface
(((
$c0
<<
2
)
|
(
$c1
>>
4
))
&
0xff
)
);
$err
|=
(
$c0
|
$c1
)
>>
8
;
}
elseif
(
$i
<
$srcLen
&&
$strictPadding
)
{
}
elseif
(
$strictPadding
)
{
$err
|=
1
;
}
}
/** @var bool $check */
$check
=
(
$err
===
0
);
if
(
!
$check
)
{
throw
new
\
RangeException
(
...
...
This diff is collapsed.
Click to expand it.
src/Binary.php
+
2
−
2
View file @
f49da04f
...
...
@@ -62,14 +62,14 @@ abstract class Binary
* @staticvar boolean $exists
* @param string $str
* @param int $start
* @param int $length
* @param
?
int $length
* @return string
* @throws \TypeError
*/
public
static
function
safeSubstr
(
string
$str
,
int
$start
=
0
,
$length
=
null
int
$length
=
null
):
string
{
if
(
$length
===
0
)
{
return
''
;
...
...
This diff is collapsed.
Click to expand it.
src/Hex.php
+
0
−
18
View file @
f49da04f
...
...
@@ -41,15 +41,12 @@ abstract class Hex implements EncoderInterface
*/
public
static
function
encode
(
string
$binString
):
string
{
/** @var string $hex */
$hex
=
''
;
$len
=
Binary
::
safeStrlen
(
$binString
);
for
(
$i
=
0
;
$i
<
$len
;
++
$i
)
{
/** @var array<int, int> $chunk */
$chunk
=
\
unpack
(
'C'
,
Binary
::
safeSubstr
(
$binString
,
$i
,
1
));
/** @var int $c */
$c
=
$chunk
[
1
]
&
0xf
;
/** @var int $b */
$b
=
$chunk
[
1
]
>>
4
;
$hex
.
=
pack
(
...
...
@@ -71,17 +68,13 @@ abstract class Hex implements EncoderInterface
*/
public
static
function
encodeUpper
(
string
$binString
):
string
{
/** @var string $hex */
$hex
=
''
;
/** @var int $len */
$len
=
Binary
::
safeStrlen
(
$binString
);
for
(
$i
=
0
;
$i
<
$len
;
++
$i
)
{
/** @var array<int, int> $chunk */
$chunk
=
\
unpack
(
'C'
,
Binary
::
safeSubstr
(
$binString
,
$i
,
2
));
/** @var int $c */
$c
=
$chunk
[
1
]
&
0xf
;
/** @var int $b */
$b
=
$chunk
[
1
]
>>
4
;
$hex
.
=
pack
(
...
...
@@ -104,15 +97,10 @@ abstract class Hex implements EncoderInterface
*/
public
static
function
decode
(
string
$encodedString
,
bool
$strictPadding
=
false
):
string
{
/** @var int $hex_pos */
$hex_pos
=
0
;
/** @var string $bin */
$bin
=
''
;
/** @var int $c_acc */
$c_acc
=
0
;
/** @var int $hex_len */
$hex_len
=
Binary
::
safeStrlen
(
$encodedString
);
/** @var int $state */
$state
=
0
;
if
((
$hex_len
&
1
)
!==
0
)
{
if
(
$strictPadding
)
{
...
...
@@ -129,15 +117,10 @@ abstract class Hex implements EncoderInterface
$chunk
=
\
unpack
(
'C*'
,
$encodedString
);
while
(
$hex_pos
<
$hex_len
)
{
++
$hex_pos
;
/** @var int $c */
$c
=
$chunk
[
$hex_pos
];
/** @var int $c_num */
$c_num
=
$c
^
48
;
/** @var int $c_num0 */
$c_num0
=
(
$c_num
-
10
)
>>
8
;
/** @var int $c_alpha */
$c_alpha
=
(
$c
&
~
32
)
-
55
;
/** @var int $c_alpha0 */
$c_alpha0
=
((
$c_alpha
-
10
)
^
(
$c_alpha
-
16
))
>>
8
;
if
((
$c_num0
|
$c_alpha0
)
===
0
)
{
...
...
@@ -145,7 +128,6 @@ abstract class Hex implements EncoderInterface
'Expected hexadecimal character'
);
}
/** @var int $c_val */
$c_val
=
(
$c_num0
&
$c_num
)
|
(
$c_alpha
&
$c_alpha0
);
if
(
$state
===
0
)
{
$c_acc
=
$c_val
*
16
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets