Compare commits

..
Author SHA1 Message Date
kj 41dc18673c release(commands): v0.2.10 2026-11-22 13:26:08 -03:00
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
5 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "commands", "name": "commands",
"version": "0.2.9", "version": "0.2.10",
"description": "CLI y migraciones para Duckbrain", "description": "CLI y migraciones para Duckbrain",
"components": { "components": {
"cli": { "cli": {
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Toolbox;
*/ */
final class Config final class Config
{ {
public const VERSION = '0.2.9'; public const VERSION = '0.2.10';
public static function toolboxUrl(): string public static function toolboxUrl(): string
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "crypto", "name": "crypto",
"version": "0.1.1", "version": "0.1.2",
"description": "Criptograf\u00eda y segundo factor (Crypto, Nonce, TwoFactorAuthenticator)", "description": "Criptograf\u00eda y segundo factor (Crypto, Nonce, TwoFactorAuthenticator)",
"core": { "core": {
"requires": ">=0.1", "requires": ">=0.1",
+4
View File
@@ -41,6 +41,10 @@ class Crypto
*/ */
public static function decryptHex(string $data, string $password = PRIVATE_KEY): string 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); return static::decrypt(hex2bin($data), $password);
} }
+4
View File
@@ -42,6 +42,10 @@ class Nonce
*/ */
public static function check(string $nonce, string $passphrase = ''): bool public static function check(string $nonce, string $passphrase = ''): bool
{ {
if ($nonce === '' || !ctype_xdigit($nonce) || strlen($nonce) % 2 !== 0) {
return false;
}
$decripted = openssl_decrypt( $decripted = openssl_decrypt(
hex2bin($nonce), hex2bin($nonce),
'aes-128-ecb', 'aes-128-ecb',