ssl_common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef SSL_COMMON_H_INCLUDED
  2. #define SSL_COMMON_H_INCLUDED
  3. /*********************************************************************
  4. *
  5. * File : $Source: /cvsroot/ijbswa/current/ssl_common.h,v $
  6. *
  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.
  10. *
  11. * Copyright : Written by and Copyright (c) 2017 Vaclav Svec. FIT CVUT.
  12. *
  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.
  18. *
  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.
  24. *
  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.
  30. *
  31. *********************************************************************/
  32. #include "project.h"
  33. #define RSA_KEY_PUBLIC_EXPONENT 65537 /* Public exponent for RSA private key generating */
  34. #define RSA_KEYSIZE 2048 /* Size of generated RSA keys */
  35. #define ERROR_BUF_SIZE 1024 /* Size of buffer for error messages */
  36. #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 */
  37. #define KEY_FILE_TYPE ".pem"
  38. #define CERT_FILE_TYPE ".crt"
  39. #define CERT_PARAM_COMMON_NAME_FCODE "CN"
  40. #define CERT_PARAM_ORGANIZATION_FCODE "O"
  41. #define CERT_PARAM_ORG_UNIT_FCODE "OU"
  42. #define CERT_PARAM_COUNTRY_FCODE "C"
  43. #define CERT_PARAM_COUNTRY_CODE "CZ"
  44. #define CERT_SUBJECT_PASSWORD ""
  45. #define CERT_INFO_PREFIX ""
  46. /*
  47. * Properties of cert for generating
  48. */
  49. typedef struct {
  50. char *issuer_crt; /* filename of the issuer certificate */
  51. char *subject_key; /* filename of the subject key file */
  52. char *issuer_key; /* filename of the issuer key file */
  53. const char *subject_pwd; /* password for the subject key file */
  54. const char *issuer_pwd; /* password for the issuer key file */
  55. char *output_file; /* where to store the constructed key file */
  56. const char *subject_name; /* subject name for certificate */
  57. char issuer_name[ISSUER_NAME_BUF_SIZE]; /* issuer name for certificate */
  58. const char *not_before; /* validity period not before */
  59. const char *not_after; /* validity period not after */
  60. const char *serial; /* serial number string */
  61. int is_ca; /* is a CA certificate */
  62. int max_pathlen; /* maximum CA path length */
  63. } cert_options;
  64. extern void free_certificate_chain(struct client_state *csp);
  65. extern int file_exists(const char *path);
  66. extern char *make_certs_path(const char *conf_dir, const char *file_name,
  67. const char *suffix);
  68. extern unsigned long get_certificate_serial(struct client_state *csp);
  69. extern int get_certificate_valid_from_date(char *buffer, size_t buffer_size, const char *fmt);
  70. extern int get_certificate_valid_to_date(char *buffer, size_t buffer_size, const char *fmt);
  71. extern int host_is_ip_address(const char *host);
  72. #endif /* ndef SSL_COMMON_H_INCLUDED */