312,7 → 312,7 |
class DataReaderV1(object): |
def _decrypt_compressed_data(self, key, cipher_text): |
''' Decrypt cipher_text using key. |
decrypt(str, str) -> cleartext (gzipped xml) |
_decrypt_compressed_data(str, str) -> cleartext (gzipped xml) |
|
This function will use the underlying, available, cipher module. |
''' |
337,6 → 337,9 |
ct = c.decrypt(cipher_text[28:], iv=iv) |
return ct |
def get_xml(self, data, password): |
''' Extract the XML contents from the encrypted and compressed input. |
get_xml(str, str) -> str |
''' |
# Pad password |
password += (chr(0) * (32 - len(password))) |
# Decrypt. Decrypted data is compressed |
347,7 → 350,15 |
return zlib.decompress(cleardata_gz[:-padlen], 15, 2**15) |
|
class DataReader(object): |
''' Interface to read Revelation's data files ''' |
def __init__(self, filename): |
''' DataReader(str) |
Loads file data and checks file format and data version for compatibility |
|
raises IOError If filename not readable |
raises IOError If filename not in Revelation format |
raises IOError If filename not in a supported data format version |
''' |
self._impl = None |
self._data = None |
self._filename = filename |
363,6 → 374,9 |
f.close() |
self._check_header() |
def _check_header(self): |
''' Checks the file header for compatibility |
_check_header() -> None |
''' |
header = self._data[0:12] |
magic = header[0:4] |
if magic != "rvl\x00": |
374,6 → 388,9 |
else: |
raise IOError('File \'%s\' is in a newer, unsupported, data format' % self._filename) |
def get_xml(self, password): |
''' Decrypt and decompress file data |
get_xml(str) -> str |
''' |
return self._impl.get_xml(self._data, password) |
|
def main(argv): |