I have an application which consists of a client and a server. Both have a pair of public and private key (RSA). For communication, both sign their messages and send them to the other part. So a message Looks like this:

| HTTP Post request |
|     Post data     |
|     Signature     |

The post data is signed with the private key and the signature is added to the data. Sometimes the post data is very small (sometimes it just contains one number).

I know it can impact performance very much if I sign every little piece of data, but this time I'm not concerned too much about performance as the frequency of signing is very low.

Can it cause security problems if I sign very small amount of data such as just one number?

  • $\begingroup$ Are you using proper padding, like PSS? $\endgroup$ – CodesInChaos Aug 12 '15 at 7:20
  • $\begingroup$ Related: crypto.stackexchange.com/questions/1807/… $\endgroup$ – otus Aug 12 '15 at 7:28
  • $\begingroup$ @CodesInChaos: I'm using phpseclib which uses PSS. So yes, I guess I'm using proper padding. I do the same as in the phpseclib examples: phpseclib.sourceforge.net/rsa/examples.html $\endgroup$ – Thomas Sparber Aug 12 '15 at 7:45
  • 1
    $\begingroup$ Consider using HTTPS/SSL/TLS to secure the connection in addition to your signature scheme. $\endgroup$ – CodesInChaos Aug 12 '15 at 13:25
  • $\begingroup$ @CodesInChaos: Thanks for the tip, I will do that! $\endgroup$ – Thomas Sparber Aug 12 '15 at 13:53

If you are using a secure signature algorithm, padding and all, then it must be secure for messages of any length. So in that sense you are good.

However, in many protocols your messages must include something to prevent replay attacks, like an incrementing counter, in which case you shouldn't be signing just a single number if the messages are meant to say anything at all.


If you were not padding your message properly, and just signing the message by raising it the power of d you would actually be introducing a potential signature forgery vulnerability. If you were padding properly, or performing the method where you hash the message, and have the specific header, there would be no vulnerability.

The vulnerability on plain RSA is as follows: $s_1$ is the signature of $m_1$ , and $s_2$ is the signature of $m_2$. Since this is plain RSA, $s_i = {m_i}^{d}$, if you multiply $s_1$ and $s_2$ together, you get the signature of $m_1 * m_2$, since

$$s_1 * s_2 = ({m_1}^{d})({m_2}^{d}) = (m_1 m_2)^d$$

You can thus get the signature of any number that only has m_1, and m_2 as its factors. So with the signature of 2,3,5,7 an attacker could forge the signature of any 7-Smooth number. (A number which can be completely factored into a product of primes <= 7)

The more messages they receive, the more messages they can forge.

Thus use a proper padding scheme, or proper signing algorithm :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.