21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.12 Signing Data Using an RSA Private Key<br />

<strong>Problem</strong><br />

You want to use RSA to digitally sign data.<br />

Solution<br />

Use a well-known one-way hash function to compress the data, then use a digital<br />

signing technique specified in PKCS #1 v2.0 or later. Any good cryptographic library<br />

should have primitives for doing exactly this. OpenSSLprovides both a low-level<br />

interface and a high-level interface, although the high-level interface doesn’t end up<br />

removing any complexity.<br />

Discussion<br />

Digital signing with RSA is roughly equivalent to encrypting with a private key. Basically,<br />

the signer computes a message digest, then encrypts the value with his private<br />

key. The verifier also computes the digest and decrypts the signed value, comparing<br />

the two. Of course, the verifier has to have the valid public key for the entity whose<br />

signature is to be verified, which means that the public key needs to be validated by<br />

some trusted third party or transmitted over a secure medium such as a trusted courier.<br />

Digital signing works because only the person with the correct private key will produce<br />

a “signature” that decrypts to the correct result. An attacker cannot use the<br />

public key to come up with a correct encrypted value that would authenticate properly.<br />

If that were possible, it would end up implying that the entire RSA algorithm<br />

could be broken.<br />

PKCS #1 v2.0 specifies two different signing standards, both of which are assumed to<br />

operate on message digest values produced by standard algorithms. Basically, these<br />

standards dictate how to take a message digest value and produce a “signature.” The<br />

preferred standard is RSASSA-PSS, which is analogous to RSAES-OAEP, the padding<br />

standard used for encryption. It has provable security properties and therefore is no<br />

less robust than the alternative, RSASSA-PKCS1v1.5. * There aren’t any known problems<br />

with the RSASSA-PKCS1v1.5, however, and it is in widespread use. On the<br />

other hand, few people are currently using RSASSA-PSS. In fact, OpenSSLdoesn’t<br />

support RSASSA-PSS. If RSASSA-PSS is available in your cryptographic library, we<br />

* There is a known theoretical problem with RSASSA-PKCS1v1.5, but it is not practical, in that it’s actually<br />

harder to attack the scheme than it is to attack the underlying message digest algorithm when using SHA1.<br />

338 | Chapter 7: Public Key Cryptography<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!