So you're making an RSA key for an HTTPS certificate. What key size do you use? (2024)

So you're about to make an RSA key for an SSL certificate. What key size should you use?

Since CertSimple only do EV certificates, we use a 2048 bit key in the bash & powershell we generate during our application process.

But why not go further? What experts have to say about 4096 bit keys varies greatly:

So you're making an RSA key for an HTTPS certificate. What key size do you use? (1)

You're probably already aware that with a 4096 bit key:

  • There's an increase in encryption strength.
  • The SSL handshake at the start of each connection will be slower.
  • There's an increase in CPU usage during handshakes.

But you may not be sure of the extent of each of these these effects. So: let's measure all these things.

Measuring encryption strength

Unlike traditional symmetric algos, asymettric algos like RSA (unfortunately) don't double in strength when you add a single bit.

So RSA key sizes are evaluated by National Institute of Standards and Technology by converting them to equivalent symmetric cipher values (see 'Comparable Algorithm Strengths'). NIST tells us a 2048 bit RSA key is equivalent to a 112 bit symmetric cipher.

NIST says a 2048 bit RSA key has a strength of 112 bits: i.e., there are theoretically 2112 possibilities to crack the private key.

Calculating RSA strength yourself

The NIST says they're using 'currently known methods' to build their data, but some clever folk on Crypto Stack Exchange worked out that the NIST data appears to use an algorthm to calculate the complexity of using a factoring attack called the 'number field sieve' by Dutch cryptographer Arjen K. Lenstra. This is handy, since the NIST recommendation doesn't include every key size. If you felt like firing up Mathematica, we could get results for, eg, a 2048 bit RSA key with:

> N[Log2[Exp[(64/9*Log[2^2048])^(1/3)*(Log[Log[2^2048]])^(2/3)]]]116.884

The Mathemetica code above was ported from Reid Wiggins' code on Crypto Stack Exchange - cheers Reid!

Since not everyone has Mathematica we ported the GNFS complexity calculator to node.js:

var getRSAStrength = require('ssl-rsa-strength');getRSAStrength(2048);

You can use this to measure RSA strength in node.js or any web browser and also to test key sizes not included in NIST's report. The results show a 2048 bit RSA key is equivalent to around 116 'bits' of a symmetric algo. Actually, 116.884, but since, you can't have .884 of a bit our JS implementation rounds down.

Note that NIST also round the GNFS complexity's result down to 112 bits, a common symmetric cipher size, to allow people to apply the same policies they would if they were considering symmetric algorithms. Our JS and the Mathemetica code above give the raw GNFS complexity.

So you're making an RSA key for an HTTPS certificate. What key size do you use? (2)

Strength for common key sizes using GNFS complexity, logarithmic scale.

Note: as mentioned in the tool's README:

The GNFS complexity measurement is a heuristic: it's a tool to help you measure the relative strengths of different RSA key sizes but it is not exact. Implementation details, future vulnerabilities in RSA, and other factors can affect the strength of an RSA key. The attack that breaks RSA 2048 could also break RSA 4096.

Notwithstanding these limitations, GNFS complexity is the best way to measure the raw strength of asymmetric encryption algorithms like RSA.

Measuring the increased load on the server

Bigger RSA key sizes may slow down handshaking from the users point of view. On a Mac or Linux machine you can get some time taken to sign a 2048 bit RSA vs 4096 bit RSA with the openssl speed rsa command:

 sign verify sign/s verify/srsa 512 bits 0.000210s 0.000014s 4772.1 69667.5rsa 1024 bits 0.000727s 0.000035s 1375.3 28508.9rsa 2048 bits 0.003778s 0.000092s 264.7 10899.5rsa 4096 bits 0.022637s 0.000305s 44.2 3275.4

So you're making an RSA key for an HTTPS certificate. What key size do you use? (3)

Looking at the results, it's pretty clear:

4096 bit handshakes are indeed significantly slower in terms of CPU usage than 2048 bit handshakes.

Keep in mind handshakes are brief: after key exchange with RSA, the browser and server have agreed on session key, and a fast symmetric encryption algo like AES is used.

Measuring browser handshakes

We can also do a more practical test by reconfiguring a webserver with 2048 and 4096 bits keys and then measuring the SSL handshake time in Chrome:

So you're making an RSA key for an HTTPS certificate. What key size do you use? (4)

Running 5 test each on both key sizes, with the browser process restarted in between, returned:

  • An average handshake of 50ms with a 2048 bit RSA key
  • An average handshake of 76ms with a 4096 bit RSA key

