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.

ture is valid. A successful check would demonstrate both that the data was not modified<br />

from the time it was signed (message integrity) and that the entity with the<br />

corresponding public key signed the data (authentication).<br />

Solution<br />

Use the verification algorithm that corresponds to the chosen signing algorithm from<br />

Recipe 7.12. Generally, this should be included with your cryptographic library.<br />

Discussion<br />

Recipe 7.12 explains the basic components of digital signatures with RSA. When verifying,<br />

you will generally need to provide the following inputs:<br />

• The signer’s public key.<br />

• The signature to be verified.<br />

• The message digest corresponding to the message you want to authenticate. If<br />

it’s a high-level API, you might be able to provide only the message.<br />

• An indication of the message digest algorithm used in the signing operation.<br />

Again, this may be assumed in a high-level API.<br />

The API should simply return indication of success or failure.<br />

Some implementations of RSA signature verification are susceptible to timing<br />

attacks. Basically, if RSA private key operations do not happen in a fixed amount of<br />

time, such attacks are possible. A technique called blinding can thwart timing<br />

attacks. The amount of time it takes to decrypt is randomized somewhat by operating<br />

on a random number in the process. To eliminate the possibility of such attacks,<br />

you should always turn blinding on before doing a signature validation operation.<br />

With OpenSSL, blinding can be enabled with by calling RSA_blinding_on( ), which<br />

has the following signature:<br />

int RSA_blinding_on(RSA *r, BN_CTX *x);<br />

This function has the following arguments:<br />

r<br />

RSA object for which blinding should be enabled.<br />

x<br />

BN_CTX object that will be used by the blinding operations as scratch space. (See<br />

Recipe 7.4 for a discussion of BN_CTX objects.) It may be specified as NULL, in<br />

which case a new one will be allocated and used internally.<br />

The OpenSSLanalog to RSA_sign( ) (discussed in Recipe 7.12) is RSA_verify( ),<br />

which has the following signature:<br />

int RSA_verify(int md_type, unsigned char *dgst, unsigned int dlen,<br />

unsigned char *sig, unsigned int siglen, RSA *r);<br />

Verifying Signed Data Using an RSA Public Key | 341<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!