Skip to content

Commit 93276b1

Browse files
committed
Fully qualify the sodium_*() function calls
This avoids a lookup to see if the functions exist in the `ParagonIE\ConstantTime` namespace and ensures that there is no “userland” fake implementation taking precedence.
1 parent e2f2b23 commit 93276b1

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Base64.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function encode(
6161
};
6262
if ($variant > 0) {
6363
try {
64-
return sodium_bin2base64($binString, $variant);
64+
return \sodium_bin2base64($binString, $variant);
6565
} catch (SodiumException $ex) {
6666
throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
6767
}
@@ -93,7 +93,7 @@ public static function encodeUnpadded(
9393
};
9494
if ($variant > 0) {
9595
try {
96-
return sodium_bin2base64($src, $variant);
96+
return \sodium_bin2base64($src, $variant);
9797
} catch (SodiumException $ex) {
9898
throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
9999
}
@@ -207,7 +207,7 @@ public static function decode(
207207
};
208208
if ($variant > 0) {
209209
try {
210-
return sodium_base642bin($encodedString, $variant);
210+
return \sodium_base642bin($encodedString, $variant);
211211
} catch (SodiumException $ex) {
212212
throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
213213
}

src/Hex.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function encode(
5050
): string {
5151
if (\extension_loaded('sodium')) {
5252
try {
53-
return sodium_bin2hex($binString);
53+
return \sodium_bin2hex($binString);
5454
} catch (SodiumException $ex) {
5555
throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
5656
}
@@ -119,7 +119,7 @@ public static function decode(
119119
): string {
120120
if (\extension_loaded('sodium') && $strictPadding) {
121121
try {
122-
return sodium_hex2bin($encodedString);
122+
return \sodium_hex2bin($encodedString);
123123
} catch (SodiumException $ex) {
124124
throw new RangeException($ex->getMessage(), $ex->getCode(), $ex);
125125
}

0 commit comments

Comments
 (0)