You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
verify() with an empty signature throws FFI\Exception instead of OqsException #3
$sig = newOqsSig('ML-DSA-65');
$keys = $sig->generateKeypair();
$sig->verify('msg', '', $keys['public_key']);
// FFI\Exception: Cannot instantiate FFI\CData of zero size
verify() allocates the signature buffer with $ffi->new('uint8_t[' . strlen($signature) . ']'), and PHP FFI rejects a zero-size allocation.
This matters because the README documents verify() as "Never throws for an invalid signature — only for malformed input lengths", and signatures are attacker-controlled input. Code following that contract with catch (OqsException) won't contain the exception, so an empty signature becomes an uncaught fatal error.
The same treatment applied to the signature buffer (passing the real length to OQS_SIG_verify separately) fixes it. An explicit length check that returns false would work too — a zero-length signature is never valid for any supported algorithm.
Non-empty malformed signatures behave correctly: a 1-byte signature and an oversized signature both return false as expected.
Reproduced with liboqs 0.16.0 (shared build), PHP 8.5.8 with FFI, macOS/arm64.
Activity