/*
 *  include/xssl.h
 *
 *  Wrapper of SSL APIs
 *
 *  Copyright (C) 2004  Phoenix Grid Computing Project
 *                      ( http://www.logos.ic.i.u-tokyo.ac.jp/phoenix/ )
 *
 *  2004-11-26  Implemented basic functions 
 *              by Kaneda Kenji
 */


#ifndef _XSSL_H
#define _XSSL_H


#include "common.h"


int  xRAND_load_file ( const char *filename, long max_bytes );
RSA *xRSA_generate_key ( int num, unsigned long e, void (*callback)(int,int,void *), void *cb_arg );
void xDSA_generate_key ( DSA *a );
DSA* xDSA_generate_parameters ( int bits, unsigned char *seed,
				int seed_len, int *counter_ret, unsigned long *h_ret,
				void (*callback)(int, int, void *), void *cb_arg );
DH * xDSA_dup_DH ( const DSA *r );

BIO *xBIO_new_file ( const char *filename, const char *mode );
BIO *xBIO_new_fp ( FILE *stream, int flags );
BIO *xBIO_new_socket ( int sock, int close_flag );

SSL_CTX *xSSL_CTX_new ( SSL_METHOD *method );
void     xSSL_CTX_use_certificate_file (SSL_CTX *ctx, const char *file, int type);
void     xSSL_CTX_use_certificate_chain_file ( SSL_CTX *ctx, const char *file );
void     xSSL_CTX_use_PrivateKey_file ( SSL_CTX *ctx, const char *file, int type );
void     xSSL_CTX_check_private_key ( SSL_CTX *ctx );
void     xSSL_CTX_load_verify_locations ( SSL_CTX *ctx, const char *CAfile, const char *CApath );
long     xSSL_CTX_set_tmp_dh ( SSL_CTX *ctx, DH *dh );
long     xSSL_CTX_set_tmp_rsa ( SSL_CTX *ctx, RSA *rsa );
void     xSSL_CTX_set_session_id_context ( SSL_CTX *ctx, const unsigned char *sid_ctx, unsigned int sid_ctx_len );

STACK_OF ( X509_NAME ) *xSSL_load_client_CA_file ( const char *file );

SSL *    xSSL_new ( SSL_CTX *ctx );
int      xSSL_connect ( SSL *ssl );
int      xSSL_accept ( SSL *ssl );
int      xSSL_read ( SSL *ssl, void *buf, int num );
int      xSSL_write ( SSL *ssl, const void *buf, int num );
int      xSSL_shutdown ( SSL *ssl, int how );

int      xX509_NAME_get_index_by_NID ( X509_NAME *name, int nid, int lastpos );


#endif /* _XSSL_H */
