]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix RSA key size validation in EVP_PKEY_RSA_keygen demo
authorQuin-Darcy <pohmsuindraguli@gmail.com>
Thu, 31 Jul 2025 14:07:46 +0000 (09:07 -0500)
committerTomas Mraz <tomas@openssl.org>
Mon, 11 Aug 2025 14:46:43 +0000 (16:46 +0200)
The validation was checking the default 'bits' value (4096) instead of
the parsed 'bits_i' from the command line arguments, allowing invalid
key sizes to bypass the 512-bit minimum.

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28139)

(cherry picked from commit c79e1b212a616b8dca194a77e7698b886000fcb0)

demos/pkey/EVP_PKEY_RSA_keygen.c

index 353c08152c04800f45792dfa86b187987aaf58d1..d268f60d4c5962e321afe328ef0585442d8b9bd2 100644 (file)
@@ -254,7 +254,7 @@ int main(int argc, char **argv)
 
     if (argc > 1) {
         bits_i = atoi(argv[1]);
-        if (bits < 512) {
+        if (bits_i < 512) {
             fprintf(stderr, "Invalid RSA key size\n");
             return EXIT_FAILURE;
         }