tport_tls.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2005 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef TPORT_TLS_H
  25. /** Defined when <tport_tls.h> has been included. */
  26. #define TPORT_TLS_H
  27. /**@internal
  28. * @file tport_tls.h
  29. * @brief Internal TLS interface
  30. *
  31. * @author Mikko Haataja <ext-Mikko.A.Haataja@nokia.com>
  32. *
  33. * Copyright 2001, 2002 Nokia Research Center. All rights reserved.
  34. *
  35. */
  36. #ifndef SU_TYPES_H
  37. #include <sofia-sip/su_types.h>
  38. #endif
  39. #include "tport_internal.h"
  40. SOFIA_BEGIN_DECLS
  41. #define TLS_MAX_HOSTS (16)
  42. typedef struct tls_s tls_t;
  43. extern char const tls_version[];
  44. typedef struct tls_issues_s {
  45. unsigned policy; /* refer to tport_tag.h, tport_tls_verify_policy */
  46. unsigned verify_depth;/* if 0, revert to default (2) */
  47. unsigned verify_date; /* if 0, notBefore and notAfter dates are ignored */
  48. int configured; /* If non-zero, complain about certificate errors */
  49. char *cert; /* CERT file name. File format is PEM */
  50. char *key; /* Private key file. PEM format */
  51. char *passphrase; /* Passphrase for password protected private key */
  52. char *randFile; /* Seed file for the PRNG (default: tls_seed.dat) */
  53. char *CAfile; /* PEM file of CA's */
  54. char *CApath; /* PEM file path of CA's */
  55. char *ciphers; /* Should be one of the above defined ciphers *
  56. * or NULL (default: !eNULL:!aNULL:!EXP:!LOW:!MD5:ALL:@STRENGTH)
  57. */
  58. int version; /* For tls1, version is 1. When ssl3/ssl2 is
  59. * used, it is 0. */
  60. unsigned timeout; /* Maximum session lifetime in seconds */
  61. } tls_issues_t;
  62. typedef struct tport_tls_s {
  63. tport_t tlstp_tp[1];
  64. tls_t *tlstp_context;
  65. char *tlstp_buffer;
  66. } tport_tls_t;
  67. typedef struct tport_tls_primary_s {
  68. tport_primary_t tlspri_pri[1];
  69. tls_t *tlspri_master;
  70. } tport_tls_primary_t;
  71. tls_t *tls_init_master(tls_issues_t *tls_issues);
  72. tls_t *tls_init_secondary(tls_t *tls_master, int sock, int accept);
  73. void tls_free(tls_t *tls);
  74. int tls_get_socket(tls_t *tls);
  75. void tls_log_errors(unsigned level, char const *s, unsigned long e);
  76. ssize_t tls_read(tls_t *tls);
  77. void *tls_read_buffer(tls_t *tls, size_t N);
  78. int tls_want_read(tls_t *tls, int events);
  79. int tls_pending(tls_t const *tls);
  80. int tls_connect(su_root_magic_t *magic, su_wait_t *w, tport_t *self);
  81. ssize_t tls_write(tls_t *tls, void *buf, size_t size);
  82. int tls_want_write(tls_t *tls, int events);
  83. int tls_events(tls_t const *tls, int flags);
  84. void tls_init(void);
  85. SOFIA_END_DECLS
  86. #endif