[BACK]Return to genrsa.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / openssl

Diff for /src/usr.bin/openssl/genrsa.c between version 1.21 and 1.22

version 1.21, 2022/11/11 17:07:39 version 1.22, 2023/03/06 14:32:06
Line 90 
Line 90 
         unsigned long f4;          unsigned long f4;
         char *outfile;          char *outfile;
         char *passargout;          char *passargout;
 } genrsa_config;  } cfg;
   
 static int  static int
 set_public_exponent(int argc, char **argv, int *argsused)  set_public_exponent(int argc, char **argv, int *argsused)
Line 98 
Line 98 
         char *option = argv[0];          char *option = argv[0];
   
         if (strcmp(option, "-3") == 0)          if (strcmp(option, "-3") == 0)
                 genrsa_config.f4 = 3;                  cfg.f4 = 3;
         else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0)          else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0)
                 genrsa_config.f4 = RSA_F4;                  cfg.f4 = RSA_F4;
         else          else
                 return (1);                  return (1);
   
Line 150 
Line 150 
         if (*name++ != '-')          if (*name++ != '-')
                 return (1);                  return (1);
   
         if ((genrsa_config.enc = get_cipher_by_name(name)) == NULL)          if ((cfg.enc = get_cipher_by_name(name)) == NULL)
                 return (1);                  return (1);
   
         *argsused = 1;          *argsused = 1;
Line 243 
Line 243 
                 .argname = "file",                  .argname = "file",
                 .desc = "Output the key to 'file'",                  .desc = "Output the key to 'file'",
                 .type = OPTION_ARG,                  .type = OPTION_ARG,
                 .opt.arg = &genrsa_config.outfile,                  .opt.arg = &cfg.outfile,
         },          },
         {          {
                 .name = "passout",                  .name = "passout",
                 .argname = "arg",                  .argname = "arg",
                 .desc = "Output file passphrase source",                  .desc = "Output file passphrase source",
                 .type = OPTION_ARG,                  .type = OPTION_ARG,
                 .opt.arg = &genrsa_config.passargout,                  .opt.arg = &cfg.passargout,
         },          },
         { NULL },          { NULL },
 };  };
Line 300 
Line 300 
                 goto err;                  goto err;
         }          }
   
         memset(&genrsa_config, 0, sizeof(genrsa_config));          memset(&cfg, 0, sizeof(cfg));
         genrsa_config.f4 = RSA_F4;          cfg.f4 = RSA_F4;
   
         if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) {          if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) {
                 genrsa_usage();                  genrsa_usage();
Line 314 
Line 314 
                 goto err;                  goto err;
         }          }
   
         if (!app_passwd(bio_err, NULL, genrsa_config.passargout, NULL,          if (!app_passwd(bio_err, NULL, cfg.passargout, NULL,
             &passout)) {              &passout)) {
                 BIO_printf(bio_err, "Error getting password\n");                  BIO_printf(bio_err, "Error getting password\n");
                 goto err;                  goto err;
         }          }
   
         if (genrsa_config.outfile == NULL) {          if (cfg.outfile == NULL) {
                 BIO_set_fp(out, stdout, BIO_NOCLOSE);                  BIO_set_fp(out, stdout, BIO_NOCLOSE);
         } else {          } else {
                 if (BIO_write_filename(out, genrsa_config.outfile) <= 0) {                  if (BIO_write_filename(out, cfg.outfile) <= 0) {
                         perror(genrsa_config.outfile);                          perror(cfg.outfile);
                         goto err;                          goto err;
                 }                  }
         }          }
Line 335 
Line 335 
         if (!rsa)          if (!rsa)
                 goto err;                  goto err;
   
         if (!BN_set_word(bn, genrsa_config.f4) ||          if (!BN_set_word(bn, cfg.f4) ||
             !RSA_generate_key_ex(rsa, num, bn, cb))              !RSA_generate_key_ex(rsa, num, bn, cb))
                 goto err;                  goto err;
   
Line 348 
Line 348 
         {          {
                 PW_CB_DATA cb_data;                  PW_CB_DATA cb_data;
                 cb_data.password = passout;                  cb_data.password = passout;
                 cb_data.prompt_info = genrsa_config.outfile;                  cb_data.prompt_info = cfg.outfile;
                 if (!PEM_write_bio_RSAPrivateKey(out, rsa, genrsa_config.enc,                  if (!PEM_write_bio_RSAPrivateKey(out, rsa, cfg.enc,
                     NULL, 0, password_callback, &cb_data))                      NULL, 0, password_callback, &cb_data))
                         goto err;                          goto err;
         }          }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22