So you're making an RSA key for an HTTPS certificate. What key size do you use? (5)

The added latency of the 4096 bit key was definitely noticeable, but handshaking was still quite fast.

Google want most pages to load within 100ms, Amazon find that every additional 100ms causes a drop in sales. Handshakes block everything - if your site is set up correctly, everything will be loaded by HTTPS and not a single resource will start loading until the handshake is complete.

But whether 25ms - 25/1000ths of a second is an issue depends on your site. Many websites - including ours - have a lot of optimisation to do before handshake latency becomes an issue.

We will run this test on a less powerful mobile device in future.

4096 bit compatibility concerns

AWS users should also keep in mind Amazon CloudFront also only support 2048 bit keys.Cisco IOS XE prior to Release 2.4 and Cisco IOS Release 15.1(1)T do not support 4096 bit keys

Summary

So... what do we think:

Per the introduction, you should definitely pick at least a 2048 bit key: the makers of openssl, Microsoft, and every web browser are pushing you to use a 2048 bit key at minimum.

Should you use 4096 bit keys? Let's consider our results:

  • A 4096 bit key does provide a reasonable increase in strength over a 2048 bit key, and according to the GNFS complexity, encryption strength doesn't drop off after 2048 bits.
  • There's a significant increase in CPU usage for the brief time of handshaking as a result of a 4096 bit key
  • There's a small increase in browser response for the brief time of handshaking as a result of a 4096 bit key

You can replicate the results of the above tests easily and should do so.

There's no hard answer here but some points:

  • Your server and openssl version is different to the one used in testing, and as time goes on, browsers march forward. Run your own tests and get your own results.
  • Consider other factors beyond strength and performance: there may be other attacks against RSA that come into play by the time you make a decision. As we've seen elsewhere, bit length isn't the only aspect to how secure a given implementation is
  • Keep in mind an EV cert on your web server lasts two years before you need to get re-verified. If for some reason you want to change your bit length before it expires, you can re-key your certificate for free - some SSL vendors charge for this, but we don't.

OK, but what will we, CertSimple, do?

  • Are we going to re-key our own certificate to 4096 bit?
  • Should we change the bash/powershell CertSimple generates to be 4096 bits by default?

No. We can re-key pretty quickly, so deploying a 4096 bit key would be pretty easy, but we feel like a 2048 bit key provides a reasonable speed/security/compatibility tradeoff - as we might move to AWS in future, the last one is also a concern for us.

On the other hand, what do we think about using a 4096 bit key? Is 4096 bit RSA horrible and slow? No. Looking at the results, the server CPU use and additional latency could be reasonable for some sites that desire the gain in strength.

Note: a previous version of the article mentioned 'there are theoretically 2^112 possibilities to brute force the private key' - this was incorrect. There are theoretically 2^112 possibilities to crack the private key using techniques other than brute force. Thanks to dchest on Hacker News for pointing out the error.

So you're making an RSA key for an HTTPS certificate. What key size do you use? (2024)

FAQs

So you're making an RSA key for an HTTPS certificate. What key size do you use? ›

When you're using CloudFront alternate domain names and HTTPS, the maximum size of the public key in an SSL/TLS RSA certificate is 2048 bits. (This is the key size, not the number of characters in the public key.)

What RSA key size should I use? ›

Since 2015, NIST recommends a minimum of 2048-bit keys for RSA, an update to the widely-accepted recommendation of a 1024-bit minimum since at least 2002.

Should I use 2048 or 4096? ›

A 4096 bit key does provide a reasonable increase in strength over a 2048 bit key, and according to the GNFS complexity, encryption strength doesn't drop off after 2048 bits. There's a significant increase in CPU usage for the brief time of handshaking as a result of a 4096 bit key.

What is the difference between 1024 and 2048 RSA key size? ›

Referencing the table linked above, a 1024-bit key has approximately 80 bits of strength, while a 2048-bit key has approximately 112 bits. Thus, it takes approximately 2112/280 = 232 times as long to factor a 2048-bit key. In other words, it takes around four billion times longer to factor a 2048-bit key.

What is 2048 in RSA 2048? ›

RSA-2048 has 617 decimal digits (2,048 bits). It is the largest of the RSA numbers and carried the largest cash prize for its factorization, $200,000. The RSA-2048 may not be factorizable for many years to come, unless considerable advances are made in integer factorization or computational power in the near future.

Does https use RSA? ›

No, both are very different. RSA is a cryptographic primitive while HTTPS is an application level protocol in the OSI layer definition.

