/***************************************************************************
 *
 * Copyright (c) 2000, 2001 BalaBit IT Ltd, Budapest, Hungary
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: ssl.h,v 1.1.2.1.2.3 2001/09/19 19:22:17 bazsi Exp $
 *
 ***************************************************************************/

#ifndef ZORP_SSL_H_INCLUDED
#define ZORP_SSL_H_INCLUDED

#include <openssl/ssl.h>
#include <zorp/zorp.h>
#include <zorp/stream.h>

typedef struct _ZSSLSession 
{
  SSL *ssl;
  gchar *session_id;
  gint verify_type;
  gint verify_depth;
  X509_STORE *crl_store;
} ZSSLSession;

#define Z_SSL_MODE_CLIENT  0
#define Z_SSL_MODE_SERVER  1

#define Z_SSL_VERIFY_NONE                0
#define Z_SSL_VERIFY_OPTIONAL            1
#define Z_SSL_VERIFY_REQUIRED_UNTRUSTED  2
#define Z_SSL_VERIFY_REQUIRED_TRUSTED    3


void z_ssl_init(void);
void z_ssl_destroy(void);
void z_stream_ssl(ZStream *s, ZSSLSession *ssl);

ZSSLSession *
z_ssl_session_new(char *session_id, 
                  int mode,
                  gchar *key_file, 
                  gchar *cert_file, 
                  gchar *ca_dir, 
                  gchar *crl_dir, 
                  int verify_depth,
                  int verify_type);

void
z_ssl_session_destroy(ZSSLSession *self);

gchar *
z_ssl_get_error_str(gchar *buf, int buflen);

#endif
