Pass error return value to exception

If the size return value is negative, an error is detected. In that case raise an exception. Even though a zero is not a valid size value, it would indicate success in other cases. But a 0 return value would not make much sense as a return value for this function.
pull/110/head
Robert de Vries 2026-05-08 16:38:59 +02:00 committed by GitHub
parent 0ac207d34a
commit 8d80db4914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -873,8 +873,8 @@ if _lib.RSA_ENABLED:
rsa.output_size = _lib.wc_RsaEncryptSize(rsa.native_object)
rsa.size = size
if rsa.output_size <= 0: # pragma: no cover
raise WolfCryptApiError("Invalid key size error", ret)
if rsa.output_size < 0: # pragma: no cover
raise WolfCryptApiError("Invalid key size error", rsa.output_size)
# Retain RNG reference defensively.
rsa._rng = rng