aboutsummaryrefslogtreecommitdiffstats
path: root/devscripts
diff options
context:
space:
mode:
authorRogério Brito <rbrito@ime.usp.br>2015-05-18 07:48:41 -0300
committerRogério Brito <rbrito@ime.usp.br>2015-05-18 07:48:41 -0300
commit540fd68c40df72763aee5d75598675c45cfa9aba (patch)
tree4e336e314c43188cc09439734e2a0ca95f05ccef /devscripts
parentf46044c66663049e286c20ee015db99d47d9dd8a (diff)
downloadyoutube-dl-540fd68c40df72763aee5d75598675c45cfa9aba.zip
youtube-dl-540fd68c40df72763aee5d75598675c45cfa9aba.tar.gz
youtube-dl-540fd68c40df72763aee5d75598675c45cfa9aba.tar.bz2
Imported Upstream version 2015.05.15
Diffstat (limited to 'devscripts')
-rw-r--r--devscripts/check-porn.py2
-rw-r--r--devscripts/generate_aes_testdata.py42
2 files changed, 43 insertions, 1 deletions
diff --git a/devscripts/check-porn.py b/devscripts/check-porn.py
index 6a5bd9e..7a219eb 100644
--- a/devscripts/check-porn.py
+++ b/devscripts/check-porn.py
@@ -28,7 +28,7 @@ for test in get_testcases():
if METHOD == 'EURISTIC':
try:
webpage = compat_urllib_request.urlopen(test['url'], timeout=10).read()
- except:
+ except Exception:
print('\nFail: {0}'.format(test['name']))
continue
diff --git a/devscripts/generate_aes_testdata.py b/devscripts/generate_aes_testdata.py
new file mode 100644
index 0000000..2e389fc
--- /dev/null
+++ b/devscripts/generate_aes_testdata.py
@@ -0,0 +1,42 @@
+from __future__ import unicode_literals
+
+import codecs
+import subprocess
+
+import os
+import sys
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from youtube_dl.utils import intlist_to_bytes
+from youtube_dl.aes import aes_encrypt, key_expansion
+
+secret_msg = b'Secret message goes here'
+
+
+def hex_str(int_list):
+ return codecs.encode(intlist_to_bytes(int_list), 'hex')
+
+
+def openssl_encode(algo, key, iv):
+ cmd = ['openssl', 'enc', '-e', '-' + algo, '-K', hex_str(key), '-iv', hex_str(iv)]
+ prog = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ out, _ = prog.communicate(secret_msg)
+ return out
+
+iv = key = [0x20, 0x15] + 14 * [0]
+
+r = openssl_encode('aes-128-cbc', key, iv)
+print('aes_cbc_decrypt')
+print(repr(r))
+
+password = key
+new_key = aes_encrypt(password, key_expansion(password))
+r = openssl_encode('aes-128-ctr', new_key, iv)
+print('aes_decrypt_text 16')
+print(repr(r))
+
+password = key + 16 * [0]
+new_key = aes_encrypt(password, key_expansion(password)) * (32 // 16)
+r = openssl_encode('aes-256-ctr', new_key, iv)
+print('aes_decrypt_text 32')
+print(repr(r))