[Pymoul-svn] SF.net SVN: pymoul: [227] xtea/trunk
Status: Alpha
Brought to you by:
tiran
From: <ti...@us...> - 2007-03-04 02:38:37
|
Revision: 227 http://pymoul.svn.sourceforge.net/pymoul/?rev=227&view=rev Author: tiran Date: 2007-03-03 18:38:37 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Renamed some files Modified Paths: -------------- xtea/trunk/setup.py xtea/trunk/src/xtea/tea.py xtea/trunk/src/xtea/xtea.py xtea/trunk/src/xtea/xxtea.py Added Paths: ----------- xtea/trunk/src/xtea/_pyxtea.c xtea/trunk/src/xtea/_pyxtea.pyx xtea/trunk/src/xtea/ctea.c xtea/trunk/src/xtea/ctea.h Removed Paths: ------------- xtea/trunk/src/xtea/_xtea.c xtea/trunk/src/xtea/_xtea.pyx xtea/trunk/src/xtea/cxtea.c xtea/trunk/src/xtea/cxtea.h Modified: xtea/trunk/setup.py =================================================================== --- xtea/trunk/setup.py 2007-03-04 02:21:04 UTC (rev 226) +++ xtea/trunk/setup.py 2007-03-04 02:38:37 UTC (rev 227) @@ -38,7 +38,7 @@ me = "Christian Heimes" email = "chr...@ch..." -cxtea = Extension('xtea._xtea', ['src/xtea/_xtea.pyx', 'src/xtea/cxtea.c']) +cxtea = Extension('xtea._pyxtea', ['src/xtea/_pyxtea.pyx', 'src/xtea/ctea.c']) ext_modules = [] if os.name == 'posix': ext_modules.append(cxtea) Copied: xtea/trunk/src/xtea/_pyxtea.c (from rev 226, xtea/trunk/src/xtea/_xtea.c) =================================================================== --- xtea/trunk/src/xtea/_pyxtea.c (rev 0) +++ xtea/trunk/src/xtea/_pyxtea.c 2007-03-04 02:38:37 UTC (rev 227) @@ -0,0 +1,1002 @@ +/* Generated by Pyrex 0.9.5.1a on Sun Mar 4 03:32:36 2007 */ + +#include "Python.h" +#include "structmember.h" +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifdef __cplusplus +#define __PYX_EXTERN_C extern "C" +#else +#define __PYX_EXTERN_C extern +#endif +__PYX_EXTERN_C double pow(double, double); +#include "stdlib.h" +#include "ctea.h" + + +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static int __pyx_lineno; +static char *__pyx_filename; +static char **__pyx_f; + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +static void __Pyx_AddTraceback(char *funcname); /*proto*/ + +/* Declarations from _pyxtea */ + + + +/* Implementation of _pyxtea */ + +static PyObject *__pyx_n__c_tea_encrypt; +static PyObject *__pyx_n__c_tea_decrypt; +static PyObject *__pyx_n__c_xtea_encrypt; +static PyObject *__pyx_n__c_xtea_decrypt; +static PyObject *__pyx_n__c_xxtea_encrypt; +static PyObject *__pyx_n__c_xxtea_decrypt; + +static PyObject *__pyx_f_7_pyxtea__c_tea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_pyxtea__c_tea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_block = 0; + PyObject *__pyx_v_key = 0; + unsigned int __pyx_v_rounds; + unsigned long (__pyx_v_v[2]); + unsigned long (__pyx_v_k[4]); + PyObject *__pyx_v_rc; + PyObject *__pyx_v_result; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + unsigned long __pyx_3; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {"block","key","rounds",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; + Py_INCREF(__pyx_v_block); + Py_INCREF(__pyx_v_key); + __pyx_v_rc = Py_None; Py_INCREF(Py_None); + __pyx_v_result = Py_None; Py_INCREF(Py_None); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":29 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":29 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":30 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":30 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":30 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":30 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[3]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":31 */ + __pyx_1 = PyInt_FromLong(tea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + Py_DECREF(__pyx_v_rc); + __pyx_v_rc = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":32 */ + __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_4, 0, __pyx_2); + PyList_SET_ITEM(__pyx_4, 1, __pyx_1); + __pyx_2 = 0; + __pyx_1 = 0; + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_4; + __pyx_4 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":33 */ + Py_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_pyxtea._c_tea_encrypt"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_rc); + Py_DECREF(__pyx_v_result); + Py_DECREF(__pyx_v_block); + Py_DECREF(__pyx_v_key); + return __pyx_r; +} + +static PyObject *__pyx_f_7_pyxtea__c_tea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_pyxtea__c_tea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_block = 0; + PyObject *__pyx_v_key = 0; + unsigned int __pyx_v_rounds; + unsigned long (__pyx_v_v[2]); + unsigned long (__pyx_v_k[4]); + PyObject *__pyx_v_rc; + PyObject *__pyx_v_result; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + unsigned long __pyx_3; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {"block","key","rounds",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; + Py_INCREF(__pyx_v_block); + Py_INCREF(__pyx_v_key); + __pyx_v_rc = Py_None; Py_INCREF(Py_None); + __pyx_v_result = Py_None; Py_INCREF(Py_None); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":38 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":38 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":39 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":39 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":39 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":39 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[3]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":40 */ + __pyx_1 = PyInt_FromLong(tea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;} + Py_DECREF(__pyx_v_rc); + __pyx_v_rc = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":41 */ + __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;} + __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_4, 0, __pyx_2); + PyList_SET_ITEM(__pyx_4, 1, __pyx_1); + __pyx_2 = 0; + __pyx_1 = 0; + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_4; + __pyx_4 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":42 */ + Py_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_pyxtea._c_tea_decrypt"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_rc); + Py_DECREF(__pyx_v_result); + Py_DECREF(__pyx_v_block); + Py_DECREF(__pyx_v_key); + return __pyx_r; +} + +static PyObject *__pyx_f_7_pyxtea__c_xtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_pyxtea__c_xtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_block = 0; + PyObject *__pyx_v_key = 0; + unsigned int __pyx_v_rounds; + unsigned long (__pyx_v_v[2]); + unsigned long (__pyx_v_k[4]); + PyObject *__pyx_v_rc; + PyObject *__pyx_v_result; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + unsigned long __pyx_3; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {"block","key","rounds",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; + Py_INCREF(__pyx_v_block); + Py_INCREF(__pyx_v_key); + __pyx_v_rc = Py_None; Py_INCREF(Py_None); + __pyx_v_result = Py_None; Py_INCREF(Py_None); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":49 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":49 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":50 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":50 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":50 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":50 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[3]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":51 */ + __pyx_1 = PyInt_FromLong(xtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;} + Py_DECREF(__pyx_v_rc); + __pyx_v_rc = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":52 */ + __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_4, 0, __pyx_2); + PyList_SET_ITEM(__pyx_4, 1, __pyx_1); + __pyx_2 = 0; + __pyx_1 = 0; + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_4; + __pyx_4 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":53 */ + Py_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_pyxtea._c_xtea_encrypt"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_rc); + Py_DECREF(__pyx_v_result); + Py_DECREF(__pyx_v_block); + Py_DECREF(__pyx_v_key); + return __pyx_r; +} + +static PyObject *__pyx_f_7_pyxtea__c_xtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_pyxtea__c_xtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_block = 0; + PyObject *__pyx_v_key = 0; + unsigned int __pyx_v_rounds; + unsigned long (__pyx_v_v[2]); + unsigned long (__pyx_v_k[4]); + PyObject *__pyx_v_rc; + PyObject *__pyx_v_result; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + unsigned long __pyx_3; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {"block","key","rounds",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; + Py_INCREF(__pyx_v_block); + Py_INCREF(__pyx_v_key); + __pyx_v_rc = Py_None; Py_INCREF(Py_None); + __pyx_v_result = Py_None; Py_INCREF(Py_None); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":58 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":58 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":59 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":59 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[1]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":59 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":59 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[3]) = __pyx_3; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":60 */ + __pyx_1 = PyInt_FromLong(xtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; goto __pyx_L1;} + Py_DECREF(__pyx_v_rc); + __pyx_v_rc = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":61 */ + __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} + __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_4, 0, __pyx_2); + PyList_SET_ITEM(__pyx_4, 1, __pyx_1); + __pyx_2 = 0; + __pyx_1 = 0; + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_4; + __pyx_4 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":62 */ + Py_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_pyxtea._c_xtea_decrypt"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_rc); + Py_DECREF(__pyx_v_result); + Py_DECREF(__pyx_v_block); + Py_DECREF(__pyx_v_key); + return __pyx_r; +} + +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_ValueError; +static PyObject *__pyx_n_append; + +static PyObject *__pyx_k1p; + +static char (__pyx_k1[]) = "len(block) %i != rounds %i"; + +static PyObject *__pyx_f_7_pyxtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_pyxtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_block = 0; + PyObject *__pyx_v_key = 0; + unsigned int __pyx_v_rounds; + unsigned long (__pyx_v_k[4]); + unsigned long (*__pyx_v_v); + int __pyx_v_rc; + int __pyx_v_size; + int __pyx_v_i; + PyObject *__pyx_v_result; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + PyObject *__pyx_5 = 0; + unsigned long __pyx_6; + static char *__pyx_argnames[] = {"block","key","rounds",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; + Py_INCREF(__pyx_v_block); + Py_INCREF(__pyx_v_key); + __pyx_v_result = Py_None; Py_INCREF(Py_None); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":69 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + Py_INCREF(__pyx_v_block); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_block); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_size = __pyx_4; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":70 */ + __pyx_4 = (__pyx_v_size != __pyx_v_rounds); + if (__pyx_4) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":71 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} + __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_2 = PyNumber_Remainder(__pyx_k1p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_1, __pyx_2, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":72 */ + __pyx_v_v = ((unsigned long (*))malloc(((sizeof(unsigned long )) * __pyx_v_size))); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":73 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":74 */ + __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_v[__pyx_v_i]) = __pyx_6; + } + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":75 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":75 */ + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[1]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":75 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":75 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[3]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":76 */ + __pyx_v_rc = xxtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":77 */ + __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; goto __pyx_L1;} + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":78 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":79 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + __pyx_3 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + } + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":80 */ + free(__pyx_v_v); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":81 */ + Py_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_pyxtea._c_xxtea_encrypt"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_result); + Py_DECREF(__pyx_v_block); + Py_DECREF(__pyx_v_key); + return __pyx_r; +} + +static PyObject *__pyx_k2p; + +static char (__pyx_k2[]) = "len(block) %i != rounds %i"; + +static PyObject *__pyx_f_7_pyxtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_pyxtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_block = 0; + PyObject *__pyx_v_key = 0; + unsigned int __pyx_v_rounds; + unsigned long (__pyx_v_k[4]); + unsigned long (*__pyx_v_v); + int __pyx_v_rc; + int __pyx_v_size; + int __pyx_v_i; + PyObject *__pyx_v_result; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + PyObject *__pyx_5 = 0; + unsigned long __pyx_6; + static char *__pyx_argnames[] = {"block","key","rounds",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; + Py_INCREF(__pyx_v_block); + Py_INCREF(__pyx_v_key); + __pyx_v_result = Py_None; Py_INCREF(Py_None); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":86 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;} + Py_INCREF(__pyx_v_block); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_block); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_size = __pyx_4; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":87 */ + __pyx_4 = (__pyx_v_size != __pyx_v_rounds); + if (__pyx_4) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":88 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_2 = PyNumber_Remainder(__pyx_k2p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_1, __pyx_2, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":89 */ + __pyx_v_v = ((unsigned long (*))malloc(((sizeof(unsigned long )) * __pyx_v_size))); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":90 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":91 */ + __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_v[__pyx_v_i]) = __pyx_6; + } + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":92 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":92 */ + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[1]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":92 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":92 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[3]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":93 */ + __pyx_v_rc = xxtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":94 */ + __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;} + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":95 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":96 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + __pyx_3 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + } + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":97 */ + free(__pyx_v_v); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":98 */ + Py_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_pyxtea._c_xxtea_decrypt"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_result); + Py_DECREF(__pyx_v_block); + Py_DECREF(__pyx_v_key); + return __pyx_r; +} + +static __Pyx_InternTabEntry __pyx_intern_tab[] = { + {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n__c_tea_decrypt, "_c_tea_decrypt"}, + {&__pyx_n__c_tea_encrypt, "_c_tea_encrypt"}, + {&__pyx_n__c_xtea_decrypt, "_c_xtea_decrypt"}, + {&__pyx_n__c_xtea_encrypt, "_c_xtea_encrypt"}, + {&__pyx_n__c_xxtea_decrypt, "_c_xxtea_decrypt"}, + {&__pyx_n__c_xxtea_encrypt, "_c_xxtea_encrypt"}, + {&__pyx_n_append, "append"}, + {&__pyx_n_len, "len"}, + {0, 0} +}; + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_k1p, __pyx_k1, sizeof(__pyx_k1)}, + {&__pyx_k2p, __pyx_k2, sizeof(__pyx_k2)}, + {0, 0, 0} +}; + +static struct PyMethodDef __pyx_methods[] = { + {"_c_tea_encrypt", (PyCFunction)__pyx_f_7_pyxtea__c_tea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_tea_decrypt", (PyCFunction)__pyx_f_7_pyxtea__c_tea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xtea_encrypt", (PyCFunction)__pyx_f_7_pyxtea__c_xtea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xtea_decrypt", (PyCFunction)__pyx_f_7_pyxtea__c_xtea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xxtea_encrypt", (PyCFunction)__pyx_f_7_pyxtea__c_xxtea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xxtea_decrypt", (PyCFunction)__pyx_f_7_pyxtea__c_xxtea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static void __pyx_init_filenames(void); /*proto*/ + +PyMODINIT_FUNC init_pyxtea(void); /*proto*/ +PyMODINIT_FUNC init_pyxtea(void) { + __pyx_init_filenames(); + __pyx_m = Py_InitModule4("_pyxtea", __pyx_methods, 0, 0, PYTHON_API_VERSION); + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}; + __pyx_b = PyImport_AddModule("__builtin__"); + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}; + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}; + if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}; + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_pyxtea.pyx":83 */ + return; + __pyx_L1:; + __Pyx_AddTraceback("_pyxtea"); +} + +static char *__pyx_filenames[] = { + "_pyxtea.pyx", +}; + +/* Runtime support code */ + +static void __pyx_init_filenames(void) { + __pyx_f = __pyx_filenames; +} + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) + PyErr_SetObject(PyExc_NameError, name); + return result; +} + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { + Py_XINCREF(type); + Py_XINCREF(value); + Py_XINCREF(tb); + /* First, check the traceback argument, replacing None with NULL. */ + if (tb == Py_None) { + Py_DECREF(tb); + tb = 0; + } + else if (tb != NULL && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + /* Next, replace a missing value with None */ + if (value == NULL) { + value = Py_None; + Py_INCREF(value); + } + /* Next, repeatedly, replace a tuple exception with its first item */ + while (PyTuple_Check(type) && PyTuple_Size(type) > 0) { + PyObject *tmp = type; + type = PyTuple_GET_ITEM(type, 0); + Py_INCREF(type); + Py_DECREF(tmp); + } + if (PyString_Check(type)) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "raising a string exception is deprecated")) + goto raise_error; + } + else if (PyType_Check(type) || PyClass_Check(type)) + ; /*PyErr_NormalizeException(&type, &value, &tb);*/ + else { + /* Raising an instance. The value should be a dummy. */ + if (value != Py_None) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + /* Normalize to raise <class>, <instance> */ + Py_DECREF(value); + value = type; + if (PyInstance_Check(type)) + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + else + type = (PyObject*) type->ob_type; + Py_INCREF(type); + } + PyErr_Restore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { + while (t->p) { + *t->p = PyString_InternFromString(t->s); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" + +static void __Pyx_AddTraceback(char *funcname) { + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + PyObject *py_globals = 0; + PyObject *empty_tuple = 0; + PyObject *empty_string = 0; + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + + py_srcfile = PyString_FromString(__pyx_filename); + if (!py_srcfile) goto bad; + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + empty_tuple = PyTuple_New(0); + if (!empty_tuple) goto bad; + empty_string = PyString_FromString(""); + if (!empty_string) goto bad; + py_code = PyCode_New( + 0, /*int argcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + empty_string, /*PyObject *code,*/ + empty_tuple, /*PyObject *consts,*/ + empty_tuple, /*PyObject *names,*/ + empty_tuple, /*PyObject *varnames,*/ + empty_tuple, /*PyObject *freevars,*/ + empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + __pyx_lineno, /*int firstlineno,*/ + empty_string /*PyObject *lnotab*/ + ); + if (!py_code) goto bad; + py_frame = PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = __pyx_lineno; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + Py_XDECREF(empty_tuple); + Py_XDECREF(empty_string); + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} Copied: xtea/trunk/src/xtea/_pyxtea.pyx (from rev 226, xtea/trunk/src/xtea/_xtea.pyx) =================================================================== --- xtea/trunk/src/xtea/_pyxtea.pyx (rev 0) +++ xtea/trunk/src/xtea/_pyxtea.pyx 2007-03-04 02:38:37 UTC (rev 227) @@ -0,0 +1,98 @@ +# Copyright (C) 2007 Christian Heimes <christian (at) cheimes (dot) de> +# pyrexc optimized version +# License: Public Domain + +# http://www.python.org/dev/peps/pep-0272/ + +ctypedef unsigned long ULong +ctypedef unsigned int UInt + +cdef extern from "stdlib.h": + ctypedef unsigned long size_t + void *malloc(size_t size) + void free(void* ptr) + size_t sizeof(void *) + +cdef extern from "ctea.h": + int tea_decipher(ULong *v, ULong *k, UInt n) + int tea_encipher(ULong *v, ULong *k, UInt n) + int xtea_decipher(ULong *v, ULong *k, UInt n) + int xtea_encipher(ULong *v, ULong *k, UInt n) + int xxtea_decipher(ULong *v, ULong *k, UInt n) + int xxtea_encipher(ULong *v, ULong *k, UInt n) + +# *** TEA *** + +def _c_tea_encrypt(object block, object key, UInt rounds): + cdef ULong v[2] + cdef ULong k[4] + v[0] = block[0]; v[1] = block[1] + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = tea_encipher(v, k, rounds) + result = [v[0], v[1]] + return result + +def _c_tea_decrypt(object block, object key, UInt rounds): + cdef ULong v[2] + cdef ULong k[4] + v[0] = block[0]; v[1] = block[1] + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = tea_decipher(v, k, rounds) + result = [v[0], v[1]] + return result + +# *** XTEA *** + +def _c_xtea_encrypt(object block, object key, UInt rounds): + cdef ULong v[2] + cdef ULong k[4] + v[0] = block[0]; v[1] = block[1] + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = xtea_encipher(v, k, rounds) + result = [v[0], v[1]] + return result + +def _c_xtea_decrypt(object block, object key, UInt rounds): + cdef ULong v[2] + cdef ULong k[4] + v[0] = block[0]; v[1] = block[1] + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = xtea_decipher(v, k, rounds) + result = [v[0], v[1]] + return result + +# *** XXTEA *** + +def _c_xxtea_encrypt(object block, key, UInt rounds): + cdef ULong k[4], *v + cdef int rc, size, i + size = len(block) + if size != rounds: + raise ValueError, "len(block) %i != rounds %i" % (size, rounds) + v = <ULong *>malloc(sizeof(ULong) * size) + for i from 0 <= i < size: + v[i] = block[i] + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = xxtea_encipher(v, k, rounds) + result = [] + for i from 0 <= i < size: + result.append(v[i]) + free(v) + return result + +def _c_xxtea_decrypt(object block, key, UInt rounds): + cdef ULong k[4], *v + cdef int rc, size, i + size = len(block) + if size != rounds: + raise ValueError, "len(block) %i != rounds %i" % (size, rounds) + v = <ULong *>malloc(sizeof(ULong) * size) + for i from 0 <= i < size: + v[i] = block[i] + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = xxtea_decipher(v, k, rounds) + result = [] + for i from 0 <= i < size: + result.append(v[i]) + free(v) + return result Deleted: xtea/trunk/src/xtea/_xtea.c =================================================================== --- xtea/trunk/src/xtea/_xtea.c 2007-03-04 02:21:04 UTC (rev 226) +++ xtea/trunk/src/xtea/_xtea.c 2007-03-04 02:38:37 UTC (rev 227) @@ -1,1002 +0,0 @@ -/* Generated by Pyrex 0.9.5.1a on Sun Mar 4 03:00:20 2007 */ - -#include "Python.h" -#include "structmember.h" -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifdef __cplusplus -#define __PYX_EXTERN_C extern "C" -#else -#define __PYX_EXTERN_C extern -#endif -__PYX_EXTERN_C double pow(double, double); -#include "stdlib.h" -#include "cxtea.h" - - -typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ -typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ - -static PyObject *__pyx_m; -static PyObject *__pyx_b; -static int __pyx_lineno; -static char *__pyx_filename; -static char **__pyx_f; - -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ - -static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ - -static void __Pyx_AddTraceback(char *funcname); /*proto*/ - -/* Declarations from _xtea */ - - - -/* Implementation of _xtea */ - -static PyObject *__pyx_n__c_tea_encrypt; -static PyObject *__pyx_n__c_tea_decrypt; -static PyObject *__pyx_n__c_xtea_encrypt; -static PyObject *__pyx_n__c_xtea_decrypt; -static PyObject *__pyx_n__c_xxtea_encrypt; -static PyObject *__pyx_n__c_xxtea_decrypt; - -static PyObject *__pyx_f_5_xtea__c_tea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_tea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_block = 0; - PyObject *__pyx_v_key = 0; - unsigned int __pyx_v_rounds; - unsigned long (__pyx_v_v[2]); - unsigned long (__pyx_v_k[4]); - PyObject *__pyx_v_rc; - PyObject *__pyx_v_result; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - unsigned long __pyx_3; - PyObject *__pyx_4 = 0; - static char *__pyx_argnames[] = {"block","key","rounds",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; - Py_INCREF(__pyx_v_block); - Py_INCREF(__pyx_v_key); - __pyx_v_rc = Py_None; Py_INCREF(Py_None); - __pyx_v_result = Py_None; Py_INCREF(Py_None); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":29 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_v[0]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":29 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_v[1]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":30 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_k[0]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":30 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_k[1]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":30 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_k[2]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":30 */ - __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_k[3]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":31 */ - __pyx_1 = PyInt_FromLong(tea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} - Py_DECREF(__pyx_v_rc); - __pyx_v_rc = __pyx_1; - __pyx_1 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":32 */ - __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - PyList_SET_ITEM(__pyx_4, 0, __pyx_2); - PyList_SET_ITEM(__pyx_4, 1, __pyx_1); - __pyx_2 = 0; - __pyx_1 = 0; - Py_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_4; - __pyx_4 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":33 */ - Py_INCREF(__pyx_v_result); - __pyx_r = __pyx_v_result; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("_xtea._c_tea_encrypt"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_rc); - Py_DECREF(__pyx_v_result); - Py_DECREF(__pyx_v_block); - Py_DECREF(__pyx_v_key); - return __pyx_r; -} - -static PyObject *__pyx_f_5_xtea__c_tea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_tea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_block = 0; - PyObject *__pyx_v_key = 0; - unsigned int __pyx_v_rounds; - unsigned long (__pyx_v_v[2]); - unsigned long (__pyx_v_k[4]); - PyObject *__pyx_v_rc; - PyObject *__pyx_v_result; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - unsigned long __pyx_3; - PyObject *__pyx_4 = 0; - static char *__pyx_argnames[] = {"block","key","rounds",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOI", __pyx_argnames, &__pyx_v_block, &__pyx_v_key, &__pyx_v_rounds)) return 0; - Py_INCREF(__pyx_v_block); - Py_INCREF(__pyx_v_key); - __pyx_v_rc = Py_None; Py_INCREF(Py_None); - __pyx_v_result = Py_None; Py_INCREF(Py_None); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":38 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_v[0]) = __pyx_3; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":38 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx... [truncated message content] |