]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
The return value of RSA_*_{en,de}crypt() is signed
authorViktor Dukhovni <openssl-users@dukhovni.org>
Sat, 6 Dec 2025 04:04:36 +0000 (15:04 +1100)
committerTomas Mraz <tomas@openssl.org>
Thu, 11 Dec 2025 12:06:47 +0000 (13:06 +0100)
The functions RSA_(public|private)_(en|de)crypt() return a signed
result, in particular `-1` may be returned on error, so the caller
MUST treat the value as signed.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29323)

crypto/rsa/rsa_gen.c

index ecc0b1b829b4efdca1aa6876db615141f9344091..9e053edb7c2021ef0754f0351db65b5a29c1b53a 100644 (file)
@@ -693,12 +693,12 @@ static int rsa_keygen(OSSL_LIB_CTX *libctx, RSA *rsa, int bits, int primes,
 static int rsa_keygen_pairwise_test(RSA *rsa, OSSL_CALLBACK *cb, void *cbarg)
 {
     int ret = 0;
-    unsigned int plaintxt_len;
     unsigned char *plaintxt = NULL;
-    unsigned int ciphertxt_len;
     unsigned char *ciphertxt = NULL;
     unsigned char *decoded = NULL;
-    unsigned int decoded_len;
+    int plaintxt_len;
+    int ciphertxt_len;
+    int decoded_len;
     int padding = RSA_NO_PADDING;
     OSSL_SELF_TEST *st = NULL;