cyassl api for swig
This commit is contained in:
parent
051b63b9c8
commit
c46cbccf4f
@ -21,28 +21,28 @@
|
||||
|
||||
%module cyassl
|
||||
%{
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/ctaocrypt/rsa.h>
|
||||
|
||||
/* defn adds */
|
||||
char* CyaSSL_error_string(int err);
|
||||
int CyaSSL_swig_connect(SSL*, const char* server, int port);
|
||||
int CyaSSL_swig_connect(CYASSL*, const char* server, int port);
|
||||
RNG* GetRng(void);
|
||||
RsaKey* GetRsaPrivateKey(const char* file);
|
||||
void FillSignStr(unsigned char*, const char*, int);
|
||||
%}
|
||||
|
||||
|
||||
SSL_METHOD* TLSv1_client_method(void);
|
||||
SSL_CTX* SSL_CTX_new(SSL_METHOD*);
|
||||
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_swig_connect(SSL*, const char* server, int port);
|
||||
CYASSL_METHOD* CyaTLSv1_client_method(void);
|
||||
CYASSL_CTX* CyaSSL_CTX_new(CYASSL_METHOD*);
|
||||
int CyaSSL_CTX_load_verify_locations(CYASSL_CTX*, const char*, const char*);
|
||||
CYASSL* CyaSSL_new(CYASSL_CTX*);
|
||||
int CyaSSL_get_error(CYASSL*, int);
|
||||
int CyaSSL_write(CYASSL*, const char*, int);
|
||||
int CyaSSL_Debugging_ON(void);
|
||||
int CyaSSL_Init(void);
|
||||
char* CyaSSL_error_string(int);
|
||||
int CyaSSL_swig_connect(CYASSL*, const char* server, int port);
|
||||
|
||||
int RsaSSL_Sign(const unsigned char* in, int inLen, unsigned char* out, int outLen, RsaKey* key, RNG* rng);
|
||||
|
||||
@ -55,7 +55,7 @@ void FillSignStr(unsigned char*, const char*, int);
|
||||
%include carrays.i
|
||||
%include cdata.i
|
||||
%array_class(unsigned char, byteArray);
|
||||
int SSL_read(SSL*, unsigned char*, int);
|
||||
int CyaSSL_read(CYASSL*, unsigned char*, int);
|
||||
|
||||
|
||||
#define SSL_FAILURE 0
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define HAVE_CONFIG_H
|
||||
#endif
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/ctaocrypt/rsa.h>
|
||||
#include <cyassl/ctaocrypt/asn.h>
|
||||
|
||||
@ -160,15 +160,15 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, short port)
|
||||
}
|
||||
|
||||
|
||||
int CyaSSL_swig_connect(SSL* ssl, const char* server, int port)
|
||||
int CyaSSL_swig_connect(CYASSL* ssl, const char* server, int port)
|
||||
{
|
||||
SOCKET_T sockfd;
|
||||
int ret = tcp_connect(&sockfd, server, port);
|
||||
if (ret != 0) return ret;
|
||||
|
||||
SSL_set_fd(ssl, sockfd);
|
||||
CyaSSL_set_fd(ssl, sockfd);
|
||||
|
||||
return SSL_connect(ssl);
|
||||
return CyaSSL_connect(ssl);
|
||||
}
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ char* CyaSSL_error_string(int err)
|
||||
{
|
||||
static char buffer[80];
|
||||
|
||||
return ERR_error_string(err, buffer);
|
||||
return CyaSSL_ERR_error_string(err, buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,34 +7,34 @@ print "Trying to connect to the echo server..."
|
||||
|
||||
cyassl.CyaSSL_Init()
|
||||
#cyassl.CyaSSL_Debugging_ON()
|
||||
ctx = cyassl.SSL_CTX_new(cyassl.TLSv1_client_method())
|
||||
ctx = cyassl.CyaSSL_CTX_new(cyassl.CyaTLSv1_client_method())
|
||||
if ctx == None:
|
||||
print "Couldn't get SSL CTX for TLSv1"
|
||||
exit(-1)
|
||||
|
||||
ret = cyassl.SSL_CTX_load_verify_locations(ctx, "../certs/ca-cert.pem", None)
|
||||
ret = cyassl.CyaSSL_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)
|
||||
ssl = cyassl.CyaSSL_new(ctx)
|
||||
ret = cyassl.CyaSSL_swig_connect(ssl, "localhost", 11111)
|
||||
|
||||
if ret != cyassl.SSL_SUCCESS:
|
||||
print "Couldn't do SSL connect"
|
||||
err = cyassl.SSL_get_error(ssl, 0)
|
||||
err = cyassl.CyaSSL_get_error(ssl, 0)
|
||||
print "error string = ", cyassl.CyaSSL_error_string(err)
|
||||
exit(-1)
|
||||
|
||||
print "...Connected"
|
||||
written = cyassl.SSL_write(ssl, "hello from python\r\n", 19)
|
||||
written = cyassl.CyaSSL_write(ssl, "hello from python\r\n", 19)
|
||||
|
||||
if written > 0:
|
||||
print "Wrote ", written, " bytes"
|
||||
|
||||
byteArray = cyassl.byteArray(100)
|
||||
readBytes = cyassl.SSL_read(ssl, byteArray, 100)
|
||||
readBytes = cyassl.CyaSSL_read(ssl, byteArray, 100)
|
||||
|
||||
print "server reply: ", cyassl.cdata(byteArray, readBytes)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user