Sign up ×

How does the length of the RSA key and the size of the document affect the time it takes to sign a document using SHA-1 and RSA?

I used CrypTool to check it, but the time does not appear to be larger for big documents. I don't know whether it is problem with CrypTool or the way I used it (maybe I used too small documents).

share|improve this question
Welcome to the board. Perhaps it's just me but I have no clue what you're asking. Please clarify. – bangdang May 9 '12 at 19:13
I tried to improve your English. Because your question was hard to understand, please verify that I understood it correctly. – Gilles May 9 '12 at 21:05

2 Answers 2

up vote 2 down vote accepted

Generally, with a digital signature for an asymmetric key (such as RSA) - the signature is created over the hash (SHA-1). The hash creates a fixed size data block (SHA-1 - 160 bits) which is the input to the asymmetric encryption function.

Hash functions - by and large - are created to execute quite quickly. By quickly, it's generally linearly proportional to the size of the input. Chances are fairly good that on an average computer, with a decently written API for your hash function, you will have trouble seeing a big difference without a dramatic change in file size. Hash functions are built for efficiency, and hash library makers do a decent job of keeping these optimized for the operating system and CPU. My suspicision (with the test set sizes unknown) is that you have a calibration problem - CrypTool is unlikely to be able to measure the variations in time to proccess the input because the delta between "fast" and "slow" is too minor to be measurable.

Your RSA key pair size WILL NOT change - to change the size of your key pair, you have to generate a new key and identify that new key pair as the input to the signature. Here's a nice paper on how bigger RSA key sizes will impact signature generation and verification.

No matter what the size of your RSA signature key is, the input length of the data will be 160b due to the fact that you are using SHA-1 to hash the data before sending it for signature. So once a key pair is determined, if you are measuring only the execution of the RSA algorithn, you won't see any difference in processing time (unless it's also affected by other operations occuring on your system) due to differences in the input data to be signed.

share|improve this answer
Great answer. Thanks you very much. But tell How does it affect size of sent document? – kspacja May 9 '12 at 19:53
Depends on the format for how the signature is appended, but just like the input to the signature is a fixed size, so is the output. So a signed document is usually the size of the original document + a fixed size for the signature. – bethlakshmi May 9 '12 at 20:29

Signing a document involves two steps: (1) hash the document, (2) sign the hash using the private key. The running time is the sum of the running times of each step.

The running time to hash the document will generally be very fast, and depends linearly upon the size of the document. You should expect that a modern computer can hash a document at a rate of about 100-500 MB/sec (megabytes per second). In other words, for a normal size document, this will be done faster than a human can notice. So, for most purposes, you can disregard the time it takes to hash the document, and consequently, in practice, the length of the document usually will be irrelevant.

The running time to sign the document will be heavily dependent upon the size of your RSA key (the number of bits in the modulus). Here are some example timings: computing a signature might take about 1 millisecond for a 1024-bit RSA key; about 5 milliseconds for a 2048-bit RSA key; or about 30 milliseconds for a 4096-bit RSA. (These numbers are only examples and might be somewhat faster or slower depending upon how fast your particular computer is.) Generally, the bulk of the time computing the signature will be spent on the RSA computation, which is very dependent upon the size of the RSA key. Nonetheless, for the key sizes typically used, this is still faster than a human can notice.

So, for reasonable sized documents and reasonable size RSA keys, the signing operation will likely be so fast that you probably won't notice the time it takes to compute the signature.

share|improve this answer

Your Answer


