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.

h_ret<br />

Optional argument that, if not specified as NULL, will have the number of iterations<br />

the function went through to find a suitable generator stored in it.<br />

callback<br />

Pointer to a function that will be called by BN_generate_prime( ) to report status<br />

when generating the primes p and q. It may be specified as NULL, in which case<br />

no progress will be reported. See Recipe 7.4 for a discussion of BN_generate_<br />

prime( ).<br />

cb_arg<br />

Application-specific value that will be passed directly to the callback function for<br />

progress reporting if one is specified.<br />

Note that DSA_generate_parameters( ) does not generate an actual key pair. Parameter<br />

sets can be reused across multiple users; key pairs cannot. An OpenSSL DSA object<br />

with the parameters set properly can be used to generate a key pair with the function<br />

DSA_generate_key( ), which will allocate and load BIGNUM objects for the pub_key and<br />

priv_key fields. It returns 1 on success.<br />

int DSA_generate_key(DSA *ctx);<br />

With OpenSSL, there is an optional precomputation step to DSA signing. Basically,<br />

for each message you sign, DSA requires you to select a random value and perform<br />

some expensive math operations on that value. You can do this precomputation<br />

before there’s actually data to sign, or you can wait until you have data to sign,<br />

which will slow down the signature process.<br />

To maintain security, the results of precomputation can only be used<br />

for a single signature. You can precompute again before the next signature,<br />

though.<br />

DSA signature precomputation is a two-step process. First, you use DSA_sign_setup( ),<br />

which will actually perform the precomputation of two values, kinv and r:<br />

int DSA_sign_setup(DSA *dsa, BN_CTX *ctx, BIGNUM **kinvp, BIGNUM **rp);<br />

This function has the following arguments:<br />

dsa<br />

ctx<br />

Context object containing the parameters and the private key that will be used<br />

for signing.<br />

Optional BN_CTX object that will be used for scratch space (see Recipe 7.4). If it is<br />

specified as NULL, DSA_sign_setup( ) will internally create its own BN_CTX object<br />

and free it before returning.<br />

Using the Digital Signature Algorithm (DSA) | 349<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!