Commit e06b95c0 authored by Philipp Hörist's avatar Philipp Hörist

[url_image_preview] Support 12bit IVs

Support 12bit IVs on encrypted httpupload files
parent 4dac406c
...@@ -19,6 +19,7 @@ import gtk ...@@ -19,6 +19,7 @@ import gtk
import gobject import gobject
import os import os
import hashlib import hashlib
import binascii
from urlparse import urlparse from urlparse import urlparse
from io import BytesIO from io import BytesIO
import shutil import shutil
...@@ -198,18 +199,17 @@ class Base(object): ...@@ -198,18 +199,17 @@ class Base(object):
key = '' key = ''
iv = '' iv = ''
encrypted = False encrypted = False
if len(urlparts.fragment): if urlparts.fragment:
fragment = [] fragment = binascii.unhexlify(urlparts.fragment)
try: key = fragment[16:]
for i in range(0, len(urlparts.fragment), 2): iv = fragment[:16]
fragment.append(chr(int(urlparts.fragment[i:i + 2], 16))) if len(key) == 32 and len(iv) == 16:
fragment = ''.join(fragment) encrypted = True
key = fragment[16:] if not encrypted:
iv = fragment[:16] key = fragment[12:]
if len(key) == 32 and len(iv) == 16: iv = fragment[:12]
if len(key) == 32 and len(iv) == 12:
encrypted = True encrypted = True
except:
pass
# file exists but thumbnail got deleted # file exists but thumbnail got deleted
if os.path.exists(filepath) and not os.path.exists(thumbpath): if os.path.exists(filepath) and not os.path.exists(thumbpath):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment