tport  1.12.11devel
tport_tls.h
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-email.address.hidden>
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 
25 #ifndef TPORT_TLS_H
26 
27 #define TPORT_TLS_H
28 
38 #ifndef SU_TYPES_H
39 #include <sofia-sip/su_types.h>
40 #endif
41 
42 #include "tport_internal.h"
43 
44 SOFIA_BEGIN_DECLS
45 
46 #define TLS_MAX_HOSTS (16)
47 
48 typedef struct tls_s tls_t;
49 
50 extern char const tls_version[];
51 
52 typedef struct tls_issues_s {
53  unsigned policy; /* refer to tport_tag.h, tport_tls_verify_policy */
54  unsigned verify_depth;/* if 0, revert to default (2) */
55  unsigned verify_date; /* if 0, notBefore and notAfter dates are ignored */
56  int configured; /* If non-zero, complain about certificate errors */
57  char *cert; /* CERT file name. File format is PEM */
58  char *key; /* Private key file. PEM format */
59  char *passphrase; /* Passphrase for password protected private key */
60  char *randFile; /* Seed file for the PRNG (default: tls_seed.dat) */
61  char *CAfile; /* PEM file of CA's */
62  char *CApath; /* PEM file path of CA's */
63  char *cipher; /* Should be one of the above defined ciphers *
64  * or NULL (default: "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
65  */
66  int version; /* For tls1, version is 1. When ssl3/ssl2 is
67  * used, it is 0. */
68 } tls_issues_t;
69 
70 typedef struct tport_tls_s {
71  tport_t tlstp_tp[1];
72  tls_t *tlstp_context;
73  char *tlstp_buffer;
74 } tport_tls_t;
75 
76 typedef struct tport_tls_primary_s {
77  tport_primary_t tlspri_pri[1];
78  tls_t *tlspri_master;
79 } tport_tls_primary_t;
80 
81 tls_t *tls_init_master(tls_issues_t *tls_issues);
82 tls_t *tls_init_secondary(tls_t *tls_master, int sock, int accept);
83 void tls_free(tls_t *tls);
84 int tls_get_socket(tls_t *tls);
85 ssize_t tls_read(tls_t *tls);
86 void *tls_read_buffer(tls_t *tls, size_t N);
87 int tls_want_read(tls_t *tls, int events);
88 int tls_pending(tls_t const *tls);
89 
90 int tls_connect(su_root_magic_t *magic, su_wait_t *w, tport_t *self);
91 ssize_t tls_write(tls_t *tls, void *buf, size_t size);
92 int tls_want_write(tls_t *tls, int events);
93 
94 int tls_events(tls_t const *tls, int flags);
95 
96 SOFIA_END_DECLS
97 
98 #endif
SU_ROOT_MAGIC_T su_root_magic_t
struct pollfd su_wait_t

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.