Changeset 225
- Timestamp:
- Thu Jan 12 08:50:08 2006
- Files:
-
- branches/crypt/Build.py (modified) (diff)
- branches/crypt/source/common/launch.h (modified) (diff)
- branches/crypt/source/common/launch.c (modified) (diff)
- branches/crypt/carchive.py (modified) (diff)
- branches/crypt/support/loader/inprocsrvr_6rw.dll (modified)
- branches/crypt/support/loader/run_6dc.exe (modified)
- branches/crypt/support/loader/inprocsrvr_7rw.dll (modified)
- branches/crypt/support/loader/run_7dc.exe (modified)
- branches/crypt/support/loader/run_6rw.exe (modified)
- branches/crypt/support/loader/run_7rw.exe (modified)
- branches/crypt/support/loader/inprocsrvr_6rc.dll (modified)
- branches/crypt/support/loader/inprocsrvr_7rc.dll (modified)
- branches/crypt/support/loader/run_6rc.exe (modified)
- branches/crypt/support/loader/run_7rc.exe (modified)
- branches/crypt/support/loader/inprocsrvr_6dw.dll (modified)
- branches/crypt/support/loader/inprocsrvr_7dw.dll (modified)
- branches/crypt/support/loader/run_6dw.exe (modified)
- branches/crypt/support/loader/run_7dw.exe (modified)
- branches/crypt/support/loader/inprocsrvr_6dc.dll (modified)
- branches/crypt/support/loader/inprocsrvr_7dc.dll (modified)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
branches/crypt/Build.py
r224 r225 311 311 return cachedfile 312 312 313 UNCOMPRESSED, COMPRESSED = range(2)313 UNCOMPRESSED, COMPRESSED, ENCRYPTED = range(3) 313 313 class PKG(Target): 314 314 typ = 'PKG' … … 339 339 'BINARY':COMPRESSED, 340 340 'EXECUTABLE':COMPRESSED, 341 'PYSOURCE':COMPRESSED, 342 'PYMODULE':COMPRESSED } 341 'PYSOURCE':ENCRYPTED, 342 'PYMODULE':ENCRYPTED } 343 343 else: 344 344 self.cdict = { 'PYSOURCE':UNCOMPRESSED } -
branches/crypt/source/common/launch.h
r224 r225 139 139 EXTDECLPROC(PyObject *, PyFile_FromString, (char *, char *)); 140 140 EXTDECLPROC(PyObject *, PyString_FromStringAndSize, (const char *, int)); 141 EXTDECLPROC(char *, PyString_AsString, (PyObject *)); 141 142 EXTDECLPROC(PyObject *, PyObject_CallFunction, (PyObject *, char *, ...)); 142 143 EXTDECLPROC(PyObject *, PyModule_GetDict, (PyObject *)); -
branches/crypt/source/common/launch.c
r224 r225 66 66 DECLPROC(PyFile_FromString); 67 67 DECLPROC(PyString_FromStringAndSize); 68 DECLPROC(PyString_AsString); 68 69 DECLPROC(PyObject_CallFunction); 69 70 DECLPROC(PyModule_GetDict); … … 113 114 static TOC *f_tocend = NULL; 114 115 static COOKIE f_cookie; 116 static PyObject *AES = NULL; 115 117 116 118 unsigned char *extract(TOC *ptoc); … … 279 281 GETPROC(dll, PyFile_FromString); 280 282 GETPROC(dll, PyString_FromStringAndSize); 283 GETPROC(dll, PyString_AsString); 281 284 GETPROC(dll, PyObject_CallFunction); 282 285 GETPROC(dll, PyModule_GetDict); … … 603 606 ntohl(ptoc->ulen) - 8); 604 607 608 VS("extracted "); 605 609 VS(ptoc->name); 606 610 VS("\n"); … … 744 748 } 745 749 fread(data, ntohl(ptoc->len), 1, f_fp); 746 if (ptoc->cflag == '\1') { 750 if (ptoc->cflag == '\2') { 751 PyObject *func_new; 752 PyObject *aes_dict; 753 PyObject *aes_obj; 754 PyObject *ddata; 755 long block_size; 756 char *iv; 757 758 if (!AES) 759 AES = PyImport_ImportModule("AES"); 760 aes_dict = PyModule_GetDict(AES); 761 func_new = PyDict_GetItemString(aes_dict, "new"); 762 block_size = PyInt_AsLong(PyDict_GetItemString(aes_dict, "block_size")); 763 iv = malloc(block_size); 764 memset(iv, 0, block_size); 765 766 aes_obj = PyObject_CallFunction(func_new, "s#Os#", 767 data, 32, 768 PyDict_GetItemString(aes_dict, "MODE_CFB"), 769 iv, block_size); 770 771 ddata = PyObject_CallMethod(aes_obj, "decrypt", "s#", data+32, ntohl(ptoc->len)-32); 772 memcpy(data, PyString_AsString(ddata), ntohl(ptoc->len)-32); 773 Py_DECREF(aes_obj); 774 Py_DECREF(ddata); 775 VS("decrypted "); 776 VS(ptoc->name); 777 VS("\n"); 778 } 779 if (ptoc->cflag == '\1' || ptoc->cflag == '\2') { 747 780 #ifndef NOZLIB 748 781 tmp = decompress(data, ptoc); -
branches/crypt/carchive.py
r220 r225 185 185 self.lib.seek(self.pkgstart+dpos) 186 186 rslt = self.lib.read(dlen) 187 if flag == 1: 187 if flag == 2: 188 global AES 189 import AES 190 key = rslt[:32] 191 # Note: keep this in sync with bootloader's code 192 rslt = AES.new(key, AES.MODE_CFB, "\0"*AES.block_size).decrypt(rslt[32:]) 193 if flag == 1 or flag == 2: 188 194 rslt = zlib.decompress(rslt) 189 195 if typcd == 'M': … … 205 211 entry[1] is fullpathname of the file. 206 212 entry[2] is a flag for it's storage format (0==uncompressed, 207 1==compressed) 213 1==compressed, 2==compressed+encrypted) 207 213 entry[3] is the entry's type code. 208 214 Version 5: … … 231 237 raise 232 238 ulen = len(s) 233 if flag == 1: 239 assert flag in range(3) 240 if flag == 1 or flag == 2: 234 241 s = zlib.compress(s, self.LEVEL) 242 if flag == 2: 243 global AES 244 import AES, Crypt 245 key = Crypt.gen_random_key(32) 246 # Note: keep this in sync with bootloader's code 247 s = key + AES.new(key, AES.MODE_CFB, "\0"*AES.block_size).encrypt(s) 235 248 dlen = len(s) 236 249 where = self.lib.tell()
