[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Do not mix tabs and spaces in our source files; use spa...
Update of /home/minion/cvsroot/src/minion/src
In directory moria.mit.edu:/tmp/cvs-serv9270/src
Modified Files:
_minionlib.h aes_ctr.c crypt.c main.c tls.c
Log Message:
Do not mix tabs and spaces in our source files; use spaces only.
Index: _minionlib.h
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/_minionlib.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- _minionlib.h 12 Dec 2002 19:56:47 -0000 1.10
+++ _minionlib.h 16 Dec 2002 02:40:11 -0000 1.11
@@ -16,7 +16,7 @@
/* We provide our own implementation of counter mode; see aes_ctr.c
*/
void mm_aes_counter128(const char *in, char *out, unsigned int len,
- AES_KEY *key, unsigned long count);
+ AES_KEY *key, unsigned long count);
/* Propagate an error from OpenSSL. If 'crypto', it's a cryptography
* error. Else, it's a TLS error.
@@ -25,8 +25,8 @@
extern PyTypeObject mm_RSA_Type;
typedef struct mm_RSA {
- PyObject_HEAD
- RSA* rsa;
+ PyObject_HEAD
+ RSA* rsa;
} mm_RSA;
#define mm_RSA_Check(v) ((v)->ob_type == &mm_RSA_Type)
@@ -86,6 +86,7 @@
/*
Local Variables:
mode:c
+ indent-tabs-mode:nil
c-basic-offset:8
End:
*/
Index: aes_ctr.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/aes_ctr.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- aes_ctr.c 12 Dec 2002 19:56:47 -0000 1.8
+++ aes_ctr.c 16 Dec 2002 02:40:11 -0000 1.9
@@ -57,49 +57,50 @@
static inline void
mm_incr(u32 const* ctr32)
{
- u32 i;
+ u32 i;
- INCR_U32(ctr32+3,i);
- if (i) return;
+ INCR_U32(ctr32+3,i);
+ if (i) return;
- INCR_U32(ctr32+2,i);
- if (i) return;
+ INCR_U32(ctr32+2,i);
+ if (i) return;
- INCR_U32(ctr32+1,i);
- if (i) return;
+ INCR_U32(ctr32+1,i);
+ if (i) return;
- INCR_U32(ctr32, i);
+ INCR_U32(ctr32, i);
}
void
mm_aes_counter128(const char *in, char *out, unsigned int len, AES_KEY *key,
unsigned long count)
{
- unsigned char counter[16];
- unsigned char tmp[16];
- /* making this a variable can hurt register pressure, and we'd
- really like the compiler to be able to inline mm_incr above. */
- #define CTR32 ((u32*)counter)
+ unsigned char counter[16];
+ unsigned char tmp[16];
+ /* making this a variable can hurt register pressure, and we'd
+ really like the compiler to be able to inline mm_incr above. */
+ #define CTR32 ((u32*)counter)
- if (!len) return;
- memset(counter, 0, 12);
- SET_U32(CTR32+3, count >> 4);
- count &= 0x0f;
+ if (!len) return;
+ memset(counter, 0, 12);
+ SET_U32(CTR32+3, count >> 4);
+ count &= 0x0f;
- while (1) {
- AES_encrypt(counter, tmp, key);
- do {
- *(out++) = *(in++) ^ tmp[count];
- if (--len == 0) return;
- } while (++count != 16);
- mm_incr(CTR32);
- count = 0;
- }
+ while (1) {
+ AES_encrypt(counter, tmp, key);
+ do {
+ *(out++) = *(in++) ^ tmp[count];
+ if (--len == 0) return;
+ } while (++count != 16);
+ mm_incr(CTR32);
+ count = 0;
+ }
}
/*
Local Variables:
mode:c
+ indent-tabs-mode:nil
c-basic-offset:8
End:
*/
Index: crypt.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/crypt.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- crypt.c 12 Dec 2002 19:56:47 -0000 1.14
+++ crypt.c 16 Dec 2002 02:40:11 -0000 1.15
@@ -33,14 +33,14 @@
void
mm_SSL_ERR(int crypto)
{
- int err = ERR_get_error();
- const char *str = ERR_reason_error_string(err);
- PyObject *exception = crypto ? mm_CryptoError : mm_TLSError;
- assert(exception);
- if (str)
- PyErr_SetString(exception, str);
- else
- PyErr_SetString(exception, "Internal error");
[...1444 lines suppressed...]
+ if (name)
+ X509_NAME_free(name);
+ if (x509)
+ X509_free(x509);
+ if (rsa)
+ RSA_free(rsa);
+ if (pkey)
+ EVP_PKEY_free(pkey);
- return retval;
+ return retval;
}
/*
Local Variables:
mode:c
+ indent-tabs-mode:nil
c-basic-offset:8
End:
*/
Index: main.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/main.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- main.c 12 Dec 2002 19:56:47 -0000 1.8
+++ main.c 16 Dec 2002 02:40:11 -0000 1.9
@@ -20,22 +20,22 @@
(char*)mm_##fn##__doc__}
static struct PyMethodDef _mixcryptlib_functions[] = {
- ENTRY(sha1),
- ENTRY(aes_key),
- ENTRY(aes_ctr128_crypt),
- ENTRY(strxor),
- ENTRY(openssl_seed),
- ENTRY(add_oaep_padding),
- ENTRY(check_oaep_padding),
- ENTRY(rsa_generate),
- ENTRY(rsa_decode_key),
- ENTRY(rsa_PEM_read_key),
- ENTRY(rsa_make_public_key),
- ENTRY(generate_dh_parameters),
- ENTRY(generate_cert),
+ ENTRY(sha1),
+ ENTRY(aes_key),
+ ENTRY(aes_ctr128_crypt),
+ ENTRY(strxor),
+ ENTRY(openssl_seed),
+ ENTRY(add_oaep_padding),
+ ENTRY(check_oaep_padding),
+ ENTRY(rsa_generate),
+ ENTRY(rsa_decode_key),
+ ENTRY(rsa_PEM_read_key),
+ ENTRY(rsa_make_public_key),
+ ENTRY(generate_dh_parameters),
+ ENTRY(generate_cert),
- ENTRY(TLSContext_new),
- { NULL, NULL }
+ ENTRY(TLSContext_new),
+ { NULL, NULL }
};
/* Helper method to create an exception object and register it in a
@@ -52,28 +52,28 @@
exc(PyObject *module_dict, PyObject **exception, char *longName,
char *itemString, char *doc)
{
- PyObject *s, *exc_d;
- if (!(s = PyString_FromString(doc)))
- return 1;
- if (!(exc_d = PyDict_New())) {
- Py_DECREF(s);
- return 1;
- }
- if (PyDict_SetItemString(exc_d, "__doc__", s)<0) {
- Py_DECREF(s); Py_DECREF(exc_d);
- return 1;
- }
- *exception = PyErr_NewException(longName, PyExc_Exception, exc_d);
- if (! *exception) {
- Py_DECREF(s); Py_DECREF(exc_d);
- return 1;
- }
- if (PyDict_SetItemString(module_dict,itemString,*exception) < 0) {
- Py_DECREF(s); Py_DECREF(exc_d); Py_DECREF(*exception);
- return 1;
- }
+ PyObject *s, *exc_d;
+ if (!(s = PyString_FromString(doc)))
+ return 1;
+ if (!(exc_d = PyDict_New())) {
+ Py_DECREF(s);
+ return 1;
+ }
+ if (PyDict_SetItemString(exc_d, "__doc__", s)<0) {
+ Py_DECREF(s); Py_DECREF(exc_d);
+ return 1;
+ }
+ *exception = PyErr_NewException(longName, PyExc_Exception, exc_d);
+ if (! *exception) {
+ Py_DECREF(s); Py_DECREF(exc_d);
+ return 1;
+ }
+ if (PyDict_SetItemString(module_dict,itemString,*exception) < 0) {
+ Py_DECREF(s); Py_DECREF(exc_d); Py_DECREF(*exception);
+ return 1;
+ }
- return 0;
+ return 0;
}
/* Required by Python: magic method to tell the Python runtime about our
@@ -82,53 +82,54 @@
DL_EXPORT(void)
init_minionlib(void)
{
- PyObject *m, *d;
- m = Py_InitModule("_minionlib", _mixcryptlib_functions);
- d = PyModule_GetDict(m);
+ PyObject *m, *d;
+ m = Py_InitModule("_minionlib", _mixcryptlib_functions);
+ d = PyModule_GetDict(m);
- SSL_library_init();
- SSL_load_error_strings();
+ SSL_library_init();
+ SSL_load_error_strings();
- /* crypt */
- ERR_load_ERR_strings();
- ERR_load_RSA_strings();
+ /* crypt */
+ ERR_load_ERR_strings();
+ ERR_load_RSA_strings();
- OpenSSL_add_all_algorithms();
+ OpenSSL_add_all_algorithms();
- if (exc(d, &mm_CryptoError, "mixminion._minionlib.CryptoError",
- "CryptoError", mm_CryptoError__doc__))
- return;
- if (exc(d, &mm_TLSError, "mixminion._minionlib.TLSError",
- "TLSError", mm_TLSError__doc__))
- return;
- if (exc(d, &mm_TLSWantRead, "mixminion._minionlib.TLSWantRead",
- "TLSWantRead", mm_TLSWantRead__doc__))
- return;
- if (exc(d, &mm_TLSWantWrite, "mixminion._minionlib.TLSWantWrite",
- "TLSWantWrite", mm_TLSWantWrite__doc__))
- return;
- if (exc(d, &mm_TLSClosed, "mixminion._minionlib.TLSClosed",
- "TLSClosed", mm_TLSClosed__doc__))
- return;
+ if (exc(d, &mm_CryptoError, "mixminion._minionlib.CryptoError",
+ "CryptoError", mm_CryptoError__doc__))
+ return;
+ if (exc(d, &mm_TLSError, "mixminion._minionlib.TLSError",
+ "TLSError", mm_TLSError__doc__))
+ return;
+ if (exc(d, &mm_TLSWantRead, "mixminion._minionlib.TLSWantRead",
+ "TLSWantRead", mm_TLSWantRead__doc__))
+ return;
+ if (exc(d, &mm_TLSWantWrite, "mixminion._minionlib.TLSWantWrite",
+ "TLSWantWrite", mm_TLSWantWrite__doc__))
+ return;
+ if (exc(d, &mm_TLSClosed, "mixminion._minionlib.TLSClosed",
+ "TLSClosed", mm_TLSClosed__doc__))
+ return;
- Py_INCREF(&mm_RSA_Type);
- if (PyDict_SetItemString(d, "RSA", (PyObject*)&mm_RSA_Type) < 0)
- return;
+ Py_INCREF(&mm_RSA_Type);
+ if (PyDict_SetItemString(d, "RSA", (PyObject*)&mm_RSA_Type) < 0)
+ return;
- Py_INCREF(&mm_TLSContext_Type);
- if (PyDict_SetItemString(d, "TLSContext",
- (PyObject*)&mm_TLSContext_Type) < 0)
- return;
+ Py_INCREF(&mm_TLSContext_Type);
+ if (PyDict_SetItemString(d, "TLSContext",
+ (PyObject*)&mm_TLSContext_Type) < 0)
+ return;
- Py_INCREF(&mm_TLSSock_Type);
- if (PyDict_SetItemString(d, "TLSSock",
- (PyObject*)&mm_TLSSock_Type) < 0)
- return;
+ Py_INCREF(&mm_TLSSock_Type);
+ if (PyDict_SetItemString(d, "TLSSock",
+ (PyObject*)&mm_TLSSock_Type) < 0)
+ return;
}
/*
Local Variables:
mode:c
+ indent-tabs-mode:nil
c-basic-offset:8
End:
*/
Index: tls.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/tls.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- tls.c 12 Dec 2002 19:56:47 -0000 1.10
+++ tls.c 16 Dec 2002 02:40:11 -0000 1.11
@@ -54,44 +54,44 @@
static int
tls_error(SSL *ssl, int r, int flags)
{
- int err = SSL_get_error(ssl,r);
- switch (err) {
- case SSL_ERROR_NONE:
- return NO_ERROR;
- case SSL_ERROR_ZERO_RETURN:
- if (flags & IGNORE_ZERO_RETURN)
- return ZERO_RETURN;
+ int err = SSL_get_error(ssl,r);
+ switch (err) {
+ case SSL_ERROR_NONE:
+ return NO_ERROR;
+ case SSL_ERROR_ZERO_RETURN:
+ if (flags & IGNORE_ZERO_RETURN)
+ return ZERO_RETURN;
mm_SSL_ERR(0);
- return ZERO_RETURN;
- case SSL_ERROR_WANT_READ:
- PyErr_SetNone(mm_TLSWantRead);
- return ERROR;
- case SSL_ERROR_WANT_WRITE:
- PyErr_SetNone(mm_TLSWantWrite);
- return ERROR;
- case SSL_ERROR_SYSCALL:
- if (flags & IGNORE_SYSCALL)
- return NO_ERROR;
- PyErr_SetNone(mm_TLSClosed);
- return ERROR;
- default:
- mm_SSL_ERR(0);
- return ERROR;
- }
+ return ZERO_RETURN;
+ case SSL_ERROR_WANT_READ:
+ PyErr_SetNone(mm_TLSWantRead);
+ return ERROR;
+ case SSL_ERROR_WANT_WRITE:
+ PyErr_SetNone(mm_TLSWantWrite);
+ return ERROR;
+ case SSL_ERROR_SYSCALL:
+ if (flags & IGNORE_SYSCALL)
+ return NO_ERROR;
+ PyErr_SetNone(mm_TLSClosed);
+ return ERROR;
+ default:
+ mm_SSL_ERR(0);
+ return ERROR;
+ }
}
typedef struct mm_TLSContext {
- PyObject_HEAD
- SSL_CTX *ctx;
+ PyObject_HEAD
+ SSL_CTX *ctx;
} mm_TLSContext;
#define mm_TLSContext_Check(v) ((v)->ob_type == &mm_TLSContext_Type)
typedef struct mm_TLSSock {
- PyObject_HEAD
- PyObject *context;
- SSL *ssl;
- int sock;
- PyObject *sockObj;
+ PyObject_HEAD
+ PyObject *context;
+ SSL *ssl;
+ int sock;
+ PyObject *sockObj;
} mm_TLSSock;
#define mm_TLSSock_Check(v) ((v)->ob_type == &mm_TLSSock_Type)
@@ -108,79 +108,79 @@
PyObject*
mm_TLSContext_new(PyObject *self, PyObject *args, PyObject *kwargs)
{
- static char *kwlist[] = { "certfile", "pkfile", "dhfile", NULL };
- char *certfile = NULL, *dhfile=NULL;
- mm_RSA *rsa = NULL;
+ static char *kwlist[] = { "certfile", "pkfile", "dhfile", NULL };
+ char *certfile = NULL, *dhfile=NULL;
+ mm_RSA *rsa = NULL;
- SSL_METHOD *method;
- SSL_CTX *ctx;
- DH *dh;
- mm_TLSContext *result;
- BIO *bio;
- RSA *_rsa = NULL;
- EVP_PKEY *pkey = NULL;
+ SSL_METHOD *method;
+ SSL_CTX *ctx;
+ DH *dh;
+ mm_TLSContext *result;
+ BIO *bio;
+ RSA *_rsa = NULL;
+ EVP_PKEY *pkey = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|sO!s:TLSContext_new",
- kwlist,
- &certfile,
- &mm_RSA_Type, &rsa,
- &dhfile))
- return NULL;
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|sO!s:TLSContext_new",
+ kwlist,
+ &certfile,
+ &mm_RSA_Type, &rsa,
+ &dhfile))
+ return NULL;
- method = TLSv1_method();
+ method = TLSv1_method();
- if (!(ctx = SSL_CTX_new(method))) {
- mm_SSL_ERR(0); return NULL;
- }
- if (!SSL_CTX_set_cipher_list(ctx, TLS1_TXT_DHE_RSA_WITH_AES_128_SHA)){
- SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
- }
- if (certfile &&
- !SSL_CTX_use_certificate_file(ctx,certfile,SSL_FILETYPE_PEM)) {
- SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
- }
- if (rsa) {
- if (!(_rsa = RSAPrivateKey_dup(rsa->rsa)) ||
- !(pkey = EVP_PKEY_new()) ||
- !EVP_PKEY_assign_RSA(pkey, _rsa)) {
- if (!pkey && _rsa) RSA_free(_rsa);
- if (pkey) EVP_PKEY_free(pkey);
- SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
- }
- if (!(SSL_CTX_use_PrivateKey(ctx, pkey))) {
- EVP_PKEY_free(pkey);
- SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
- }
- EVP_PKEY_free(pkey);
- }
+ if (!(ctx = SSL_CTX_new(method))) {
+ mm_SSL_ERR(0); return NULL;
+ }
+ if (!SSL_CTX_set_cipher_list(ctx, TLS1_TXT_DHE_RSA_WITH_AES_128_SHA)){
+ SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
+ }
+ if (certfile &&
+ !SSL_CTX_use_certificate_file(ctx,certfile,SSL_FILETYPE_PEM)) {
+ SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
+ }
+ if (rsa) {
+ if (!(_rsa = RSAPrivateKey_dup(rsa->rsa)) ||
+ !(pkey = EVP_PKEY_new()) ||
+ !EVP_PKEY_assign_RSA(pkey, _rsa)) {
+ if (!pkey && _rsa) RSA_free(_rsa);
+ if (pkey) EVP_PKEY_free(pkey);
+ SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
+ }
+ if (!(SSL_CTX_use_PrivateKey(ctx, pkey))) {
+ EVP_PKEY_free(pkey);
+ SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
+ }
+ EVP_PKEY_free(pkey);
+ }
- if (dhfile) {
- if ( !(bio = BIO_new_file(dhfile, "r"))) {
- SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
- }
- dh=PEM_read_bio_DHparams(bio,NULL,NULL,NULL);
- BIO_free(bio);
- if (!dh) {
- SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
- }
- SSL_CTX_set_tmp_dh(ctx,dh);
- DH_free(dh);
- }
- SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
+ if (dhfile) {
+ if ( !(bio = BIO_new_file(dhfile, "r"))) {
+ SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
+ }
+ dh=PEM_read_bio_DHparams(bio,NULL,NULL,NULL);
+ BIO_free(bio);
+ if (!dh) {
+ SSL_CTX_free(ctx); mm_SSL_ERR(0); return NULL;
+ }
+ SSL_CTX_set_tmp_dh(ctx,dh);
+ DH_free(dh);
+ }
+ SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
- result = PyObject_New(mm_TLSContext, &mm_TLSContext_Type);
- if (!result) {
- SSL_CTX_free(ctx); return NULL;
- }
- result->ctx = ctx;
- return (PyObject*)result;
+ result = PyObject_New(mm_TLSContext, &mm_TLSContext_Type);
+ if (!result) {
+ SSL_CTX_free(ctx); return NULL;
+ }
+ result->ctx = ctx;
+ return (PyObject*)result;
}
static void
mm_TLSContext_dealloc(mm_TLSContext *self)
{
- SSL_CTX_free(self->ctx);
- PyObject_DEL(self);
+ SSL_CTX_free(self->ctx);
+ PyObject_DEL(self);
}
static char mm_TLSContext_sock__doc__[] =
@@ -192,64 +192,64 @@
static PyObject *
mm_TLSContext_sock(PyObject *self, PyObject *args, PyObject *kwargs)
{
- static char *kwlist[] = { "socket", "serverMode", NULL };
- PyObject *sockObj;
- int serverMode = 0;
- int sock;
+ static char *kwlist[] = { "socket", "serverMode", NULL };
+ PyObject *sockObj;
+ int serverMode = 0;
+ int sock;
- SSL_CTX *ctx;
- BIO *bio;
- SSL *ssl;
- mm_TLSSock *ret;
+ SSL_CTX *ctx;
+ BIO *bio;
+ SSL *ssl;
+ mm_TLSSock *ret;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:sock",
- kwlist, &sockObj, &serverMode))
- return NULL;
- assert(mm_TLSContext_Check(self));
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:sock",
+ kwlist, &sockObj, &serverMode))
+ return NULL;
+ assert(mm_TLSContext_Check(self));
- if ((sock = PyObject_AsFileDescriptor(sockObj)) < 0) {
- TYPE_ERR("TLSContext.sock requires a socket");
- return NULL;
- }
+ if ((sock = PyObject_AsFileDescriptor(sockObj)) < 0) {
+ TYPE_ERR("TLSContext.sock requires a socket");
+ return NULL;
+ }
- ctx = ((mm_TLSContext*)self)->ctx;
+ ctx = ((mm_TLSContext*)self)->ctx;
- if (!(ssl = SSL_new(ctx))) {
- mm_SSL_ERR(0); return NULL;
- }
+ if (!(ssl = SSL_new(ctx))) {
+ mm_SSL_ERR(0); return NULL;
+ }
- if (serverMode && !SSL_set_cipher_list(ssl,
- TLS1_TXT_DHE_RSA_WITH_AES_128_SHA ":"
- SSL3_TXT_RSA_DES_192_CBC3_SHA)) {
- mm_SSL_ERR(0); SSL_free(ssl); return NULL;
- }
+ if (serverMode && !SSL_set_cipher_list(ssl,
+ TLS1_TXT_DHE_RSA_WITH_AES_128_SHA ":"
+ SSL3_TXT_RSA_DES_192_CBC3_SHA)) {
+ mm_SSL_ERR(0); SSL_free(ssl); return NULL;
+ }
- if (!(bio = BIO_new_socket(sock, BIO_NOCLOSE))) {
- SSL_free(ssl); mm_SSL_ERR(0); return NULL;
- }
- SSL_set_bio(ssl,bio,bio);
+ if (!(bio = BIO_new_socket(sock, BIO_NOCLOSE))) {
+ SSL_free(ssl); mm_SSL_ERR(0); return NULL;
+ }
+ SSL_set_bio(ssl,bio,bio);
- if (!(ret = PyObject_New(mm_TLSSock, &mm_TLSSock_Type))) {
- SSL_free(ssl); PyErr_NoMemory(); SSL_free(ssl); return NULL;
- }
- ret->ssl = ssl;
- ret->context = self;
- ret->sock = sock;
- ret->sockObj = sockObj;
- Py_INCREF(self);
- Py_INCREF(sockObj);
- return (PyObject*)ret;
+ if (!(ret = PyObject_New(mm_TLSSock, &mm_TLSSock_Type))) {
+ SSL_free(ssl); PyErr_NoMemory(); SSL_free(ssl); return NULL;
+ }
+ ret->ssl = ssl;
+ ret->context = self;
+ ret->sock = sock;
+ ret->sockObj = sockObj;
+ Py_INCREF(self);
+ Py_INCREF(sockObj);
+ return (PyObject*)ret;
}
static PyMethodDef mm_TLSContext_methods[] = {
- METHOD(mm_TLSContext, sock),
- { NULL, NULL }
+ METHOD(mm_TLSContext, sock),
+ { NULL, NULL }
};
static PyObject*
mm_TLSContext_getattr(PyObject *self, char *name)
{
- return Py_FindMethod(mm_TLSContext_methods, self, name);
+ return Py_FindMethod(mm_TLSContext_methods, self, name);
}
static const char mm_TLSContext_Type__doc__[] =
@@ -258,30 +258,30 @@
"sockets. It has a single method, 'sock()', to create new sockets.\n";
PyTypeObject mm_TLSContext_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /*ob_size*/
- "mixminion._minionlib.TLSContext", /*tp_name*/
- sizeof(mm_TLSContext), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)mm_TLSContext_dealloc, /*tp_dealloc*/
- (printfunc)0, /*tp_print*/
- (getattrfunc)mm_TLSContext_getattr, /*tp_getattr*/
- (setattrfunc)0, /*tp_setattr*/
- 0,0,
- 0,0,0,
- 0,0,0,0,0,
- 0,0,
- (char*)mm_TLSContext_Type__doc__
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /*ob_size*/
+ "mixminion._minionlib.TLSContext", /*tp_name*/
+ sizeof(mm_TLSContext), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)mm_TLSContext_dealloc, /*tp_dealloc*/
+ (printfunc)0, /*tp_print*/
+ (getattrfunc)mm_TLSContext_getattr, /*tp_getattr*/
+ (setattrfunc)0, /*tp_setattr*/
+ 0,0,
+ 0,0,0,
+ 0,0,0,0,0,
+ 0,0,
+ (char*)mm_TLSContext_Type__doc__
};
static void
mm_TLSSock_dealloc(mm_TLSSock *self)
{
- Py_DECREF(self->context);
- Py_DECREF(self->sockObj);
- SSL_free(self->ssl);
- PyObject_DEL(self);
+ Py_DECREF(self->context);
+ Py_DECREF(self->sockObj);
+ SSL_free(self->ssl);
+ PyObject_DEL(self);
}
static char mm_TLSSock_accept__doc__[] =
@@ -292,22 +292,22 @@
static PyObject*
mm_TLSSock_accept(PyObject *self, PyObject *args, PyObject *kwargs)
{
- SSL *ssl;
- int r;
+ SSL *ssl;
+ int r;
- assert(mm_TLSSock_Check(self));
- FAIL_IF_ARGS();
+ assert(mm_TLSSock_Check(self));
+ FAIL_IF_ARGS();
- ssl = ((mm_TLSSock*)self)->ssl;
- Py_BEGIN_ALLOW_THREADS
- r = SSL_accept(ssl);
- Py_END_ALLOW_THREADS
+ ssl = ((mm_TLSSock*)self)->ssl;
+ Py_BEGIN_ALLOW_THREADS
+ r = SSL_accept(ssl);
+ Py_END_ALLOW_THREADS
- if (tls_error(ssl, r, 0))
- return NULL;
+ if (tls_error(ssl, r, 0))
+ return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static char mm_TLSSock_connect__doc__[] =
@@ -318,23 +318,23 @@
static PyObject*
mm_TLSSock_connect(PyObject *self, PyObject *args, PyObject *kwargs)
{
- SSL *ssl;
- int r, err;
+ SSL *ssl;
+ int r, err;
- assert(mm_TLSSock_Check(self));
- FAIL_IF_ARGS();
+ assert(mm_TLSSock_Check(self));
+ FAIL_IF_ARGS();
- ssl = ((mm_TLSSock*)self)->ssl;
+ ssl = ((mm_TLSSock*)self)->ssl;
- Py_BEGIN_ALLOW_THREADS
- r = SSL_connect(ssl);
- Py_END_ALLOW_THREADS
- err = SSL_get_error(ssl,r);
- if (tls_error(ssl, r, 0))
- return NULL;
+ Py_BEGIN_ALLOW_THREADS
+ r = SSL_connect(ssl);
+ Py_END_ALLOW_THREADS
+ err = SSL_get_error(ssl,r);
+ if (tls_error(ssl, r, 0))
+ return NULL;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static char mm_TLSSock_pending__doc__[] =
@@ -344,14 +344,14 @@
static PyObject*
mm_TLSSock_pending(PyObject *self, PyObject *args, PyObject *kwargs)
{
- SSL *ssl;
+ SSL *ssl;
- assert(mm_TLSSock_Check(self));
- FAIL_IF_ARGS();
+ assert(mm_TLSSock_Check(self));
+ FAIL_IF_ARGS();
- ssl = ((mm_TLSSock*)self)->ssl;
+ ssl = ((mm_TLSSock*)self)->ssl;
- return PyInt_FromLong(SSL_pending(ssl));
+ return PyInt_FromLong(SSL_pending(ssl));
}
static char mm_TLSSock_read__doc__[] =
@@ -364,43 +364,43 @@
static PyObject*
mm_TLSSock_read(PyObject *self, PyObject *args, PyObject *kwargs)
{
- static char *kwlist[] = { "size", NULL };
- int n;
- SSL *ssl;
- int r;
- PyObject *res;
+ static char *kwlist[] = { "size", NULL };
+ int n;
+ SSL *ssl;
+ int r;
+ PyObject *res;
- assert(mm_TLSSock_Check(self));
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:read", kwlist,
- &n))
- return NULL;
+ assert(mm_TLSSock_Check(self));
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:read", kwlist,
+ &n))
+ return NULL;
- ssl = ((mm_TLSSock*)self)->ssl;
+ ssl = ((mm_TLSSock*)self)->ssl;
- if (!(res = PyString_FromStringAndSize(NULL, n))) {
- PyErr_NoMemory(); return NULL;
- }
+ if (!(res = PyString_FromStringAndSize(NULL, n))) {
+ PyErr_NoMemory(); return NULL;
+ }
- Py_BEGIN_ALLOW_THREADS
- r = SSL_read(ssl, PyString_AS_STRING(res), n);
- Py_END_ALLOW_THREADS
- if (r > 0) {
- if (r != n && _PyString_Resize(&res,r) < 0) {
- return NULL;
- }
- return res;
- }
- Py_DECREF(res);
- switch (tls_error(ssl, r, IGNORE_ZERO_RETURN)) {
- case NO_ERROR:
- Py_INCREF(Py_None);
- return Py_None;
- case ZERO_RETURN:
- return PyInt_FromLong(0);
- case ERROR:
- default:
- return NULL;
- }
+ Py_BEGIN_ALLOW_THREADS
+ r = SSL_read(ssl, PyString_AS_STRING(res), n);
+ Py_END_ALLOW_THREADS
+ if (r > 0) {
+ if (r != n && _PyString_Resize(&res,r) < 0) {
+ return NULL;
+ }
+ return res;
+ }
+ Py_DECREF(res);
+ switch (tls_error(ssl, r, IGNORE_ZERO_RETURN)) {
+ case NO_ERROR:
+ Py_INCREF(Py_None);
+ return Py_None;
+ case ZERO_RETURN:
+ return PyInt_FromLong(0);
+ case ERROR:
+ default:
+ return NULL;
+ }
}
static char mm_TLSSock_write__doc__[] =
@@ -414,33 +414,33 @@
static PyObject*
mm_TLSSock_write(PyObject *self, PyObject *args, PyObject *kwargs)
{
- static char *kwlist[] = { "s", NULL };
- char *string;
- int stringlen;
- SSL *ssl;
- int r;
+ static char *kwlist[] = { "s", NULL };
+ char *string;
+ int stringlen;
+ SSL *ssl;
+ int r;
- assert(mm_TLSSock_Check(self));
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:write", kwlist,
- &string, &stringlen))
- return NULL;
+ assert(mm_TLSSock_Check(self));
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:write", kwlist,
+ &string, &stringlen))
+ return NULL;
- ssl = ((mm_TLSSock*)self)->ssl;
+ ssl = ((mm_TLSSock*)self)->ssl;
- Py_BEGIN_ALLOW_THREADS
- r = SSL_write(ssl, string, stringlen);
- Py_END_ALLOW_THREADS
+ Py_BEGIN_ALLOW_THREADS
+ r = SSL_write(ssl, string, stringlen);
+ Py_END_ALLOW_THREADS
- switch(tls_error(ssl, r, IGNORE_ZERO_RETURN)) {
- case NO_ERROR:
- return PyInt_FromLong(r);
- case ZERO_RETURN:
- return PyInt_FromLong(0);
- case ERROR:
- default:
- return NULL;
+ switch(tls_error(ssl, r, IGNORE_ZERO_RETURN)) {
+ case NO_ERROR:
+ return PyInt_FromLong(r);
+ case ZERO_RETURN:
+ return PyInt_FromLong(0);
+ case ERROR:
+ default:
+ return NULL;
- }
+ }
}
static char mm_TLSSock_shutdown__doc__[] =
@@ -452,24 +452,24 @@
static PyObject*
mm_TLSSock_shutdown(PyObject *self, PyObject *args, PyObject *kwargs)
{
- SSL *ssl;
- int r;
+ SSL *ssl;
+ int r;
- assert(mm_TLSSock_Check(self));
- FAIL_IF_ARGS();
+ assert(mm_TLSSock_Check(self));
+ FAIL_IF_ARGS();
- ssl = ((mm_TLSSock*)self)->ssl;
+ ssl = ((mm_TLSSock*)self)->ssl;
- Py_BEGIN_ALLOW_THREADS
- r = SSL_shutdown(ssl);
- Py_END_ALLOW_THREADS
- if (r == 1) return PyInt_FromLong(1);
- if (tls_error(ssl, r, IGNORE_SYSCALL))
- return NULL;
- if (r == 0) return PyInt_FromLong(0);
+ Py_BEGIN_ALLOW_THREADS
+ r = SSL_shutdown(ssl);
+ Py_END_ALLOW_THREADS
+ if (r == 1) return PyInt_FromLong(1);
+ if (tls_error(ssl, r, IGNORE_SYSCALL))
+ return NULL;
+ if (r == 0) return PyInt_FromLong(0);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static char mm_TLSSock_fileno__doc__[] =
@@ -480,10 +480,10 @@
mm_TLSSock_fileno(PyObject *self, PyObject *args, PyObject *kwargs)
{
- assert(mm_TLSSock_Check(self));
- FAIL_IF_ARGS();
+ assert(mm_TLSSock_Check(self));
+ FAIL_IF_ARGS();
- return PyInt_FromLong(((mm_TLSSock*)self)->sock);
+ return PyInt_FromLong(((mm_TLSSock*)self)->sock);
}
static char mm_TLSSock_get_peer_cert_pk__doc__[] =
@@ -494,49 +494,49 @@
static PyObject*
mm_TLSSock_get_peer_cert_pk(PyObject *self, PyObject *args, PyObject *kwargs)
{
- SSL *ssl;
- X509 *cert;
- EVP_PKEY *pkey;
- RSA *rsa;
- mm_RSA *result;
+ SSL *ssl;
+ X509 *cert;
+ EVP_PKEY *pkey;
+ RSA *rsa;
+ mm_RSA *result;
- assert(mm_TLSSock_Check(self));
- FAIL_IF_ARGS();
+ assert(mm_TLSSock_Check(self));
+ FAIL_IF_ARGS();
- ssl = ((mm_TLSSock*)self)->ssl;
- if (!(cert = SSL_get_peer_certificate(ssl))) {
- mm_SSL_ERR(0); return NULL;
- }
- pkey = X509_get_pubkey(cert);
- if (!(rsa = EVP_PKEY_get1_RSA(pkey))) {
- EVP_PKEY_free(pkey); mm_SSL_ERR(0); return NULL;
- }
- EVP_PKEY_free(pkey);
+ ssl = ((mm_TLSSock*)self)->ssl;
+ if (!(cert = SSL_get_peer_certificate(ssl))) {
+ mm_SSL_ERR(0); return NULL;
+ }
+ pkey = X509_get_pubkey(cert);
+ if (!(rsa = EVP_PKEY_get1_RSA(pkey))) {
+ EVP_PKEY_free(pkey); mm_SSL_ERR(0); return NULL;
+ }
+ EVP_PKEY_free(pkey);
- if (!(result = PyObject_New(mm_RSA, &mm_RSA_Type))) {
- RSA_free(rsa); PyErr_NoMemory(); return NULL;
- }
- result->rsa = rsa;
+ if (!(result = PyObject_New(mm_RSA, &mm_RSA_Type))) {
+ RSA_free(rsa); PyErr_NoMemory(); return NULL;
+ }
+ result->rsa = rsa;
- return (PyObject*) result;
+ return (PyObject*) result;
}
static PyMethodDef mm_TLSSock_methods[] = {
- METHOD(mm_TLSSock, accept),
- METHOD(mm_TLSSock, connect),
- METHOD(mm_TLSSock, pending),
- METHOD(mm_TLSSock, read),
- METHOD(mm_TLSSock, write),
- METHOD(mm_TLSSock, shutdown),
- METHOD(mm_TLSSock, get_peer_cert_pk),
- METHOD(mm_TLSSock, fileno),
- { NULL, NULL }
+ METHOD(mm_TLSSock, accept),
+ METHOD(mm_TLSSock, connect),
+ METHOD(mm_TLSSock, pending),
+ METHOD(mm_TLSSock, read),
+ METHOD(mm_TLSSock, write),
+ METHOD(mm_TLSSock, shutdown),
+ METHOD(mm_TLSSock, get_peer_cert_pk),
+ METHOD(mm_TLSSock, fileno),
+ { NULL, NULL }
};
static PyObject*
mm_TLSSock_getattr(PyObject *self, char *name)
{
- return Py_FindMethod(mm_TLSSock_methods, self, name);
+ return Py_FindMethod(mm_TLSSock_methods, self, name);
}
static const char mm_TLSSock_Type__doc__[] =
@@ -544,26 +544,27 @@
"A single TLS connection.";
PyTypeObject mm_TLSSock_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /*ob_size*/
- "mixminion._minionlib.TLSSock", /*tp_name*/
- sizeof(mm_TLSSock), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)mm_TLSSock_dealloc, /*tp_dealloc*/
- (printfunc)0, /*tp_print*/
- (getattrfunc)mm_TLSSock_getattr, /*tp_getattr*/
- (setattrfunc)0, /*tp_setattr*/
- 0,0,
- 0,0,0,
- 0,0,0,0,0,
- 0,0,
- (char*)mm_TLSSock_Type__doc__
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /*ob_size*/
+ "mixminion._minionlib.TLSSock", /*tp_name*/
+ sizeof(mm_TLSSock), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)mm_TLSSock_dealloc, /*tp_dealloc*/
+ (printfunc)0, /*tp_print*/
+ (getattrfunc)mm_TLSSock_getattr, /*tp_getattr*/
+ (setattrfunc)0, /*tp_setattr*/
+ 0,0,
+ 0,0,0,
+ 0,0,0,0,0,
+ 0,0,
+ (char*)mm_TLSSock_Type__doc__
};
/*
Local Variables:
mode:c
+ indent-tabs-mode:nil
c-basic-offset:8
End:
*/