diff options
Diffstat (limited to 'devscripts/transition_helper_exe/youtube-dl.py')
-rw-r--r-- | devscripts/transition_helper_exe/youtube-dl.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/devscripts/transition_helper_exe/youtube-dl.py b/devscripts/transition_helper_exe/youtube-dl.py index 6297dfd40..edb449fb3 100644 --- a/devscripts/transition_helper_exe/youtube-dl.py +++ b/devscripts/transition_helper_exe/youtube-dl.py @@ -4,13 +4,17 @@ import sys, os import urllib2 import json, hashlib + def rsa_verify(message, signature, key): from struct import pack from hashlib import sha256 from sys import version_info + def b(x): - if version_info[0] == 2: return x - else: return x.encode('latin1') + if version_info[0] == 2: + return x + else: + return x.encode('latin1') assert(type(message) == type(b(''))) block_size = 0 n = key[0] @@ -23,13 +27,17 @@ def rsa_verify(message, signature, key): raw_bytes.insert(0, pack("B", signature & 0xFF)) signature >>= 8 signature = (block_size - len(raw_bytes)) * b('\x00') + b('').join(raw_bytes) - if signature[0:2] != b('\x00\x01'): return False + if signature[0:2] != b('\x00\x01'): + return False signature = signature[2:] - if not b('\x00') in signature: return False + if not b('\x00') in signature: + return False signature = signature[signature.index(b('\x00'))+1:] - if not signature.startswith(b('\x30\x31\x30\x0D\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20')): return False + if not signature.startswith(b('\x30\x31\x30\x0D\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20')): + return False signature = signature[19:] - if signature != sha256(message).digest(): return False + if signature != sha256(message).digest(): + return False return True sys.stderr.write(u'Hi! We changed distribution method and now youtube-dl needs to update itself one more time.\n') @@ -92,7 +100,7 @@ echo Updating youtube-dl... ping 127.0.0.1 -n 5 -w 1000 > NUL move /Y "%s.new" "%s" del "%s" - \n""" %(exe, exe, bat)) + \n""" % (exe, exe, bat)) b.close() os.startfile(bat) |