2 * Copyright (C) 2003-2012 Free Software Foundation, Inc.
4 * This file is part of GnuTLS.
6 * GnuTLS is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuTLS is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #ifndef CERTTOOL_COMMON_H
22 #define CERTTOOL_COMMON_H
24 #include <gnutls/x509.h>
30 void certtool_version(void);
32 #include <gnutls/x509.h>
33 #include <gnutls/abstract.h>
35 typedef struct common_info {
36 const char *secret_key;
46 const char *ca_privkey;
48 const char *sec_param;
49 const char *pkcs_cipher;
53 unsigned int crq_extensions;
65 gnutls_pubkey_t load_public_key_or_import(int mand,
66 gnutls_privkey_t privkey,
67 common_info_st * info);
68 gnutls_privkey_t load_private_key(int mand, common_info_st * info);
69 gnutls_x509_privkey_t load_x509_private_key(int mand,
70 common_info_st * info);
71 gnutls_x509_privkey_t *load_privkey_list(int mand, size_t * privkey_size,
72 common_info_st * info);
73 gnutls_x509_crq_t load_request(common_info_st * info);
74 gnutls_privkey_t load_ca_private_key(common_info_st * info);
75 gnutls_x509_crt_t load_ca_cert(unsigned mand, common_info_st * info);
76 gnutls_x509_crt_t load_cert(int mand, common_info_st * info);
77 gnutls_datum_t *load_secret_key(int mand, common_info_st * info);
78 gnutls_pubkey_t load_pubkey(int mand, common_info_st * info);
79 gnutls_x509_crt_t *load_cert_list(int mand, size_t * size,
80 common_info_st * info);
81 int get_bits(gnutls_pk_algorithm_t key_type, int info_bits,
82 const char *info_sec_param, int warn);
84 gnutls_sec_param_t str_to_sec_param(const char *str);
85 gnutls_ecc_curve_t str_to_curve(const char *str);
88 int generate_prime(FILE * outfile, int how, common_info_st * info);
89 void dh_info(FILE * infile, FILE * outfile, common_info_st * ci);
91 gnutls_x509_privkey_t *load_privkey_list(int mand, size_t * privkey_size,
92 common_info_st * info);
94 void _pubkey_info(FILE * outfile, gnutls_certificate_print_formats_t,
95 gnutls_pubkey_t pubkey);
96 void print_ecc_pkey(FILE * outfile, gnutls_ecc_curve_t curve,
97 gnutls_datum_t * k, gnutls_datum_t * x,
98 gnutls_datum_t * y, int cprint);
99 void print_rsa_pkey(FILE * outfile, gnutls_datum_t * m, gnutls_datum_t * e,
100 gnutls_datum_t * d, gnutls_datum_t * p,
101 gnutls_datum_t * q, gnutls_datum_t * u,
102 gnutls_datum_t * exp1, gnutls_datum_t * exp2,
104 void print_dsa_pkey(FILE * outfile, gnutls_datum_t * x, gnutls_datum_t * y,
105 gnutls_datum_t * p, gnutls_datum_t * q,
106 gnutls_datum_t * g, int cprint);
108 FILE *safe_open_rw(const char *file, int privkey_op);
110 const char *get_password(common_info_st * cinfo, unsigned int *flags,
113 extern unsigned char *lbuffer;
114 extern int lbuffer_size;
116 void fix_lbuffer(unsigned);