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.

tion during key agreement in Recipe 8.18, using Diffie-Hellman as the key agreement<br />

algorithm.<br />

DSA requires three public parameters in addition to the public key: a very large<br />

prime number, p; a generator, g; and a prime number, q, which is a 160-bit prime<br />

factor of p –1. * Unlike the generator in Diffie-Hellman, the DSA generator is not a<br />

small constant. Instead, it’s a computed value derived from p, q, and a random number.<br />

Most libraries should have a type representing a DSA public key with the same basic<br />

fields. We’ll cover OpenSSL’s API; other APIs should be similar.<br />

OpenSSLdefines a DSA object that can represent both the private key and the public<br />

key in one structure. Here’s the interesting subset of the declaration:<br />

typedef struct {<br />

BIGNUM *p, *q, *g, *pub_key, *priv_key;<br />

} DSA;<br />

The function DSA_generate_parameters( ) will allocate a DSA object and generate a set<br />

of parameters. The new DSA object that it returns can be destroyed with the function<br />

DSA_free( ).<br />

DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len,<br />

int *counter_ret, unsigned long *h_ret,<br />

void (*callback)(int, int, void *), void *cb_arg);<br />

This function has the following arguments:<br />

bits<br />

Size in bits of the prime number to be generated. This value must be a multiple<br />

of 64. The DSA standard only allows values up to 1,024, but it’s somewhat common<br />

to use larger sizes anyway, and OpenSSL supports that.<br />

seed<br />

Optional buffer containing a starting point for the prime number generation<br />

algorithm. It doesn’t seem to speed anything up; we recommend setting it to<br />

NULL.<br />

seed_len<br />

If the starting point buffer is not specified as NULL, this is the length in bytes of<br />

that buffer. If the buffer is specified as NULL, this should be specified as 0.<br />

counter_ret<br />

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

the function went through to find suitable primes for p and q stored in it.<br />

* The size of q does impact security, and higher bit lengths can be useful. However, 160 bits is believed to offer<br />

good security, and the DSA standard currently does not allow for other sizes.<br />

348 | 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!