What is the difference between key size 128 and 256? ›

A 128-bit level of encryption has 2128 possible key combinations (340,282,366,920,938,463,463,374,607,431,768,211,456 – 39 digits long) and 256-bit AES encryption has 2256 possible key combinations (a number 78 digits long).

How long does it take to crack a 2048 bit RSA key? ›

With existing computing technology, one estimate holds it would take 300 trillion years to “brute force” an RSA 2048-bit key. Other estimates measure the time to execute brute force attacks on today's public key encryption in decades.

Is 1024-bit RSA secure? ›

Encryption algorithms using 1024-bit keys are no longer secure, due to the emergence of 'trapdoored' primes. Expert Michael Cobb explains how the encryption backdoor works. The National Institute of Standards and Technology (NIST) has recommended minimum key sizes of 2048-bits for the...

What is the signature size of RSA 2048? ›

The signature is 1024-bit integer (128 bytes, 256 hex digits). This signature size corresponds to the RSA key size.

Is RSA encryption 1024 or 2048? ›

If you want to use RSA encryption, make sure that you are using a key of at least 1024 bits. Those with higher threat models should stick to keys of 2048 or 4096 bits if they want to use RSA with confidence.

Why does an RSA key need to be so large? ›

RSA can work with keys of different keys of length: 1024, 2048, 3072, 4096, 8129, 16384 or even more bits. Key length of 3072-bits and above are considered secure. Longer keys provide higher security but consume more computing time, so there is a tradeoff between security and speed.

How to generate RSA 2048 key? ›

  1. Generate an RSA keypair with a 2048 bit private keyEdit. Execute command: "openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048" (previously “openssl genrsa -out private_key.pem 2048”) ...
  2. Extracting the public key from an RSA keypairEdit. ...
  3. Viewing the key elementsEdit.

How hard is it to crack RSA-2048? ›

We estimate that a quantum circuit with 372 physical qubits and a depth of thousands is necessary to challenge RSA-2048 using our algorithm. The worrying part of this statement is that there are companies that are creating quantum computers that are likely to release 1,000 qubit+ processors by 2025.

How safe is RSA 4096? ›

RSA-4096 is a legitimate encryption cipher. It is one of the best encryption systems that you can use to protect your data in transmission.

Can RSA-2048 be broken? ›

The basic claim of the paper, published last Christmas by 24 Chinese researchers, is that they have found an algorithm that enables 2,048-bit RSA keys to be broken even with the relatively low-power quantum computers available today.

What is the RSA key length of HTTPS? ›

When you're using CloudFront alternate domain names and HTTPS, the maximum size of the public key in an SSL/TLS RSA certificate is 2048 bits. (This is the key size, not the number of characters in the public key.)

What encryption is used for HTTPS? ›

HTTPS uses an encryption protocol to encrypt communications. The protocol is called Transport Layer Security (TLS), although formerly it was known as Secure Sockets Layer (SSL). This protocol secures communications by using what's known as an asymmetric public key infrastructure.

What level of encryption is HTTPS? ›

HTTPS Encryption Strength: Server Configuration

Most of today's SSL/TLS certificates offer 256-bit encryption strength. This is great as it's almost impossible to crack the standard 256-bit cryptographic key.

How long does it take to crack RSA 1024? ›

Assuming they used the General number field sieve (a very fair assumption) it would take them 7481 years to crack a 1024 bit number using the same hardware. Or using only your i7 with this algorithm: about 3 million years.

How long does it take to crack 4096 bit RSA? ›

For concreteness, in the following we consider even larger keys, of size 4096 bit (and 2048-bit primes), which should be secure beyond the year 2031 [BBB+12]. We show an attack that can extract whole 4096-bit RSA keys within about one hour using just the acoustic emanations from the target machine.

Does the key size matter? ›

Provided that an encryption algorithm actually supports different key lengths, the general rule is that the longer the key, the better.

How long does it take to crack a 512-bit RSA key? ›

> > 2003 ("within three years") a 512-bit key can be factored in a few days. > this latter case, you are still looking at 2-3 years to crack the key. key may be broken in a day. breaking the key variable protecting it can be profitable.

How long to crack 512-bit RSA? ›

1999 was the year when the first 512-bit general factorization was performed, on a challenge published by RSA (the company) and called RSA-155 (because the number consisted in 155 decimal digits -- in binary, the length is 512 bits). That factorization took 6 months.

What is the longest broken RSA key? ›

