1 #ifndef SSL_COMMON_H_INCLUDED
2 #define SSL_COMMON_H_INCLUDED
3 /*********************************************************************
5 * File : $Source: /cvsroot/ijbswa/current/ssl_common.h,v $
7 * Purpose : File with TLS/SSL extension. Contains methods for
8 * creating, using and closing TLS/SSL connections that do
9 * not depend on particular TLS/SSL library.
11 * Copyright : Written by and Copyright (c) 2017 Vaclav Svec. FIT CVUT.
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General
15 * Public License as published by the Free Software
16 * Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 * This program is distributed in the hope that it will
20 * be useful, but WITHOUT ANY WARRANTY; without even the
21 * implied warranty of MERCHANTABILITY or FITNESS FOR A
22 * PARTICULAR PURPOSE. See the GNU General Public
23 * License for more details.
25 * The GNU General Public License should be included with
26 * this file. If not, you can view it at
27 * http://www.gnu.org/copyleft/gpl.html
28 * or write to the Free Software Foundation, Inc., 59
29 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 *********************************************************************/
35 #define RSA_KEY_PUBLIC_EXPONENT 65537 /* Public exponent for RSA private key generating */
36 #define RSA_KEYSIZE 2048 /* Size of generated RSA keys */
37 #define ERROR_BUF_SIZE 1024 /* Size of buffer for error messages */
38 #define INVALID_CERT_INFO_BUF_SIZE 2048 /* Size of buffer for message with information about reason of certificate invalidity. Data after the end of buffer will not be saved */
39 #define KEY_FILE_TYPE ".pem"
40 #define CERT_FILE_TYPE ".crt"
42 #define CERT_PARAM_COMMON_NAME_FCODE "CN"
43 #define CERT_PARAM_ORGANIZATION_FCODE "O"
44 #define CERT_PARAM_ORG_UNIT_FCODE "OU"
45 #define CERT_PARAM_COUNTRY_FCODE "C"
46 #define CERT_PARAM_COUNTRY_CODE "CZ"
47 #define CERT_SUBJECT_PASSWORD ""
50 * Properties of cert for generating
53 char *issuer_crt; /* filename of the issuer certificate */
54 char *subject_key; /* filename of the subject key file */
55 char *issuer_key; /* filename of the issuer key file */
56 const char *subject_pwd; /* password for the subject key file */
57 const char *issuer_pwd; /* password for the issuer key file */
58 char *output_file; /* where to store the constructed key file */
59 const char *subject_name; /* subject name for certificate */
60 char issuer_name[ISSUER_NAME_BUF_SIZE]; /* issuer name for certificate */
61 const char *not_before; /* validity period not before */
62 const char *not_after; /* validity period not after */
63 const char *serial; /* serial number string */
64 int is_ca; /* is a CA certificate */
65 int max_pathlen; /* maximum CA path length */
68 extern void free_certificate_chain(struct client_state *csp);
69 extern int file_exists(const char *path);
70 extern char *make_certs_path(const char *conf_dir, const char *file_name,
72 extern unsigned long get_certificate_serial(struct client_state *csp);
73 extern int get_certificate_valid_from_date(char *buffer, size_t buffer_size, const char *fmt);
74 extern int get_certificate_valid_to_date(char *buffer, size_t buffer_size, const char *fmt);
75 extern int enforce_sane_certificate_state(const char *certificate, const char *key);
77 #endif /* ndef SSL_COMMON_H_INCLUDED */