3 Old DSA publickey interface.
5 Copyright (C) 2002, 2013, 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/.
34 #ifndef NETTLE_DSA_COMPAT_H_INCLUDED
35 #define NETTLE_DSA_COMPAT_H_INCLUDED
43 #define dsa_public_key_init nettle_dsa_public_key_init
44 #define dsa_public_key_clear nettle_dsa_public_key_clear
45 #define dsa_private_key_init nettle_dsa_private_key_init
46 #define dsa_private_key_clear nettle_dsa_private_key_clear
47 #define dsa_sha1_sign nettle_dsa_sha1_sign
48 #define dsa_sha1_verify nettle_dsa_sha1_verify
49 #define dsa_sha256_sign nettle_dsa_sha256_sign
50 #define dsa_sha256_verify nettle_dsa_sha256_verify
51 #define dsa_sha1_sign_digest nettle_dsa_sha1_sign_digest
52 #define dsa_sha1_verify_digest nettle_dsa_sha1_verify_digest
53 #define dsa_sha256_sign_digest nettle_dsa_sha256_sign_digest
54 #define dsa_sha256_verify_digest nettle_dsa_sha256_verify_digest
55 #define dsa_compat_generate_keypair nettle_dsa_compat_generate_keypair
57 /* Switch meaning of dsa_generate_keypair */
58 #undef dsa_generate_keypair
59 #define dsa_generate_keypair nettle_dsa_compat_generate_keypair
67 /* Same as struct dsa_params, but can't use that struct here without
68 breaking backwards compatibility. Layout must be identical, since
69 this is cast to a struct dsa_param pointer for calling _dsa_sign
79 struct dsa_private_key
81 /* Unlike an rsa public key, private key operations will need both
82 * the private and the public information. */
86 /* Signing a message works as follows:
88 * Store the private key in a dsa_private_key struct.
90 * Initialize a hashing context, by callling
93 * Hash the message by calling
96 * Create the signature by calling
99 * The signature is represented as a struct dsa_signature. This call also
100 * resets the hashing context.
102 * When done with the key and signature, don't forget to call
103 * dsa_signature_clear.
106 /* Calls mpz_init to initialize bignum storage. */
108 dsa_public_key_init(struct dsa_public_key *key);
110 /* Calls mpz_clear to deallocate bignum storage. */
112 dsa_public_key_clear(struct dsa_public_key *key);
115 /* Calls mpz_init to initialize bignum storage. */
117 dsa_private_key_init(struct dsa_private_key *key);
119 /* Calls mpz_clear to deallocate bignum storage. */
121 dsa_private_key_clear(struct dsa_private_key *key);
124 dsa_sha1_sign(const struct dsa_public_key *pub,
125 const struct dsa_private_key *key,
126 void *random_ctx, nettle_random_func *random,
127 struct sha1_ctx *hash,
128 struct dsa_signature *signature);
131 dsa_sha256_sign(const struct dsa_public_key *pub,
132 const struct dsa_private_key *key,
133 void *random_ctx, nettle_random_func *random,
134 struct sha256_ctx *hash,
135 struct dsa_signature *signature);
138 dsa_sha1_verify(const struct dsa_public_key *key,
139 struct sha1_ctx *hash,
140 const struct dsa_signature *signature);
143 dsa_sha256_verify(const struct dsa_public_key *key,
144 struct sha256_ctx *hash,
145 const struct dsa_signature *signature);
148 dsa_sha1_sign_digest(const struct dsa_public_key *pub,
149 const struct dsa_private_key *key,
150 void *random_ctx, nettle_random_func *random,
151 const uint8_t *digest,
152 struct dsa_signature *signature);
154 dsa_sha256_sign_digest(const struct dsa_public_key *pub,
155 const struct dsa_private_key *key,
156 void *random_ctx, nettle_random_func *random,
157 const uint8_t *digest,
158 struct dsa_signature *signature);
161 dsa_sha1_verify_digest(const struct dsa_public_key *key,
162 const uint8_t *digest,
163 const struct dsa_signature *signature);
166 dsa_sha256_verify_digest(const struct dsa_public_key *key,
167 const uint8_t *digest,
168 const struct dsa_signature *signature);
172 dsa_generate_keypair(struct dsa_public_key *pub,
173 struct dsa_private_key *key,
175 void *random_ctx, nettle_random_func *random,
176 void *progress_ctx, nettle_progress_func *progress,
177 unsigned p_bits, unsigned q_bits);
183 #endif /* NETTLE_DSA_COMPAT_H_INCLUDED */