The future of 2,048-bit encryption. Although it's estimated that a 1,024-bit RSA key won't be broken within the next five years (768 bits is the largest RSA key known to have been cracked), it's only considered equivalent to 80 bits of security.

Why not to use RSA? ›

Simply, RSA is very resource expensive algorithm, it takes time to generate RSA keys and to perform operations on these enormous prime numbers. As the size of data increases, the process load increases and the whole thing ends up taking too much time to complete.

Is RSA still used today? ›

No, RSA Encryption Isn't Obsolete | American Enterprise Institute - AEI.

What is the largest encryption key? ›

Advanced Encryption Standard (AES) keys are symmetric keys that can be three different key lengths (128, 192, or 256 bits). AES is the encryption standard that is recognized and recommended by the US government. The 256-bit keys are the longest allowed by AES.

What is the minimum key size of 2048 bits for RSA key exchanges? ›

Key exchanges should provide at least 112 bits of security, which translates to a minimum key size of 2048 bits for Diffie Hellman and RSA key exchanges. IMPACT: An attacker with access to sufficient computational power might be able to recover the session key and decrypt session content.

How do you tell if a certificate is 1024 or 2048? ›

Go to the Security tab and click on View Certificate.
  1. You'll see three tabs on the top of the page.
  2. The first would be the website's name. ...
  3. In the Public Key Info, you'll see information relating to the algorithm (in this example, it's the RSA algorithm) and the SSL key size (which is 2048 bits for digicert.com).

How to generate RSA 4096 key? ›

Generating an SSH key pair

Open your terminal and run the following command, using your own email address: $ ssh-keygen -t rsa -b 4096 -C "you@example.com" Generating public/private rsa key pair. When the key pair was created, you're asked to enter a filename where to save the key.

Has RSA 1024 been cracked? ›

With a small cluster of 81 Pentium 4 chips and 104 hours of processing time, they were able to successfully hack 1024-bit encryption in OpenSSL on a SPARC-based system, without damaging the computer, leaving a single trace or ending human life as we know it.

What happens if an RSA public key is too large to be factored? ›

If an RSA public key is too large to be factored, then it shows that the RSA algorithm is cryptographically secure and cannot be attacked (in the attacker's lifetime).

What is the block size of RSA? ›

The block size is equal to the number of bytes of the RSA modulus. If the modulus is k bytes long, then the encrypted output size is always k. For the “NoPadding” mode, the plaintext input must be equal to or less than k; with the “PKCS1Padding” mode, the plaintext input must be equal to or less than k-11 bytes.

Is RSA 4096 safe? ›

RSA-4096 is a legitimate encryption cipher. It is one of the best encryption systems that you can use to protect your data in transmission.

What is the difference between 2048 and 4096 key size in Salesforce? ›

Select a key size for your generated certificate and keys. Certificates with 2048-bit keys last one year and are faster than certificates with 4096-bit keys. Certificates with 4096-bit keys last two years. Note After you save a Salesforce certificate, you can't change its type or key size.

Is 128-bit encryption good enough? ›

If you ask how long will it take to crack 128-bit encryption using a brute force attack, the answer would be 1 billion years. A machine that can crack a DES key in a second would take 149 trillion years to crack a 128-bit AES key. Hence, it is safe to say that AES-128 encryption is safe against brute-force attacks.

What is the difference between SSH 1024 and 2048? ›

There are no performance differences between 1024 and 2048 key. Generate RSA keys. You can use the RSA keys for SSH protocol 1 and 2 versions. DSA keys for use only SSH protocol version 2.

Is RSA 1024 still secure? ›

Encryption algorithms using 1024-bit keys are no longer secure, due to the emergence of 'trapdoored' primes. Expert Michael Cobb explains how the encryption backdoor works. The National Institute of Standards and Technology (NIST) has recommended minimum key sizes of 2048-bits for the...

How secure is 2048 bit RSA key? ›

A 2048-bit RSA key provides 112-bit of security. Given that TLS certificates are valid for a maximum of one year, 2048-bit RSA key length fulfills the NIST recommendation until late in this decade.

How long would it take to crack RSA 4096? ›

We show an attack that can extract whole 4096-bit RSA keys within about one hour using just the acoustic emanations from the target machine. The choice of the size of the 4096 bit number is more as a Proof of Concept that it is possible to do it with big number.

What is the size of RSA certificate? ›

When you're using CloudFront alternate domain names and HTTPS, the maximum size of the public key in an SSL/TLS RSA certificate is 2048 bits. (This is the key size, not the number of characters in the public key.)

Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 5732

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.