httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: httpd-2.0/modules/ssl ssl_engine_init.c
Date Wed, 13 Mar 2002 00:50:14 GMT
dougm       02/03/12 16:50:14

  Modified:    modules/ssl ssl_engine_init.c
  Log:
  folding more duplication in ssl_tmp_keys_init
  
  Revision  Changes    Path
  1.52      +35 -36    httpd-2.0/modules/ssl/ssl_engine_init.c
  
  Index: ssl_engine_init.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_engine_init.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- ssl_engine_init.c	12 Mar 2002 23:05:33 -0000	1.51
  +++ ssl_engine_init.c	13 Mar 2002 00:50:13 -0000	1.52
  @@ -141,60 +141,59 @@
       MODSSL_TMP_KEYS_FREE(mc, DH);
   }
   
  -static void ssl_tmp_keys_init(server_rec *s, apr_pool_t *p)
  +static void ssl_tmp_key_init_rsa(server_rec *s,
  +                                 int bits, int idx)
   {
       SSLModConfigRec *mc = myModConfig(s);
   
  -    /* seed PRNG */
  -    ssl_rand_seed(s, p, SSL_RSCTX_STARTUP, "Init: ");
  -
  -    /* generate 512 bit RSA key */
  -    ssl_log(s, SSL_LOG_INFO,
  -            "Init: Generating temporary RSA private keys (512/1024 bits)");
  -
  -    /* generate 512 bit RSA key */
  -    if (!(mc->pTmpKeys[SSL_TMP_KEY_RSA_512] = 
  -          RSA_generate_key(512, RSA_F4, NULL, NULL)))
  +    if (!(mc->pTmpKeys[idx] =
  +          RSA_generate_key(bits, RSA_F4, NULL, NULL)))
       {
           ssl_log(s, SSL_LOG_ERROR,
                   "Init: Failed to generate temporary "
  -                "512 bit RSA private key");
  +                "%d bit RSA private key", bits);
           ssl_die();
       }
   
  -    /* generate 1024 bit RSA key */
  -    if (!(mc->pTmpKeys[SSL_TMP_KEY_RSA_1024] = 
  -          RSA_generate_key(1024, RSA_F4, NULL, NULL)))
  +}
  +
  +static void ssl_tmp_key_init_dh(server_rec *s,
  +                                int bits, int idx)
  +{
  +    SSLModConfigRec *mc = myModConfig(s);
  +
  +    if (!(mc->pTmpKeys[idx] =
  +          ssl_dh_GetTmpParam(bits)))
       {
           ssl_log(s, SSL_LOG_ERROR,
                   "Init: Failed to generate temporary "
  -                "1024 bit RSA private key");
  +                "%d bit DH parameters", bits);
           ssl_die();
       }
  +}
  +
  +#define MODSSL_TMP_KEY_INIT_RSA(s, bits) \
  +    ssl_tmp_key_init_rsa(s, bits, SSL_TMP_KEY_RSA_##bits)
  +
  +#define MODSSL_TMP_KEY_INIT_DH(s, bits) \
  +    ssl_tmp_key_init_dh(s, bits, SSL_TMP_KEY_DH_##bits)
  +
  +static void ssl_tmp_keys_init(server_rec *s, apr_pool_t *p)
  +{
  +    /* seed PRNG */
  +    ssl_rand_seed(s, p, SSL_RSCTX_STARTUP, "Init: ");
   
       ssl_log(s, SSL_LOG_INFO,
  -            "Init: Configuring temporary "
  -            "DH parameters (512/1024 bits)");
  +            "Init: Generating temporary RSA private keys (512/1024 bits)");
   
  -    /* generate 512 bit DH param */
  -    if (!(mc->pTmpKeys[SSL_TMP_KEY_DH_512] = 
  -          ssl_dh_GetTmpParam(512)))
  -    {
  -        ssl_log(s, SSL_LOG_ERROR,
  -                "Init: Failed to generate temporary "
  -                "512 bit DH parameters");
  -        ssl_die();
  -    }
  +    MODSSL_TMP_KEY_INIT_RSA(s, 512);
  +    MODSSL_TMP_KEY_INIT_RSA(s, 1024);
   
  -    /* generate 1024 bit DH param */
  -    if (!(mc->pTmpKeys[SSL_TMP_KEY_DH_1024] = 
  -          ssl_dh_GetTmpParam(1024)))
  -    {
  -        ssl_log(s, SSL_LOG_ERROR,
  -                "Init: Failed to generate temporary "
  -                "1024 bit DH parameters");
  -        ssl_die();
  -    }
  +    ssl_log(s, SSL_LOG_INFO,
  +            "Init: Configuring temporary DH parameters (512/1024 bits)");
  +
  +    MODSSL_TMP_KEY_INIT_DH(s, 512);
  +    MODSSL_TMP_KEY_INIT_DH(s, 1024);
   }
   
   /*
  
  
  

Mime
View raw message