Thread: [Pymoul-svn] SF.net SVN: pymoul: [223] xtea/trunk/src/xtea
Status: Alpha
Brought to you by:
tiran
From: <ti...@us...> - 2007-03-02 14:54:16
|
Revision: 223 http://pymoul.svn.sourceforge.net/pymoul/?rev=223&view=rev Author: tiran Date: 2007-03-02 06:54:09 -0800 (Fri, 02 Mar 2007) Log Message: ----------- Added xxtea algorithm to c/pyrex code Modified 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/src/xtea/_xtea.c =================================================================== --- xtea/trunk/src/xtea/_xtea.c 2007-03-01 17:41:40 UTC (rev 222) +++ xtea/trunk/src/xtea/_xtea.c 2007-03-02 14:54:09 UTC (rev 223) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.4.1 on Thu Mar 1 15:44:44 2007 */ +/* Generated by Pyrex 0.9.4.1 on Fri Mar 2 15:53:19 2007 */ #include "Python.h" #include "structmember.h" @@ -11,6 +11,7 @@ #define __PYX_EXTERN_C extern #endif __PYX_EXTERN_C double pow(double, double); +#include "stdlib.h" #include "cxtea.h" @@ -48,13 +49,10 @@ /* Implementation of _xtea */ -static PyObject *__pyx_n_MODE_ECB; -static PyObject *__pyx_n_MODE_CBC; -static PyObject *__pyx_n_MODE_CFB; -static PyObject *__pyx_n_MODE_OFB; -static PyObject *__pyx_n_MODE_CTR; static PyObject *__pyx_n__c_xtea_encryptQuad; -static PyObject *__pyx_n__c_xtea_decryptQuad; +static PyObject *__pyx_n__c_xxtea_decryptQuad; +static PyObject *__pyx_n__c_xxtea_encrypt; +static PyObject *__pyx_n__c_xxtea_decrypt; static PyObject *__pyx_f_5_xtea__c_xtea_encryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_5_xtea__c_xtea_encryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -64,6 +62,7 @@ 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; @@ -73,62 +72,66 @@ static char *__pyx_argnames[] = {"v0","v1","key","rounds",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "kkOI", __pyx_argnames, &__pyx_v_v0, &__pyx_v_v1, &__pyx_v_key, &__pyx_v_rounds)) return 0; 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":24 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":25 */ (__pyx_v_v[0]) = __pyx_v_v0; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":24 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":25 */ (__pyx_v_v[1]) = __pyx_v_v1; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":25 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":26 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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 = 25; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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":25 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":26 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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 = 25; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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":25 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":26 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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 = 25; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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":25 */ - __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":26 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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 = 25; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; 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":26 */ - encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":27 */ - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} - __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} - __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} - PyList_SET_ITEM(__pyx_4, 0, __pyx_1); - PyList_SET_ITEM(__pyx_4, 1, __pyx_2); + __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 = 27; 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":28 */ + __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} + __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; 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":28 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":29 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -142,19 +145,21 @@ __Pyx_AddTraceback("_xtea._c_xtea_encryptQuad"); __pyx_r = 0; __pyx_L0:; + Py_DECREF(__pyx_v_rc); Py_DECREF(__pyx_v_result); Py_DECREF(__pyx_v_key); return __pyx_r; } -static PyObject *__pyx_f_5_xtea__c_xtea_decryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xtea_decryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_f_5_xtea__c_xxtea_decryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__c_xxtea_decryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { unsigned long __pyx_v_v0; unsigned long __pyx_v_v1; 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; @@ -164,62 +169,66 @@ static char *__pyx_argnames[] = {"v0","v1","key","rounds",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "kkOI", __pyx_argnames, &__pyx_v_v0, &__pyx_v_v1, &__pyx_v_key, &__pyx_v_rounds)) return 0; 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":33 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":34 */ (__pyx_v_v[0]) = __pyx_v_v0; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":33 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":34 */ (__pyx_v_v[1]) = __pyx_v_v1; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":34 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":35 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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 = 34; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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":34 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":35 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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 = 34; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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":34 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":35 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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 = 34; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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":34 */ - __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":35 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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 = 34; goto __pyx_L1;} + __pyx_3 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; 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":35 */ - decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":36 */ - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} - __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} - __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} - PyList_SET_ITEM(__pyx_4, 0, __pyx_1); - PyList_SET_ITEM(__pyx_4, 1, __pyx_2); + __pyx_1 = PyInt_FromLong(xxtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; 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":37 */ + __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; 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":37 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":38 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -230,28 +239,307 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("_xtea._c_xtea_decryptQuad"); + __Pyx_AddTraceback("_xtea._c_xxtea_decryptQuad"); __pyx_r = 0; __pyx_L0:; + Py_DECREF(__pyx_v_rc); Py_DECREF(__pyx_v_result); Py_DECREF(__pyx_v_key); return __pyx_r; } +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_append; + +static PyObject *__pyx_f_5_xtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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_vsize; + 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; + unsigned long __pyx_5; + 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/_xtea.pyx":43 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; 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 = 43; 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 = 43; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_size = __pyx_4; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":44 */ + __pyx_v_vsize = ((sizeof(unsigned long )) * __pyx_v_size); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":45 */ + __pyx_v_v = ((unsigned long (*))malloc(__pyx_v_vsize)); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":46 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":47 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[__pyx_v_i]) = __pyx_5; + __pyx_L2:; + } + __pyx_L3:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ + __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + (__pyx_v_k[0]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_v_key, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + (__pyx_v_k[1]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + (__pyx_v_k[3]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":49 */ + __pyx_v_rc = xtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":50 */ + __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_2; + __pyx_2 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":51 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":52 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_L4:; + } + __pyx_L5:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":53 */ + free(__pyx_v_v); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":54 */ + 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); + __Pyx_AddTraceback("_xtea._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_f_5_xtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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_vsize; + 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; + unsigned long __pyx_5; + 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/_xtea.pyx":59 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; 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 = 59; 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 = 59; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_size = __pyx_4; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":60 */ + __pyx_v_vsize = ((sizeof(unsigned long )) * __pyx_v_size); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":61 */ + __pyx_v_v = ((unsigned long (*))malloc(__pyx_v_vsize)); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":62 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":63 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[__pyx_v_i]) = __pyx_5; + __pyx_L2:; + } + __pyx_L3:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ + __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + (__pyx_v_k[0]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_v_key, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + (__pyx_v_k[1]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[2]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + (__pyx_v_k[3]) = __pyx_5; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":65 */ + __pyx_v_rc = xtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":66 */ + __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;} + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_2; + __pyx_2 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":67 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_L4:; + } + __pyx_L5:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":69 */ + free(__pyx_v_v); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":70 */ + 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); + __Pyx_AddTraceback("_xtea._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_MODE_CBC, "MODE_CBC"}, - {&__pyx_n_MODE_CFB, "MODE_CFB"}, - {&__pyx_n_MODE_CTR, "MODE_CTR"}, - {&__pyx_n_MODE_ECB, "MODE_ECB"}, - {&__pyx_n_MODE_OFB, "MODE_OFB"}, - {&__pyx_n__c_xtea_decryptQuad, "_c_xtea_decryptQuad"}, {&__pyx_n__c_xtea_encryptQuad, "_c_xtea_encryptQuad"}, + {&__pyx_n__c_xxtea_decrypt, "_c_xxtea_decrypt"}, + {&__pyx_n__c_xxtea_decryptQuad, "_c_xxtea_decryptQuad"}, + {&__pyx_n__c_xxtea_encrypt, "_c_xxtea_encrypt"}, + {&__pyx_n_append, "append"}, + {&__pyx_n_len, "len"}, {0, 0} }; static struct PyMethodDef __pyx_methods[] = { {"_c_xtea_encryptQuad", (PyCFunction)__pyx_f_5_xtea__c_xtea_encryptQuad, METH_VARARGS|METH_KEYWORDS, 0}, - {"_c_xtea_decryptQuad", (PyCFunction)__pyx_f_5_xtea__c_xtea_decryptQuad, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xxtea_decryptQuad", (PyCFunction)__pyx_f_5_xtea__c_xxtea_decryptQuad, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xxtea_encrypt", (PyCFunction)__pyx_f_5_xtea__c_xxtea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xxtea_decrypt", (PyCFunction)__pyx_f_5_xtea__c_xxtea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; @@ -259,44 +547,17 @@ PyMODINIT_FUNC init_xtea(void); /*proto*/ PyMODINIT_FUNC init_xtea(void) { - PyObject *__pyx_1 = 0; __pyx_init_filenames(); __pyx_m = Py_InitModule4("_xtea", __pyx_methods, 0, 0, PYTHON_API_VERSION); - if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}; + 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 = 8; goto __pyx_L1;}; - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}; - if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}; + 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;}; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":15 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_MODE_ECB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":16 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_MODE_CBC, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":17 */ - __pyx_1 = PyInt_FromLong(4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_MODE_CFB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":18 */ - __pyx_1 = PyInt_FromLong(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_MODE_OFB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":19 */ - __pyx_1 = PyInt_FromLong(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_MODE_CTR, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":30 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":56 */ return; __pyx_L1:; - Py_XDECREF(__pyx_1); __Pyx_AddTraceback("_xtea"); } @@ -310,6 +571,14 @@ __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 int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { while (t->p) { *t->p = PyString_InternFromString(t->s); Modified: xtea/trunk/src/xtea/_xtea.pyx =================================================================== --- xtea/trunk/src/xtea/_xtea.pyx 2007-03-01 17:41:40 UTC (rev 222) +++ xtea/trunk/src/xtea/_xtea.pyx 2007-03-02 14:54:09 UTC (rev 223) @@ -3,35 +3,68 @@ # License: Public Domain # http://www.python.org/dev/peps/pep-0272/ -# http://en.wikipedia.org/wiki/XTEA 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 "cxtea.h": - void decipher(ULong *v, ULong *k, UInt rounds) - void encipher(ULong *v, ULong *k, UInt rounds) + 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) -MODE_ECB = 1 # Electronic Code Book -MODE_CBC = 2 # Cipher Block Chaining -MODE_CFB = 4 # Cipher Feedback -MODE_OFB = 5 # Output Feedback -MODE_CTR = 6 # Counter - def _c_xtea_encryptQuad(ULong v0, ULong v1, object key, UInt rounds): cdef ULong v[2] cdef ULong k[4] v[0] = v0; v[1] = v1 - k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3]; - encipher(v, k, rounds) + 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_decryptQuad(ULong v0, ULong v1, key, UInt rounds): +def _c_xxtea_decryptQuad(ULong v0, ULong v1, object key, UInt rounds): cdef ULong v[2] cdef ULong k[4] v[0] = v0; v[1] = v1 - k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3]; - decipher(v, k, rounds) + k[0] = key[0]; k[1] = key[1]; k[2] = key[2]; k[3] = key[3] + rc = xxtea_decipher(v, k, rounds) result = [v[0], v[1]] return result + +def _c_xxtea_encrypt(object block, key, UInt rounds): + cdef ULong k[4], *v + cdef int rc, size, vsize, i + size = len(block) + vsize = sizeof(ULong) * size + v = <ULong *>malloc(vsize) + 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 = xtea_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, vsize, i + size = len(block) + vsize = sizeof(ULong) * size + v = <ULong *>malloc(vsize) + 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 = xtea_encipher(v, k, rounds) + result = [] + for i from 0 <= i < size: + result.append(v[i]) + free(v) + return result Modified: xtea/trunk/src/xtea/cxtea.c =================================================================== --- xtea/trunk/src/xtea/cxtea.c 2007-03-01 17:41:40 UTC (rev 222) +++ xtea/trunk/src/xtea/cxtea.c 2007-03-02 14:54:09 UTC (rev 223) @@ -3,30 +3,81 @@ License: Public Domain Source: http://en.wikipedia.org/wiki/XTEA + http://www.cix.co.uk/~klockstone/xxtea.pdf + http://www-users.cs.york.ac.uk/~matthew/TEA/ */ #include "cxtea.h" -void decipher(ULong *const v, const ULong *const k, const UInt rounds) +/* XTEA decipher / encipher + * v - array with 2 values + * k - array with 4 values + * n - number of rounds + */ + +int xtea_decipher(ULong *const v, const ULong *const k, const UInt n) { register UInt i; - register ULong delta=0x9E3779B9; - register ULong sum=delta*rounds; - for (i=0; i < rounds; i++) { + register ULong delta=0x9E3779B9, sum=delta*n; + for (i=0; i < n; i++) { v[1] -= ((v[0]<<4 ^ v[0]>>5) + v[0]) ^ (sum + k[sum>>11 & 3]); sum -= delta; v[0] -= ((v[1]<<4 ^ v[1]>>5) + v[1]) ^ (sum + k[sum & 3]); } + return 0; } -void encipher(ULong *const v, const ULong *const k, const UInt rounds) +int xtea_encipher(ULong *const v, const ULong *const k, const UInt n) { register UInt i; - register ULong delta=0x9E3779B9; - register ULong sum=0; - for (i=0; i < rounds; i++) { + register ULong delta=0x9E3779B9, sum=0; + for (i=0; i < n; i++) { v[0] += ((v[1]<<4 ^ v[1]>>5) + v[1]) ^ (sum + k[sum & 3]); sum += delta; v[1] += ((v[0]<<4 ^ v[0]>>5) + v[0]) ^ (sum + k[sum>>11 & 3]); } + return 0; } + +/* xxTEA or block TEA 2 + * Fixed version w/o underflow issue in z=v[n-1] + * v - array with n values + * k - array with 4 values + * n - rounds and number of values in v + */ + +#define MX (((z>>5)^(y<<2))+(((y>>3)^(z<<4))^(sum^y))+(k[(p&3)^e]^z)); + +int xxtea_encipher(ULong *const v, const ULong *const k, const UInt n) + { + register long p, q=6+52/n; + register ULong z=v[n-1], y=v[0], e, DELTA=0x9e3779b9, sum=0; + while (q-- > 0) { + sum += DELTA; + e = sum >> 2 & 3; + for (p=0; p<n-1; p++) { + y = v[p+1]; + z = v[p] += MX; + } + y = v[0]; + z = v[n-1] += MX; + } + return 0; + } + +int xxtea_decipher(ULong *const v, const ULong *const k, const UInt n) + { + register long p, q=6+52/n; + register ULong z=v[n-1], y=v[0], e, DELTA=0x9e3779b9, sum=q*DELTA; + while (sum != 0) { + e = sum>>2 & 3; + for (p=n-1; p>0; p--) { + z = v[p-1]; + y = v[p] -= MX; + } + z = v[n-1]; + y = v[0] -= MX; + sum -= DELTA; + } + return 0; + } Modified: xtea/trunk/src/xtea/cxtea.h =================================================================== --- xtea/trunk/src/xtea/cxtea.h 2007-03-01 17:41:40 UTC (rev 222) +++ xtea/trunk/src/xtea/cxtea.h 2007-03-02 14:54:09 UTC (rev 223) @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Christian Heimes <christian (at) cheimes (dot) de> pyrexc optimized version License: Public Domain - - Source: http://en.wikipedia.org/wiki/XTEA */ #define MODE_ECB 1 // Electronic Code Book @@ -14,6 +12,7 @@ typedef unsigned long ULong; typedef unsigned int UInt; -void decipher(ULong *const v, const ULong *const k, const UInt rounds); -void encipher(ULong *const v, const ULong *const k, const UInt rounds); - +int xtea_decipher(ULong *const v, const ULong *const k, const UInt n); +int xtea_encipher(ULong *const v, const ULong *const k, const UInt n); +int xxtea_decipher(ULong *const v, const ULong *const k, const UInt n); +int xxtea_encipher(ULong *const v, const ULong *const k, const UInt n); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ti...@us...> - 2007-03-02 16:28:17
|
Revision: 224 http://pymoul.svn.sourceforge.net/pymoul/?rev=224&view=rev Author: tiran Date: 2007-03-02 08:28:11 -0800 (Fri, 02 Mar 2007) Log Message: ----------- Redesign of the package. Moved common stuf to common Fixed broken naming in pyx code Modified Paths: -------------- xtea/trunk/src/xtea/__init__.py xtea/trunk/src/xtea/_xtea.c xtea/trunk/src/xtea/_xtea.pyx xtea/trunk/src/xtea/cxtea.c xtea/trunk/src/xtea/cxtea.h xtea/trunk/src/xtea/tests.py xtea/trunk/src/xtea/xtea.py Added Paths: ----------- xtea/trunk/src/xtea/_common.py Modified: xtea/trunk/src/xtea/__init__.py =================================================================== --- xtea/trunk/src/xtea/__init__.py 2007-03-02 14:54:09 UTC (rev 223) +++ xtea/trunk/src/xtea/__init__.py 2007-03-02 16:28:11 UTC (rev 224) @@ -1,7 +1,11 @@ # xtea package -from xtea import new -from xtea import MODE_ECB -from xtea import MODE_OFB -from xtea import BIG_ENDIAN -from xtea import LITTLE_ENDIAN -from xtea import NETWORK_ENDIAN +from xtea import XTEA +#from xxtea import XXTEA + +from _common import MODE_ECB +from _common import MODE_OFB +from _common import BIG_ENDIAN +from _common import LITTLE_ENDIAN +from _common import NETWORK_ENDIAN +from _common import HOST_ENDIAN +from _common import pad Added: xtea/trunk/src/xtea/_common.py =================================================================== --- xtea/trunk/src/xtea/_common.py (rev 0) +++ xtea/trunk/src/xtea/_common.py 2007-03-02 16:28:11 UTC (rev 224) @@ -0,0 +1,151 @@ +""" +""" +from struct import pack +from struct import unpack +import sys + +__all__ = ['MODE_ECB', 'MODE_OFB', 'BIG_ENDIAN', 'LITTLE_ENDIAN', + 'NETWORK_ENDIAN', 'HOST_ENDIAN', 'pad'] + +MODE_ECB = 1 # Electronic Code Book +MODE_CBC = 2 # Cipher Block Chaining +MODE_CFB = 4 # Cipher Feedback +MODE_OFB = 5 # Output Feedback +MODE_CTR = 6 # Counter +BIG_ENDIAN = 'big' +LITTLE_ENDIAN = 'little' +NETWORK_ENDIAN = LITTLE_ENDIAN +HOST_ENDIAN = sys.byteorder +NULL='\x00' +ULONG_SIZE=4 + +def pad(s, align, char=NULL): + """Pad string 's' to 'align' number of elements with char 'char' + + >>> pad('abcd', 4) + 'abcd' + >>> pad('abcdabcd', 4) + 'abcdabcd' + >>> pad('abcdef', 4) + 'abcdef\\x00\\x00' + >>> pad('abcdef', 4, char='0') + 'abcdef00' + """ + mod = len(s) % align + if mod != 0: + return s+mod*char + else: + return s + +class _AbstractTEA(object): + """Abstract TEA base class + """ + @property + def key_size(self): + """Size of key + """ + return 16 + + @property + def block_size(self): + """Size of blocks + """ + return 8 + + @property + def default_rounds(self): + """Default number of rounds + """ + return 32 + + def __init__(self, key, mode=MODE_ECB, IV=8*NULL, rounds=None, + endian=HOST_ENDIAN, counter=None, segment_size=None): + if endian == BIG_ENDIAN: + self._endian = ">" + elif endian == LITTLE_ENDIAN: + self._endian = "<" + else: + raise ValueError("Unknown endian: %s" % endian) + + ks = self.key_size + if isinstance(key, tuple): + if len(key) != ks/ULONG_SIZE: + raise ValueError("Invalid key size") + for e in key: + if not isinstance(e, (long, int)): + raise TypeError("Wrong type %s in key" % repr(e)) + self._key = key + elif isinstance(key, str): + if len(key) != ks: + raise ValueError("Invalid key size") + self._key = unpack("%s%iL" % (self._endian, ks/ULONG_SIZE), key) + else: + raise TypeError("Invalid key type") + + if mode == MODE_ECB: + pass + elif mode == MODE_OFB: + if not isinstance(IV, str) or len(IV) != self.block_size: + raise ValueError("Invalid IV") + else: + raise ValueError("Unknown or unsupported mode") + self._mode = mode + self._iv = IV + + if rounds is None: + rounds = self.default_rounds + if rounds < 2 or not isinstance(rounds, int): + raise ValueError("Invalid rounds") + self._rounds = rounds + self._counter = counter + self._segment_size = segment_size + + @classmethod + def new(cls, key, **kwargs): + """PEP 272 conform constructor + """ + return cls(key, **kwargs) + + def encrypt(self, block): + """Encrypt a block + + @param block: block to encrypt + @type block: str + """ + if self._mode == MODE_ECB: + return self._ecb(block, func=self._encrypt) + elif self._mode == MODE_OFB: + return self._ofb(block) + else: + raise ValueError("Unknown or unsupported mode") + + def decrypt(self, block): + """Decrypt a block + + @param block: block to decrypt + @type block: str + """ + if self._mode == MODE_ECB: + return self._ecb(block, func=self._decrypt) + elif self._mode == MODE_OFB: + return self._ofb(block) + else: + raise ValueError("Unknown or unsupported mode") + + _decrypt = None + _encrypt = None + + def _ecb(self, block, func): + """Electronic Code Book encryption/decryption + + @type block: str + @param func: decrypt or encrypt function + @type func: callable + """ + raise NotImplementedError + + def _ofb(self, block): + """Output Feedback (OFB) encryption requires an IV + """ + raise NotImplementedError + Property changes on: xtea/trunk/src/xtea/_common.py ___________________________________________________________________ Name: svn:keywords + 'Id Revision' Name: svn:eol-style + native Modified: xtea/trunk/src/xtea/_xtea.c =================================================================== --- xtea/trunk/src/xtea/_xtea.c 2007-03-02 14:54:09 UTC (rev 223) +++ xtea/trunk/src/xtea/_xtea.c 2007-03-02 16:28:11 UTC (rev 224) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.4.1 on Fri Mar 2 15:53:19 2007 */ +/* Generated by Pyrex 0.9.5.1a on Fri Mar 2 17:24:15 2007 */ #include "Python.h" #include "structmember.h" @@ -17,26 +17,6 @@ typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ -static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/ -static int __Pyx_EndUnpack(PyObject *, int); /*proto*/ -static int __Pyx_PrintItem(PyObject *); /*proto*/ -static int __Pyx_PrintNewline(void); /*proto*/ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static void __Pyx_ReRaise(void); /*proto*/ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ -static PyObject *__Pyx_GetExcValue(void); /*proto*/ -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ -static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ -static void __Pyx_WriteUnraisable(char *name); /*proto*/ -static void __Pyx_AddTraceback(char *funcname); /*proto*/ -static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ -static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/ -static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ -static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ static PyObject *__pyx_m; static PyObject *__pyx_b; @@ -44,20 +24,32 @@ 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_xtea_encryptQuad; -static PyObject *__pyx_n__c_xxtea_decryptQuad; +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_n_XXX_c_xxtea_encrypt; +static PyObject *__pyx_n_XXX_c_xxtea_decrypt; -static PyObject *__pyx_f_5_xtea__c_xtea_encryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xtea_encryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - unsigned long __pyx_v_v0; - unsigned long __pyx_v_v1; +static PyObject *__pyx_f_5_xtea__c_xtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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]); @@ -69,17 +61,28 @@ PyObject *__pyx_2 = 0; unsigned long __pyx_3; PyObject *__pyx_4 = 0; - static char *__pyx_argnames[] = {"v0","v1","key","rounds",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "kkOI", __pyx_argnames, &__pyx_v_v0, &__pyx_v_v1, &__pyx_v_key, &__pyx_v_rounds)) return 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":25 */ - (__pyx_v_v[0]) = __pyx_v_v0; + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; 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 = 25; 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":25 */ - (__pyx_v_v[1]) = __pyx_v_v1; + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; 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 = 25; 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":26 */ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} @@ -142,19 +145,19 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("_xtea._c_xtea_encryptQuad"); + __Pyx_AddTraceback("_xtea._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_5_xtea__c_xxtea_decryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xxtea_decryptQuad(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - unsigned long __pyx_v_v0; - unsigned long __pyx_v_v1; +static PyObject *__pyx_f_5_xtea__c_xtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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]); @@ -166,17 +169,28 @@ PyObject *__pyx_2 = 0; unsigned long __pyx_3; PyObject *__pyx_4 = 0; - static char *__pyx_argnames[] = {"v0","v1","key","rounds",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "kkOI", __pyx_argnames, &__pyx_v_v0, &__pyx_v_v1, &__pyx_v_key, &__pyx_v_rounds)) return 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":34 */ - (__pyx_v_v[0]) = __pyx_v_v0; + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; 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 = 34; 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":34 */ - (__pyx_v_v[1]) = __pyx_v_v1; + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; 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 = 34; 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":35 */ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} @@ -211,7 +225,7 @@ (__pyx_v_k[3]) = __pyx_3; /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":36 */ - __pyx_1 = PyInt_FromLong(xxtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __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 = 36; goto __pyx_L1;} Py_DECREF(__pyx_v_rc); __pyx_v_rc = __pyx_1; __pyx_1 = 0; @@ -239,18 +253,24 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("_xtea._c_xxtea_decryptQuad"); + __Pyx_AddTraceback("_xtea._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_5_xtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_5_xtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_block = 0; @@ -268,7 +288,8 @@ PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; int __pyx_4; - unsigned long __pyx_5; + 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); @@ -288,87 +309,106 @@ __pyx_v_size = __pyx_4; /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":44 */ + __pyx_4 = (__pyx_v_size != __pyx_v_rounds); + if (__pyx_4) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":45 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; 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 = 45; 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 = 45; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":46 */ __pyx_v_vsize = ((sizeof(unsigned long )) * __pyx_v_size); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":45 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":47 */ __pyx_v_v = ((unsigned long (*))malloc(__pyx_v_vsize)); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":46 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":47 */ - __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_v[__pyx_v_i]) = __pyx_5; - __pyx_L2:; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":49 */ + __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; 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 = 49; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_v[__pyx_v_i]) = __pyx_6; } - __pyx_L3:; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ - __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_v_k[0]) = __pyx_5; + __pyx_6 = 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_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_key, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":50 */ + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - (__pyx_v_k[1]) = __pyx_5; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[1]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + __pyx_6 = 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_5; + (__pyx_v_k[2]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ - __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":50 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - (__pyx_v_k[3]) = __pyx_5; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[3]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":49 */ - __pyx_v_rc = xtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":51 */ + __pyx_v_rc = xxtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":50 */ - __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":52 */ + __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_2; - __pyx_2 = 0; + __pyx_v_result = __pyx_1; + __pyx_1 = 0; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":51 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":53 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":52 */ - __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); - __pyx_1 = 0; - __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":54 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; 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 = 54; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_L4:; } - __pyx_L5:; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":53 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":55 */ free(__pyx_v_v); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":54 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":56 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -379,6 +419,7 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_5); __Pyx_AddTraceback("_xtea._c_xxtea_encrypt"); __pyx_r = 0; __pyx_L0:; @@ -388,6 +429,10 @@ return __pyx_r; } +static PyObject *__pyx_k2p; + +static char (__pyx_k2[]) = "len(block) %i != rounds %i"; + static PyObject *__pyx_f_5_xtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_5_xtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_block = 0; @@ -405,107 +450,127 @@ PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; int __pyx_4; - unsigned long __pyx_5; + 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/_xtea.pyx":59 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":61 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; 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 = 59; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; 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 = 59; goto __pyx_L1;} + __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_v_size = __pyx_4; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":60 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":62 */ + __pyx_4 = (__pyx_v_size != __pyx_v_rounds); + if (__pyx_4) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":63 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} + __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; 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 = 63; 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 = 63; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ __pyx_v_vsize = ((sizeof(unsigned long )) * __pyx_v_size); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":61 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":65 */ __pyx_v_v = ((unsigned long (*))malloc(__pyx_v_vsize)); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":62 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":66 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":63 */ - __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_v[__pyx_v_i]) = __pyx_5; - __pyx_L2:; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":67 */ + __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; 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 = 67; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_v[__pyx_v_i]) = __pyx_6; } - __pyx_L3:; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ - __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - (__pyx_v_k[0]) = __pyx_5; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[0]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_key, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - (__pyx_v_k[1]) = __pyx_5; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[1]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - (__pyx_v_k[2]) = __pyx_5; + (__pyx_v_k[2]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":64 */ - __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - __pyx_1 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ + __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyInt_AsUnsignedLongMask(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - (__pyx_v_k[3]) = __pyx_5; + __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[3]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":65 */ - __pyx_v_rc = xtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":69 */ + __pyx_v_rc = xxtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":66 */ - __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":70 */ + __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;} Py_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_2; - __pyx_2 = 0; + __pyx_v_result = __pyx_1; + __pyx_1 = 0; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":67 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":71 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ - __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); - __pyx_1 = 0; - __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":72 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; 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 = 72; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_L4:; } - __pyx_L5:; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":69 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":73 */ free(__pyx_v_v); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":70 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":74 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -516,6 +581,7 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_5); __Pyx_AddTraceback("_xtea._c_xxtea_decrypt"); __pyx_r = 0; __pyx_L0:; @@ -525,21 +591,326 @@ return __pyx_r; } +static PyObject *__pyx_k3p; + +static char (__pyx_k3[]) = "len(block) %i != rounds %i"; + +static PyObject *__pyx_f_5_xtea_XXX_c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea_XXX_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[2]); + int __pyx_v_rc; + int __pyx_v_size; + 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/_xtea.pyx":79 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; 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 = 79; 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 = 79; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_size = __pyx_4; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":80 */ + __pyx_4 = (__pyx_v_size != __pyx_v_rounds); + if (__pyx_4) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":81 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} + __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; 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_k3p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; 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 = 81; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":82 */ + __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; 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 = 82; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_v[0]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":82 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; 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 = 82; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[1]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ + __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; 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 = 83; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[0]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; 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 = 83; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[1]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ + __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; 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 = 83; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[2]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; 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 = 83; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[3]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":84 */ + __pyx_v_rc = xxtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":85 */ + __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_5 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + __pyx_1 = PyList_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_3); + PyList_SET_ITEM(__pyx_1, 1, __pyx_5); + __pyx_3 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":86 */ + 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("_xtea.XXX_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_k4p; + +static char (__pyx_k4[]) = "len(block) %i != rounds %i"; + +static PyObject *__pyx_f_5_xtea_XXX_c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea_XXX_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[2]); + int __pyx_v_rc; + int __pyx_v_size; + 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/_xtea.pyx":91 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; 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 = 91; 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 = 91; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_size = __pyx_4; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":92 */ + __pyx_4 = (__pyx_v_size != __pyx_v_rounds); + if (__pyx_4) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":93 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; 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_k4p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; 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 = 93; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":94 */ + __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; 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 = 94; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_v[0]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":94 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; 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 = 94; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_v[1]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":95 */ + __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; 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 = 95; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[0]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":95 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; 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 = 95; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[1]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":95 */ + __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; 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 = 95; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + (__pyx_v_k[2]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":95 */ + __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; 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 = 95; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + (__pyx_v_k[3]) = __pyx_6; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":96 */ + __pyx_v_rc = xxtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":97 */ + __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + __pyx_5 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + __pyx_1 = PyList_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_3); + PyList_SET_ITEM(__pyx_1, 1, __pyx_5); + __pyx_3 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_1; + __pyx_1 = 0; + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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("_xtea.XXX_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__c_xtea_encryptQuad, "_c_xtea_encryptQuad"}, + {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n_XXX_c_xxtea_decrypt, "XXX_c_xxtea_decrypt"}, + {&__pyx_n_XXX_c_xxtea_encrypt, "XXX_c_xxtea_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_decryptQuad, "_c_xxtea_decryptQuad"}, {&__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)}, + {&__pyx_k3p, __pyx_k3, sizeof(__pyx_k3)}, + {&__pyx_k4p, __pyx_k4, sizeof(__pyx_k4)}, + {0, 0, 0} +}; + static struct PyMethodDef __pyx_methods[] = { - {"_c_xtea_encryptQuad", (PyCFunction)__pyx_f_5_xtea__c_xtea_encryptQuad, METH_VARARGS|METH_KEYWORDS, 0}, - {"_c_xxtea_decryptQuad", (PyCFunction)__pyx_f_5_xtea__c_xxtea_decryptQuad, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xtea_encrypt", (PyCFunction)__pyx_f_5_xtea__c_xtea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"_c_xtea_decrypt", (PyCFunction)__pyx_f_5_xtea__c_xtea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, {"_c_xxtea_encrypt", (PyCFunction)__pyx_f_5_xtea__c_xxtea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, {"_c_xxtea_decrypt", (PyCFunction)__pyx_f_5_xtea__c_xxtea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"XXX_c_xxtea_encrypt", (PyCFunction)__pyx_f_5_xtea_XXX_c_xxtea_encrypt, METH_VARARGS|METH_KEYWORDS, 0}, + {"XXX_c_xxtea_decrypt", (PyCFunction)__pyx_f_5_xtea_XXX_c_xxtea_decrypt, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; @@ -554,8 +925,9 @@ 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/_xtea.pyx":56 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":88 */ return; __pyx_L1:; __Pyx_AddTraceback("_xtea"); @@ -579,6 +951,64 @@ 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); @@ -589,6 +1019,16 @@ 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" Modified: xtea/trunk/src/xtea/_xtea.pyx =================================================================== --- xtea/trunk/src/xtea/_xtea.pyx 2007-03-02 14:54:09 UTC (rev 223) +++ xtea/trunk/src/xtea/_xtea.pyx 2007-03-02 16:28:11 UTC (rev 224) @@ -19,21 +19,21 @@ int xxtea_decipher(ULong *v, ULong *k, UInt n) int xxtea_encipher(ULong *v, ULong *k, UInt n) -def _c_xtea_encryptQuad(ULong v0, ULong v1, object key, UInt rounds): +def _c_xtea_encrypt(object block, object key, UInt rounds): cdef ULong v[2] cdef ULong k[4] - v[0] = v0; v[1] = v1 + 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_xxtea_decryptQuad(ULong v0, ULong v1, object key, UInt rounds): +def _c_xtea_decrypt(object block, object key, UInt rounds): cdef ULong v[2] cdef ULong k[4] - v[0] = v0; v[1] = v1 + 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 = xxtea_decipher(v, k, rounds) + rc = xtea_decipher(v, k, rounds) result = [v[0], v[1]] return result @@ -41,12 +41,14 @@ cdef ULong k[4], *v cdef int rc, size, vsize, i size = len(block) + if size != rounds: + raise ValueError, "len(block) %i != rounds %i" % (size, rounds) vsize = sizeof(ULong) * size v = <ULong *>malloc(vsize) 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 = xtea_encipher(v, k, rounds) + rc = xxtea_encipher(v, k, rounds) result = [] for i from 0 <= i < size: result.append(v[i]) @@ -57,14 +59,40 @@ cdef ULong k[4], *v cdef int rc, size, vsize, i size = len(block) + if size != rounds: + raise ValueError, "len(block) %i != rounds %i" % (size, rounds) vsize = sizeof(U... [truncated message content] |
From: <ti...@us...> - 2007-03-02 17:03:28
|
Revision: 225 http://pymoul.svn.sourceforge.net/pymoul/?rev=225&view=rev Author: tiran Date: 2007-03-02 09:03:21 -0800 (Fri, 02 Mar 2007) Log Message: ----------- Added implementation switch and timing function Modified Paths: -------------- xtea/trunk/src/xtea/_common.py xtea/trunk/src/xtea/tests.py xtea/trunk/src/xtea/xtea.py Modified: xtea/trunk/src/xtea/_common.py =================================================================== --- xtea/trunk/src/xtea/_common.py 2007-03-02 16:28:11 UTC (rev 224) +++ xtea/trunk/src/xtea/_common.py 2007-03-02 17:03:21 UTC (rev 225) @@ -106,6 +106,33 @@ """ return cls(key, **kwargs) + @classmethod + def setDefaultImpl(cls, impl='py'): + """Set default implementation + """ + if impl == 'py': + cls._decrypt = cls._py_decrypt + cls._encrypt = cls._py_encrypt + elif impl == 'c': + assert cls._c_decrypt is not None + cls._decrypt = cls._c_decrypt + cls._encrypt = cls._c_encrypt + else: + raise ValueError(impl) + + def setImpl(self, impl='py'): + """Set implementation for this instance + """ + if impl == 'py': + self._decrypt = self._py_decrypt + self._encrypt = self._py_encrypt + elif impl == 'c': + assert self._c_decrypt is not None + self._decrypt = self._c_decrypt + self._encrypt = self._c_encrypt + else: + raise ValueError(impl) + def encrypt(self, block): """Encrypt a block @@ -134,6 +161,10 @@ _decrypt = None _encrypt = None + _c_decrypt = None + _c_encrypt = None + _py_decrypt = None + _py_encrypt = None def _ecb(self, block, func): """Electronic Code Book encryption/decryption Modified: xtea/trunk/src/xtea/tests.py =================================================================== --- xtea/trunk/src/xtea/tests.py 2007-03-02 16:28:11 UTC (rev 224) +++ xtea/trunk/src/xtea/tests.py 2007-03-02 17:03:21 UTC (rev 225) @@ -8,7 +8,9 @@ import os import unittest from doctest import DocTestSuite +from time import time +from xtea import XTEA class CXteaTestCase(unittest.TestCase): def setUp(self): @@ -24,15 +26,29 @@ def tearDown(self): pass +def compare_timing(cls=XTEA): + key = os.urandom(16) + data = os.urandom(1024) + xtea = cls(key) + for impl in ('c', 'py'): + for size in (1, 5, 10, 50): + d = size*data + xtea.setImpl(impl) + start = time() + for i in range(5): + enc = xtea.encrypt(d) + xtea.decrypt(enc) + print "%s: 5 times %sk data: %0.4f" % (impl, size, time() - start) + def test_suite(): return unittest.TestSuite(( unittest.makeSuite(CXteaTestCase), unittest.makeSuite(PyXteaTestCase), DocTestSuite('xtea'), - DocTestSuite('xxtea'), + #DocTestSuite('xxtea'), DocTestSuite('_common'), )) if __name__ == '__main__': + #compare_timing() unittest.main(defaultTest="test_suite") - Modified: xtea/trunk/src/xtea/xtea.py =================================================================== --- xtea/trunk/src/xtea/xtea.py 2007-03-02 16:28:11 UTC (rev 224) +++ xtea/trunk/src/xtea/xtea.py 2007-03-02 17:03:21 UTC (rev 225) @@ -154,7 +154,7 @@ return ''.join(xor) @staticmethod - def _py_xtea_decrypt(v, key, n=32, delta=0x9e3779b9L, + def _py_decrypt(v, key, n=32, delta=0x9e3779b9L, mask=0xffffffffL): """Decrypt a quad @@ -175,10 +175,8 @@ v0 = (v0 - (((v1<<4 ^ v1>>5) + v1) ^ (sum + key[sum & 3]))) & mask return v0, v1 - _decrypt = _py_xtea_decrypt - @staticmethod - def _py_xtea_encrypt(v, key, n=32, delta=0x9e3779b9L, + def _py_encrypt(v, key, n=32, delta=0x9e3779b9L, mask=0xffffffffL): """Encrypt a quad @@ -199,15 +197,14 @@ v1 = (v1 + (((v0<<4 ^ v0>>5) + v0) ^ (sum + key[sum>>11 & 3]))) & mask return v0, v1 - _encrypt = _py_xtea_encrypt - # Try to replace core functions with optimized versions try: from _xtea import _c_xtea_encrypt from _xtea import _c_xtea_decrypt except ImportError, msg: - pass + XTEA.setDefaultImpl('py') #print msg else: - XTEA._encrypt = _c_xtea_encrypt - XTEA._decrypt = _c_xtea_decrypt + XTEA._c_encrypt = _c_xtea_encrypt + XTEA._c_decrypt = _c_xtea_decrypt + XTEA.setDefaultImpl('c') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ti...@us...> - 2007-03-04 02:21:08
|
Revision: 226 http://pymoul.svn.sourceforge.net/pymoul/?rev=226&view=rev Author: tiran Date: 2007-03-03 18:21:04 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Added xxtea and tea implementation Modified Paths: -------------- xtea/trunk/src/xtea/__init__.py xtea/trunk/src/xtea/_common.py xtea/trunk/src/xtea/_xtea.c xtea/trunk/src/xtea/_xtea.pyx xtea/trunk/src/xtea/cxtea.c xtea/trunk/src/xtea/cxtea.h xtea/trunk/src/xtea/tests.py xtea/trunk/src/xtea/xtea.py Added Paths: ----------- xtea/trunk/src/xtea/tea.py xtea/trunk/src/xtea/xxtea.py Modified: xtea/trunk/src/xtea/__init__.py =================================================================== --- xtea/trunk/src/xtea/__init__.py 2007-03-02 17:03:21 UTC (rev 225) +++ xtea/trunk/src/xtea/__init__.py 2007-03-04 02:21:04 UTC (rev 226) @@ -1,4 +1,5 @@ # xtea package +#from tea import TEA from xtea import XTEA #from xxtea import XXTEA Modified: xtea/trunk/src/xtea/_common.py =================================================================== --- xtea/trunk/src/xtea/_common.py 2007-03-02 17:03:21 UTC (rev 225) +++ xtea/trunk/src/xtea/_common.py 2007-03-04 02:21:04 UTC (rev 226) @@ -12,12 +12,15 @@ MODE_CFB = 4 # Cipher Feedback MODE_OFB = 5 # Output Feedback MODE_CTR = 6 # Counter + BIG_ENDIAN = 'big' LITTLE_ENDIAN = 'little' NETWORK_ENDIAN = LITTLE_ENDIAN HOST_ENDIAN = sys.byteorder + NULL='\x00' ULONG_SIZE=4 +DELTA=0x9E3779B9 def pad(s, align, char=NULL): """Pad string 's' to 'align' number of elements with char 'char' @@ -111,8 +114,8 @@ """Set default implementation """ if impl == 'py': - cls._decrypt = cls._py_decrypt - cls._encrypt = cls._py_encrypt + cls._decrypt = staticmethod(cls._py_decrypt) + cls._encrypt = staticmethod(cls._py_encrypt) elif impl == 'c': assert cls._c_decrypt is not None cls._decrypt = cls._c_decrypt @@ -124,8 +127,8 @@ """Set implementation for this instance """ if impl == 'py': - self._decrypt = self._py_decrypt - self._encrypt = self._py_encrypt + self._decrypt = staticmethod(self._py_decrypt) + self._encrypt = staticmethod(self._py_encrypt) elif impl == 'c': assert self._c_decrypt is not None self._decrypt = self._c_decrypt @@ -171,12 +174,40 @@ @type block: str @param func: decrypt or encrypt function - @type func: callable + @type func: callable(v0, v1, keys[4], rounds) """ - raise NotImplementedError + l = len(block) + bs = self.block_size + key, rounds = self._key, self._rounds + fmt = self._endian+"2L" + result = [] + if l % bs != 0: + raise ValueError + for i in range(l/bs): + v = unpack(fmt, block[i*bs:(i+1)*bs]) + w = func(v, key, rounds) + result.append(pack(fmt, *w)) + return ''.join(result) + def _ofb_keygen(self): + """Key generator + + @return: generator function + """ + key, iv, rounds = self._key, self._iv, self._rounds + fmt = self._endian+"%iL" % (self.block_size/ULONG_SIZE) + #v0, v1 = unpack(self._endian+"2L", iv) + while True: + v = unpack(fmt, iv) + w = self._encrypt(v, key, rounds) + iv = pack(fmt, *w) + for k in iv: + yield ord(k) + def _ofb(self, block): """Output Feedback (OFB) encryption requires an IV """ - raise NotImplementedError - + key = pack(self._endian+"%iL" % (self.key_size/ULONG_SIZE), *self._key) + gen = self._ofb_keygen() + xor = [chr(x^y) for (x, y) in zip(map(ord, block), gen)] + return ''.join(xor) Modified: xtea/trunk/src/xtea/_xtea.c =================================================================== --- xtea/trunk/src/xtea/_xtea.c 2007-03-02 17:03:21 UTC (rev 225) +++ xtea/trunk/src/xtea/_xtea.c 2007-03-04 02:21:04 UTC (rev 226) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.5.1a on Fri Mar 2 17:24:15 2007 */ +/* Generated by Pyrex 0.9.5.1a on Sun Mar 4 03:00:20 2007 */ #include "Python.h" #include "structmember.h" @@ -40,15 +40,15 @@ /* 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_n_XXX_c_xxtea_encrypt; -static PyObject *__pyx_n_XXX_c_xxtea_decrypt; -static PyObject *__pyx_f_5_xtea__c_xtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +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; @@ -68,64 +68,64 @@ __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":25 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + /* "/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 = 25; goto __pyx_L1;} + __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":25 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + /* "/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 = 25; goto __pyx_L1;} + __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":26 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + /* "/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 = 26; goto __pyx_L1;} + __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":26 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + /* "/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 = 26; goto __pyx_L1;} + __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":26 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + /* "/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 = 26; goto __pyx_L1;} + __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":26 */ - __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + /* "/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 = 26; goto __pyx_L1;} + __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":27 */ - __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 = 27; goto __pyx_L1;} + /* "/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":28 */ - __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} - __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} + /* "/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; @@ -134,7 +134,7 @@ __pyx_v_result = __pyx_4; __pyx_4 = 0; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":29 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":33 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -145,7 +145,7 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("_xtea._c_xtea_encrypt"); + __Pyx_AddTraceback("_xtea._c_tea_encrypt"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_rc); @@ -155,8 +155,8 @@ return __pyx_r; } -static PyObject *__pyx_f_5_xtea__c_xtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +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; @@ -176,64 +176,64 @@ __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":34 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + /* "/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 = 34; goto __pyx_L1;} + __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":34 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + /* "/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_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 = 34; goto __pyx_L1;} + __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/_xtea.pyx":35 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 35; goto __pyx_L1;} + __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/_xtea.pyx":35 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 35; goto __pyx_L1;} + __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/_xtea.pyx":35 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 35; goto __pyx_L1;} + __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/_xtea.pyx":35 */ - __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 35; goto __pyx_L1;} + __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/_xtea.pyx":36 */ - __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 = 36; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":37 */ - __pyx_2 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} - __pyx_1 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} - __pyx_4 = PyList_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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; @@ -242,7 +242,7 @@ __pyx_v_result = __pyx_4; __pyx_4 = 0; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":38 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":42 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -253,7 +253,7 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("_xtea._c_xtea_decrypt"); + __Pyx_AddTraceback("_xtea._c_tea_decrypt"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_rc); @@ -263,152 +263,94 @@ 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_5_xtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_f_5_xtea__c_xtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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]); - unsigned long (*__pyx_v_v); - int __pyx_v_rc; - int __pyx_v_size; - int __pyx_v_vsize; - int __pyx_v_i; + PyObject *__pyx_v_rc; 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; + 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":43 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; 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 = 43; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_v_size = __pyx_4; + (__pyx_v_v[0]) = __pyx_3; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":44 */ - __pyx_4 = (__pyx_v_size != __pyx_v_rounds); - if (__pyx_4) { + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":45 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; 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 = 45; 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 = 45; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":46 */ - __pyx_v_vsize = ((sizeof(unsigned long )) * __pyx_v_size); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":47 */ - __pyx_v_v = ((unsigned long (*))malloc(__pyx_v_vsize)); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":48 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":49 */ - __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; 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 = 49; 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/_xtea.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_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __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_6; + (__pyx_v_k[0]) = __pyx_3; /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":50 */ - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; 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 = 50; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - (__pyx_v_k[1]) = __pyx_6; + __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/_xtea.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_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __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_6; + (__pyx_v_k[2]) = __pyx_3; /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":50 */ - __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; 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 = 50; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - (__pyx_v_k[3]) = __pyx_6; + __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/_xtea.pyx":51 */ - __pyx_v_rc = xxtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); + __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/_xtea.pyx":52 */ - __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;} - Py_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_1; + __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/_xtea.pyx":53 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":54 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} - __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; 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 = 54; 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/_xtea.pyx":55 */ - free(__pyx_v_v); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":56 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -418,159 +360,105 @@ __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_5); - __Pyx_AddTraceback("_xtea._c_xxtea_encrypt"); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_xtea._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_k2p; - -static char (__pyx_k2[]) = "len(block) %i != rounds %i"; - -static PyObject *__pyx_f_5_xtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_f_5_xtea__c_xtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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]); - unsigned long (*__pyx_v_v); - int __pyx_v_rc; - int __pyx_v_size; - int __pyx_v_vsize; - int __pyx_v_i; + PyObject *__pyx_v_rc; 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; + 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":61 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; 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 = 61; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_v_size = __pyx_4; + (__pyx_v_v[0]) = __pyx_3; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":62 */ - __pyx_4 = (__pyx_v_size != __pyx_v_rounds); - if (__pyx_4) { + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":63 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} - __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;} - __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; 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 = 63; 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 = 63; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":64 */ - __pyx_v_vsize = ((sizeof(unsigned long )) * __pyx_v_size); + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":65 */ - __pyx_v_v = ((unsigned long (*))malloc(__pyx_v_vsize)); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":66 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":67 */ - __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; 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 = 67; 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/_xtea.pyx":68 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __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_6; + (__pyx_v_k[2]) = __pyx_3; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; 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 = 68; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - (__pyx_v_k[1]) = __pyx_6; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ - __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} + __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_6; + (__pyx_v_k[3]) = __pyx_3; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":68 */ - __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; 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 = 68; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - (__pyx_v_k[3]) = __pyx_6; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":69 */ - __pyx_v_rc = xxtea_decipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":70 */ - __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; goto __pyx_L1;} - Py_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_1; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":71 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":72 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;} - __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; 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 = 72; 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/_xtea.pyx":73 */ - free(__pyx_v_v); - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":74 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":62 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -580,30 +468,35 @@ __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_5); - __Pyx_AddTraceback("_xtea._c_xxtea_decrypt"); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_xtea._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_k3p; +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_ValueError; +static PyObject *__pyx_n_append; -static char (__pyx_k3[]) = "len(block) %i != rounds %i"; +static PyObject *__pyx_k1p; -static PyObject *__pyx_f_5_xtea_XXX_c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea_XXX_c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static char (__pyx_k1[]) = "len(block) %i != rounds %i"; + +static PyObject *__pyx_f_5_xtea__c_xxtea_encrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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[2]); + 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; @@ -618,105 +511,116 @@ Py_INCREF(__pyx_v_key); __pyx_v_result = Py_None; Py_INCREF(Py_None); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":79 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 79; goto __pyx_L1;} + __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 = 79; goto __pyx_L1;} + __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/_xtea.pyx":80 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":70 */ __pyx_4 = (__pyx_v_size != __pyx_v_rounds); if (__pyx_4) { - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":81 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} - __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_rounds); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} - __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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_k3p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; goto __pyx_L1;} + __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 = 81; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":82 */ - __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_block, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; 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 = 82; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - (__pyx_v_v[0]) = __pyx_6; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":72 */ + __pyx_v_v = ((unsigned long (*))malloc(((sizeof(unsigned long )) * __pyx_v_size))); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":82 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_block, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":73 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.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 = 82; goto __pyx_L1;} + __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_v[1]) = __pyx_6; + (__pyx_v_k[0]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ - __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 83; goto __pyx_L1;} + __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[0]) = __pyx_6; + (__pyx_v_k[1]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 83; goto __pyx_L1;} + __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[1]) = __pyx_6; + (__pyx_v_k[2]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ - __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} - __pyx_5 = PyObject_GetItem(__pyx_v_key, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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 = 83; goto __pyx_L1;} + __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[2]) = __pyx_6; - - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":83 */ - __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;} - __pyx_2 = PyObject_GetItem(__pyx_v_key, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; 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 = 83; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; (__pyx_v_k[3]) = __pyx_6; - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":84 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":76 */ __pyx_v_rc = xxtea_encipher(__pyx_v_v,__pyx_v_k,__pyx_v_rounds); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":85 */ - __pyx_3 = PyLong_FromUnsignedLong((__pyx_v_v[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} - __pyx_5 = PyLong_FromUnsignedLong((__pyx_v_v[1])); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} - __pyx_1 = PyList_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; goto __pyx_L1;} - PyList_SET_ITEM(__pyx_1, 0, __pyx_3); - PyList_SET_ITEM(__pyx_1, 1, __pyx_5); - __pyx_3 = 0; - __pyx_5 = 0; + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":86 */ + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":78 */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_size; ++__pyx_v_i) { + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.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/_xtea.pyx":80 */ + free(__pyx_v_v); + + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":81 */ Py_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -728,7 +632,7 @@ Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_5); - __Pyx_AddTraceback("_xtea.XXX_c_xxtea_encrypt"); + __Pyx_AddTraceback("_xtea._c_xxtea_encrypt"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_result); @@ -737,19 +641,20 @@ return __pyx_r; } -static PyObject *__pyx_k4p; +static PyObject *__pyx_k2p; -static char (__pyx_k4[]) = "len(block) %i != rounds %i"; +static char (__pyx_k2[]) = "len(block) %i != rounds %i"; -static PyObject *__pyx_f_5_xtea_XXX_c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5_xtea_XXX_c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_f_5_xtea__c_xxtea_decrypt(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_5_xtea__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[2]); + 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; @@ -764,104 +669,115 @@ Py_INCREF(__pyx_v_key); __pyx_v_result = Py_None; Py_INCREF(Py_None); - /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":91 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + /* "/home/heimes/dev/pymoul/xtea/src/xtea/_xtea.pyx":86 */ + __p... [truncated message content] |