tport_tls.h 3.13 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

25 26
#ifndef TPORT_TLS_H
/** Defined when <tport_tls.h> has been included. */
27
#define TPORT_TLS_H
28
/**@internal
29 30 31
 * @file tport_tls.h
 * @brief Internal TLS interface
 *
Pekka Pessi's avatar
Pekka Pessi committed
32 33 34
 * @author Mikko Haataja <ext-Mikko.A.Haataja@nokia.com>
 *
 * Copyright 2001, 2002 Nokia Research Center.  All rights reserved.
35
 *
Pekka Pessi's avatar
Pekka Pessi committed
36 37
 */

38 39
#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
40 41
#endif

42 43
#include "tport_internal.h"

44 45
SOFIA_BEGIN_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
46 47 48 49
#define TLS_MAX_HOSTS (16)

typedef struct tls_s tls_t;

50 51
extern char const tls_version[];

Pekka Pessi's avatar
Pekka Pessi committed
52
typedef struct tls_issues_s {
53 54 55
  unsigned policy;      /* refer to tport_tag.h, tport_tls_verify_policy */
  unsigned verify_depth;/* if 0, revert to default (2) */
  unsigned verify_date; /* if 0, notBefore and notAfter dates are ignored */
Pekka Pessi's avatar
Pekka Pessi committed
56 57 58
  int   configured;	/* If non-zero, complain about certificate errors */
  char *cert;		/* CERT file name. File format is PEM         */
  char *key;		/* Private key file. PEM format               */
59
  char *passphrase;     /* Passphrase for password protected private key */
Pekka Pessi's avatar
Pekka Pessi committed
60 61 62
  char *randFile;       /* Seed file for the PRNG (default: tls_seed.dat) */
  char *CAfile;		/* PEM file of CA's                           */
  char *CApath;		/* PEM file path of CA's		      */
63
  char *ciphers;         /* Should be one of the above defined ciphers *
Pekka Pessi's avatar
Pekka Pessi committed
64 65
			 * or NULL (default: "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
                         */
66
  int   version;	/* For tls1, version is 1. When ssl3/ssl2 is
Pekka Pessi's avatar
Pekka Pessi committed
67
			 * used, it is 0. */
68
  char *keystore;		/* Path a p12 key store file         */
Pekka Pessi's avatar
Pekka Pessi committed
69 70
} tls_issues_t;

71 72 73 74 75 76 77 78 79 80 81
typedef struct tport_tls_s {
  tport_t  tlstp_tp[1];
  tls_t   *tlstp_context;
  char    *tlstp_buffer;
} tport_tls_t;

typedef struct tport_tls_primary_s {
  tport_primary_t tlspri_pri[1];
  tls_t *tlspri_master;
} tport_tls_primary_t;

Pekka Pessi's avatar
Pekka Pessi committed
82
tls_t *tls_init_master(tls_issues_t *tls_issues);
83
tls_t *tls_init_secondary(tls_t *tls_master, int sock, int accept);
Pekka Pessi's avatar
Pekka Pessi committed
84
void tls_free(tls_t *tls);
85 86
ssize_t tls_read(tls_t *tls);
void *tls_read_buffer(tls_t *tls, size_t N);
Pekka Pessi's avatar
Pekka Pessi committed
87 88 89
int tls_want_read(tls_t *tls, int events);
int tls_pending(tls_t const *tls);

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);
Pekka Pessi's avatar
Pekka Pessi committed
92 93 94 95
int tls_want_write(tls_t *tls, int events);

int tls_events(tls_t const *tls, int flags);

96 97
SOFIA_END_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
98
#endif