3 Generation of DSA keypairs
5 Copyright (C) 2002, 2014 Niels Möller
7 This file is part of GNU Nettle.
9 GNU Nettle is free software: you can redistribute it and/or
10 modify it under the terms of either:
12 * the GNU Lesser General Public License as published by the Free
13 Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
18 * the GNU General Public License as published by the Free
19 Software Foundation; either version 2 of the License, or (at your
20 option) any later version.
22 or both in parallel, as here.
24 GNU Nettle is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
29 You should have received copies of the GNU General Public License and
30 the GNU Lesser General Public License along with this program. If
31 not, see http://www.gnu.org/licenses/.
41 #include "dsa-compat.h"
45 /* Undo name mangling */
46 #undef dsa_generate_keypair
47 #define dsa_generate_keypair nettle_dsa_generate_keypair
49 /* Valid sizes, according to FIPS 186-3 are (1024, 160), (2048, 224),
50 (2048, 256), (3072, 256). */
52 dsa_compat_generate_keypair(struct dsa_public_key *pub,
53 struct dsa_private_key *key,
54 void *random_ctx, nettle_random_func *random,
55 void *progress_ctx, nettle_progress_func *progress,
56 unsigned p_bits, unsigned q_bits)
58 struct dsa_params *params;
63 if (p_bits < DSA_SHA1_MIN_P_BITS)
68 if (p_bits < DSA_SHA256_MIN_P_BITS)
75 /* NOTE: Depends on identical layout! */
76 params = (struct dsa_params *) pub;
78 if (!dsa_generate_params (params,
80 progress_ctx, progress,
84 dsa_generate_keypair (params, pub->y, key->x, random_ctx, random);