File indexing completed on 2025-01-18 10:02:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef NETTLE_DSA_H_INCLUDED
0035 #define NETTLE_DSA_H_INCLUDED
0036
0037 #include "nettle-types.h"
0038 #include "bignum.h"
0039
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043
0044
0045 #define dsa_params_init nettle_dsa_params_init
0046 #define dsa_params_clear nettle_dsa_params_clear
0047 #define dsa_signature_init nettle_dsa_signature_init
0048 #define dsa_signature_clear nettle_dsa_signature_clear
0049 #define dsa_sign nettle_dsa_sign
0050 #define dsa_verify nettle_dsa_verify
0051 #define dsa_generate_params nettle_dsa_generate_params
0052 #define dsa_generate_keypair nettle_dsa_generate_keypair
0053 #define dsa_signature_from_sexp nettle_dsa_signature_from_sexp
0054 #define dsa_keypair_to_sexp nettle_dsa_keypair_to_sexp
0055 #define dsa_keypair_from_sexp_alist nettle_dsa_keypair_from_sexp_alist
0056 #define dsa_sha1_keypair_from_sexp nettle_dsa_sha1_keypair_from_sexp
0057 #define dsa_sha256_keypair_from_sexp nettle_dsa_sha256_keypair_from_sexp
0058 #define dsa_params_from_der_iterator nettle_dsa_params_from_der_iterator
0059 #define dsa_public_key_from_der_iterator nettle_dsa_public_key_from_der_iterator
0060 #define dsa_openssl_private_key_from_der_iterator nettle_dsa_openssl_private_key_from_der_iterator
0061 #define dsa_openssl_private_key_from_der nettle_openssl_provate_key_from_der
0062
0063
0064 #define DSA_SHA1_MIN_P_BITS 512
0065 #define DSA_SHA1_Q_OCTETS 20
0066 #define DSA_SHA1_Q_BITS 160
0067
0068 #define DSA_SHA256_MIN_P_BITS 1024
0069 #define DSA_SHA256_Q_OCTETS 32
0070 #define DSA_SHA256_Q_BITS 256
0071
0072 struct dsa_params
0073 {
0074
0075 mpz_t p;
0076
0077
0078 mpz_t q;
0079
0080
0081 mpz_t g;
0082 };
0083
0084 void
0085 dsa_params_init (struct dsa_params *params);
0086
0087 void
0088 dsa_params_clear (struct dsa_params *params);
0089
0090 struct dsa_signature
0091 {
0092 mpz_t r;
0093 mpz_t s;
0094 };
0095
0096
0097 void
0098 dsa_signature_init(struct dsa_signature *signature);
0099
0100
0101 void
0102 dsa_signature_clear(struct dsa_signature *signature);
0103
0104 int
0105 dsa_sign(const struct dsa_params *params,
0106 const mpz_t x,
0107 void *random_ctx, nettle_random_func *random,
0108 size_t digest_size,
0109 const uint8_t *digest,
0110 struct dsa_signature *signature);
0111
0112 int
0113 dsa_verify(const struct dsa_params *params,
0114 const mpz_t y,
0115 size_t digest_size,
0116 const uint8_t *digest,
0117 const struct dsa_signature *signature);
0118
0119
0120
0121
0122 int
0123 dsa_generate_params(struct dsa_params *params,
0124 void *random_ctx, nettle_random_func *random,
0125 void *progress_ctx, nettle_progress_func *progress,
0126 unsigned p_bits, unsigned q_bits);
0127
0128 void
0129 dsa_generate_keypair (const struct dsa_params *params,
0130 mpz_t pub, mpz_t key,
0131 void *random_ctx, nettle_random_func *random);
0132
0133
0134
0135 struct nettle_buffer;
0136
0137
0138 int
0139 dsa_keypair_to_sexp(struct nettle_buffer *buffer,
0140 const char *algorithm_name,
0141 const struct dsa_params *params,
0142 const mpz_t pub,
0143 const mpz_t priv);
0144
0145 struct sexp_iterator;
0146
0147 int
0148 dsa_signature_from_sexp(struct dsa_signature *rs,
0149 struct sexp_iterator *i,
0150 unsigned q_bits);
0151
0152 int
0153 dsa_keypair_from_sexp_alist(struct dsa_params *params,
0154 mpz_t pub,
0155 mpz_t priv,
0156 unsigned p_max_bits,
0157 unsigned q_bits,
0158 struct sexp_iterator *i);
0159
0160
0161
0162
0163
0164 int
0165 dsa_sha1_keypair_from_sexp(struct dsa_params *params,
0166 mpz_t pub,
0167 mpz_t priv,
0168 unsigned p_max_bits,
0169 size_t length, const uint8_t *expr);
0170
0171 int
0172 dsa_sha256_keypair_from_sexp(struct dsa_params *params,
0173 mpz_t pub,
0174 mpz_t priv,
0175 unsigned p_max_bits,
0176 size_t length, const uint8_t *expr);
0177
0178
0179 struct asn1_der_iterator;
0180
0181 int
0182 dsa_params_from_der_iterator(struct dsa_params *params,
0183 unsigned max_bits, unsigned q_bits,
0184 struct asn1_der_iterator *i);
0185
0186 int
0187 dsa_public_key_from_der_iterator(const struct dsa_params *params,
0188 mpz_t pub,
0189 struct asn1_der_iterator *i);
0190
0191 int
0192 dsa_openssl_private_key_from_der_iterator(struct dsa_params *params,
0193 mpz_t pub,
0194 mpz_t priv,
0195 unsigned p_max_bits,
0196 struct asn1_der_iterator *i);
0197
0198 int
0199 dsa_openssl_private_key_from_der(struct dsa_params *params,
0200 mpz_t pub,
0201 mpz_t priv,
0202 unsigned p_max_bits,
0203 size_t length, const uint8_t *data);
0204
0205
0206 #ifdef __cplusplus
0207 }
0208 #endif
0209
0210 #endif