Skip to content

Commit 1ab2695

Browse files
committed
Merge branch 'master' into plugin-store
2 parents 78f60cd + 76b86cb commit 1ab2695

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

mod-deploy.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/share/mod/html/css
2727
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/share/mod/html/js
2828
ssh ${SSH_OPTIONS} ${TARGET} mkdir -p /usr/share/mod/html/css/fontello/{css,font} /usr/share/mod/html/js/{lib/slick/fonts,utils}
2929

30-
ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.4/site-packages/mod/*.py*
31-
ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.4/site-packages/mod/communication/*.py*
32-
ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.4/site-packages/modtools/*.py*
30+
ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.*/site-packages/mod/*.py*
31+
ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.*/site-packages/mod/communication/*.py*
32+
ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.*/site-packages/modtools/*.py*
3333

3434
scp ${SCP_OPTIONS} html/*.html ${TARGET}:/usr/share/mod/html/
3535
scp ${SCP_OPTIONS} html/include/*.html ${TARGET}:/usr/share/mod/html/include/
@@ -45,12 +45,12 @@ scp ${SCP_OPTIONS} html/js/lib/slick/fonts/*.* ${TARGET}:/usr/share/mod/html/j
4545
scp ${SCP_OPTIONS} html/js/utils/*.js ${TARGET}:/usr/share/mod/html/js/utils/
4646
scp ${SCP_OPTIONS} html/img/*.png ${TARGET}:/usr/share/mod/html/img/
4747
scp ${SCP_OPTIONS} html/img/*.svg ${TARGET}:/usr/share/mod/html/img/
48-
scp ${SCP_OPTIONS} mod/*.py ${TARGET}:/usr/lib/python3.4/site-packages/mod/
49-
scp ${SCP_OPTIONS} mod/communication/*.py ${TARGET}:/usr/lib/python3.4/site-packages/mod/communication/
50-
scp ${SCP_OPTIONS} modtools/*.py ${TARGET}:/usr/lib/python3.4/site-packages/modtools/
48+
scp ${SCP_OPTIONS} mod/*.py ${TARGET}:/usr/lib/python3.*/site-packages/mod/
49+
scp ${SCP_OPTIONS} mod/communication/*.py ${TARGET}:/usr/lib/python3.*/site-packages/mod/communication/
50+
scp ${SCP_OPTIONS} modtools/*.py ${TARGET}:/usr/lib/python3.*/site-packages/modtools/
5151

52-
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.4/site-packages/mod/__pycache__
53-
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.4/site-packages/mod/communication/__pycache__
54-
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.4/site-packages/modtools/__pycache__
52+
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.*/site-packages/mod/__pycache__
53+
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.*/site-packages/mod/communication/__pycache__
54+
ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.*/site-packages/modtools/__pycache__
5555

5656
echo "all ok"

mod/communication/crypto.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
import io
66
import uuid
77

8-
from Crypto.Cipher import PKCS1_OAEP, AES
9-
from Crypto.PublicKey import RSA
10-
from Crypto.Signature import PKCS1_v1_5
11-
from Crypto.Hash import SHA1
8+
try:
9+
from Cryptodome.Cipher import PKCS1_OAEP, AES
10+
from Cryptodome.Hash import SHA1
11+
from Cryptodome.PublicKey import RSA
12+
from Cryptodome.Signature import pkcs1_15 as PKCS1_v1_5
13+
usingCryptodome = True
14+
except ImportError:
15+
from Crypto.Cipher import PKCS1_OAEP, AES
16+
from Crypto.Hash import SHA1
17+
from Crypto.PublicKey import RSA
18+
from Crypto.Signature import PKCS1_v1_5
19+
usingCryptodome = False
1220

1321

1422
def encrypt(recipient_key_txt: str, data: str):
@@ -24,20 +32,25 @@ def encrypt(recipient_key_txt: str, data: str):
2432

2533
# Encrypt the data with the AES session keynonce: str, nonce: str,
2634
cipher_aes = AES.new(session_key, AES.MODE_EAX, uuid.uuid4().bytes)
27-
ciphertext, tag = cipher_aes.encrypt_and_digest(data)
35+
if usingCryptodome:
36+
ciphertext, tag = cipher_aes.encrypt_and_digest(bytes(data, 'utf-8'))
37+
else:
38+
ciphertext, tag = cipher_aes.encrypt_and_digest(data)
2839
[out.write(x) for x in (cipher_aes.nonce, tag, ciphertext)]
2940
out.seek(0)
3041
return out.getvalue()
3142

3243

3344
def decrypt(private_key_txt: str, encrypted: bytes):
34-
3545
private_key = RSA.importKey(private_key_txt)
36-
private_key_size = int((private_key.size() + 1)/8)
46+
if usingCryptodome:
47+
private_key_size = int((private_key.size_in_bits() + 1)/8)
48+
else:
49+
private_key_size = int((private_key.size() + 1)/8)
3750

3851
buffer = io.BytesIO(encrypted)
3952
session_key, nonce, tag, ciphertext = \
40-
[buffer .read(x) for x in (private_key_size, 16, 16, -1)]
53+
[buffer.read(x) for x in (private_key_size, 16, 16, -1)]
4154

4255
# Decrypt the session key with the public RSA key
4356
cipher_rsa = PKCS1_OAEP.new(private_key)
@@ -56,8 +69,15 @@ def sign_message_sha1(key_txt: str, message: str):
5669
return PKCS1_v1_5.new(key).sign(sha1)
5770

5871

59-
def verify_signature(sender_key_txt: str, contents: str, signature: str):
72+
def verify_signature(sender_key_txt: str, contents: str, signature: bytes):
6073
sender_key = RSA.importKey(sender_key_txt)
6174
sha1 = SHA1.new()
6275
sha1.update(contents.encode())
63-
return PKCS1_v1_5.new(sender_key).verify(sha1, signature)
76+
if usingCryptodome:
77+
try:
78+
PKCS1_v1_5.new(sender_key).verify(sha1, signature)
79+
return True
80+
except ValueError:
81+
return False
82+
else:
83+
return PKCS1_v1_5.new(sender_key).verify(sha1, signature)

mod/screenshot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import logging
99

1010
from tornado.ioloop import IOLoop
11-
from mod.settings import HTML_DIR, DEV_ENVIRONMENT, DEVICE_KEY, CACHE_DIR
11+
from mod.settings import HTML_DIR, DEV_ENVIRONMENT, DEVICE_KEY, CACHE_DIR, APP
1212

1313

1414
def generate_screenshot(bundle_path, callback):
@@ -24,7 +24,7 @@ def generate_screenshot(bundle_path, callback):
2424
cwd = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
2525

2626
# running packaged through cxfreeze
27-
if os.path.isfile(sys.argv[0]):
27+
if APP and os.path.isfile(sys.argv[0]):
2828
cmd = [os.path.join(cwd, 'mod-pedalboard'), 'take_screenshot', bundle_path, HTML_DIR, CACHE_DIR]
2929
if sys.platform == 'win32':
3030
cmd[0] += ".exe"

0 commit comments

Comments
 (0)