update swig interface

This commit is contained in:
toddouska 2011-11-09 17:58:37 -08:00
parent 185e23fc58
commit 051b63b9c8
5 changed files with 27 additions and 11 deletions

4
.gitignore vendored
View File

@ -61,4 +61,8 @@ TAGS
support/libcyassl.pc
cyassl/version.h
cyassl/ctaocrypt/stamp-h1
swig/_cyassl.so
swig/cyassl.py
swig/cyassl.pyc
swig/cyassl_wrap.c
stamp-h1

View File

@ -3,7 +3,7 @@ echo
swig -python cyassl.i
pythonIncludes=`python-config --includes`
pythonLibs=`python-config --libs`
gcc -c -fpic cyassl_wrap.c -I$pythonIncludes -I/usr/local/cyassl/include -DHAVE_CONFIG_H
gcc -c -fpic cyassl_adds.c -I/usr/local/cyassl/include
gcc -shared -flat_namespace cyassl_adds.o cyassl_wrap.o -lcyassl -L/usr/local/cyassl/lib $pythonLibs -o _cyassl.so
gcc -c -fpic cyassl_wrap.c -I$pythonIncludes
gcc -c -fpic cyassl_adds.c
gcc -shared -flat_namespace cyassl_adds.o cyassl_wrap.o -lcyassl $pythonLibs -o _cyassl.so
python runme.py

View File

@ -21,12 +21,12 @@
%module cyassl
%{
#include "openssl/ssl.h"
#include "rsa.h"
#include <cyassl/openssl/ssl.h>
#include <cyassl/ctaocrypt/rsa.h>
/* defn adds */
char* CyaSSL_error_string(int err);
int CyaSSL_connect(SSL*, const char* server, int port);
int CyaSSL_swig_connect(SSL*, const char* server, int port);
RNG* GetRng(void);
RsaKey* GetRsaPrivateKey(const char* file);
void FillSignStr(unsigned char*, const char*, int);
@ -39,8 +39,10 @@ int SSL_CTX_load_verify_locations(SSL_CTX*, const char*, const char*);
SSL* SSL_new(SSL_CTX*);
int SSL_get_error(SSL*, int);
int SSL_write(SSL*, const char*, int);
int CyaSSL_Debugging_ON(void);
int CyaSSL_Init(void);
char* CyaSSL_error_string(int);
int CyaSSL_connect(SSL*, const char* server, int port);
int CyaSSL_swig_connect(SSL*, const char* server, int port);
int RsaSSL_Sign(const unsigned char* in, int inLen, unsigned char* out, int outLen, RsaKey* key, RNG* rng);

View File

@ -160,7 +160,7 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, short port)
}
int CyaSSL_connect(SSL* ssl, const char* server, int port)
int CyaSSL_swig_connect(SSL* ssl, const char* server, int port)
{
SOCKET_T sockfd;
int ret = tcp_connect(&sockfd, server, port);

View File

@ -5,11 +5,21 @@ import cyassl
print ""
print "Trying to connect to the echo server..."
cyassl.CyaSSL_Init()
#cyassl.CyaSSL_Debugging_ON()
ctx = cyassl.SSL_CTX_new(cyassl.TLSv1_client_method())
ret = cyassl.SSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None)
ssl = cyassl.SSL_new(ctx)
if ctx == None:
print "Couldn't get SSL CTX for TLSv1"
exit(-1)
ret = cyassl.CyaSSL_connect(ssl, "localhost", 11111)
ret = cyassl.SSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None)
if ret != cyassl.SSL_SUCCESS:
print "Couldn't do SSL_CTX_load_verify_locations "
print "error string = ", ret
exit(-1)
ssl = cyassl.SSL_new(ctx)
ret = cyassl.CyaSSL_swig_connect(ssl, "localhost", 11111)
if ret != cyassl.SSL_SUCCESS:
print "Couldn't do SSL connect"