certtool: use unsigned for bits
[gnutls:gnutls.git] / src / certtool-common.h
1 /*
2  * Copyright (C) 2003-2012 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuTLS.
5  *
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.
10  *
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.
15  *
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/>.
19  */
20
21 #ifndef CERTTOOL_COMMON_H
22 #define CERTTOOL_COMMON_H
23
24 #include <gnutls/x509.h>
25 #include <stdio.h>
26
27 #define TYPE_CRT 1
28 #define TYPE_CRQ 2
29
30 void certtool_version(void);
31
32 #include <gnutls/x509.h>
33 #include <gnutls/abstract.h>
34
35 typedef struct common_info {
36         const char *secret_key;
37         const char *privkey;
38         const char *pubkey;
39         int pkcs8;
40         int incert_format;
41         int outcert_format;
42         const char *cert;
43
44         const char *request;
45         const char *ca;
46         const char *ca_privkey;
47         unsigned bits;
48         const char *sec_param;
49         const char *pkcs_cipher;
50         const char *password;
51         int null_password;
52         int empty_password;
53         unsigned int crq_extensions;
54         unsigned int v1_cert;
55
56         const char *pin;
57         const char *so_pin;
58
59         int cprint;
60
61         unsigned int batch;
62         unsigned int verbose;
63 } common_info_st;
64
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);
83
84 gnutls_sec_param_t str_to_sec_param(const char *str);
85 gnutls_ecc_curve_t str_to_curve(const char *str);
86
87 /* prime.c */
88 int generate_prime(FILE * outfile, int how, common_info_st * info);
89 void dh_info(FILE * infile, FILE * outfile, common_info_st * ci);
90
91 gnutls_x509_privkey_t *load_privkey_list(int mand, size_t * privkey_size,
92                                          common_info_st * info);
93
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,
103                     int cprint);
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);
107
108 FILE *safe_open_rw(const char *file, int privkey_op);
109
110 const char *get_password(common_info_st * cinfo, unsigned int *flags,
111                          int confirm);
112
113 extern unsigned char *lbuffer;
114 extern int lbuffer_size;
115
116 void fix_lbuffer(unsigned);
117
118 #endif