Compare commits

...
Author SHA1 Message Date
kj 0c7eecb97d release(crypto): v0.1.2 2026-11-22 13:25:51 -03:00
kj 9c80f13748 fix(crypto): reject malformed nonce in check() 2026-11-22 13:25:48 -03:00
kj 5a28e37998 fix(crypto): guard decryptHex against malformed hex input 2026-11-22 13:25:48 -03:00
3 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "crypto",
"version": "0.1.1",
"version": "0.1.2",
"description": "Criptograf\u00eda y segundo factor (Crypto, Nonce, TwoFactorAuthenticator)",
"core": {
"requires": ">=0.1",
+4
View File
@@ -41,6 +41,10 @@ class Crypto
*/
public static function decryptHex(string $data, string $password = PRIVATE_KEY): string
{
if ($data === '' || !ctype_xdigit($data) || strlen($data) % 2 !== 0) {
return '';
}
return static::decrypt(hex2bin($data), $password);
}
+4
View File
@@ -42,6 +42,10 @@ class Nonce
*/
public static function check(string $nonce, string $passphrase = ''): bool
{
if ($nonce === '' || !ctype_xdigit($nonce) || strlen($nonce) % 2 !== 0) {
return false;
}
$decripted = openssl_decrypt(
hex2bin($nonce),
'aes-128-ecb',