# Ssl\_dhparam and recommended-private-length

**URL:** <https://www.ruby-forum.com/t/ssl-dhparam-and-recommended-private-length/201221>\
**Category:** NGINX\
**Created:** [January 3, 2011, 9:58am UTC](https://www.ruby-forum.com/t/ssl-dhparam-and-recommended-private-length/201221 "2011-01-03T09:58:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 3, 2011, 9:58am UTC](https://www.ruby-forum.com/t/ssl-dhparam-and-recommended-private-length/201221/1 "2011-01-03T09:58:48Z")

</div>

Hi,

Nginx offers a possibility to import DH parameters (prime p and  
generator g) from external file. The parameters (p and g) have to be  
generated with “openssl dpharam.” In the default setting, openssl  
calculates strong primes and uses either 2 or 5 as generator. The  
private exponent in modular exponentiation is then very long, its bit  
representation is comparable in length to the prime modulus, e.g. 2047  
bits with 2048 bits long modulus. However, there is an extra option in  
openssl dhparam to generate DSA type parameters for Diffie-Hellman key  
exchange. The main advantage is that the recommended exponent length is  
much shorter, e.g. 224 or 256 bits with 2048 bits long modulus. The  
length of the exponent has direct impact on computational complexity  
because it determines the number of multiplications and squarings in  
modular exponentiation. For example, one could go down from 2048  
multiplications and squarings to 256 or 224.

At the moment, nginx passes only p and g parameters to SSL. It would be  
nice to pass also the recommended exponent length to openssl via  
dh-\>length provided that the recommended-private-length is present in  
pem file. For the recommended-private-length parameter to be present in  
PEM file, the DH parameters have to be generated with “openssl dhparam  
-dsaparam”

Posted at Nginx Forum:

> **[ssl\_dhparam and recommended-private-length](https://forum.nginx.org/read.php?2,163037,163037#msg-163037)**
>
> Hi, Nginx offers a possibility to import DH parameters (prime p and generator g) from external file. The parameters (p and g) have to be generated with "openssl dpharam." In the default setting, openssl calculates strong primes and uses...

---

<div class="post-metadata">

**Author:** ![timo2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@timo2](https://www.ruby-forum.com/u/timo2)\
**Post date:** [January 3, 2011, 1:06pm UTC](https://www.ruby-forum.com/t/ssl-dhparam-and-recommended-private-length/201221/2 "2011-01-03T13:06:25Z")

</div>

Well, it seems that openssl can handle it by itself if the recommended  
exponent length is in the pem file. Nginx uses openssl routines to  
decode PEM file in ngx\_ssl\_dhparam routine. So the recommended exponent  
length should be taken into account. Can anyone more experienced confirm  
that?

However, the default values (hardcoded in nginx source) are 1024 bit  
long safe prime p and generator g=2. NIST recommends to use at least  
2048 bits long primes with at least 224-bit prime order subgroup  
starting from 1 January 2011 🙂 Does using any 2048 group from RFC 5114  
as a default one make more sense?

Posted at Nginx Forum:

> **[Re: ssl\_dhparam and recommended-private-length](https://forum.nginx.org/read.php?2,163037,163078#msg-163078)**
>
> Hi, Nginx offers a possibility to import DH parameters (prime p and generator g) from external file. The parameters (p and g) have to be generated with "openssl dpharam." In the default setting, openssl calculates strong primes and uses...
