mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Switch to SHA1 and remove gcm_tag
This commit is contained in:
parent
d2da193978
commit
fc37a8afa3
1 changed files with 8 additions and 6 deletions
|
@ -39,14 +39,14 @@ try:
|
||||||
from Cryptodome.Protocol.KDF import PBKDF2
|
from Cryptodome.Protocol.KDF import PBKDF2
|
||||||
from Cryptodome.Cipher import AES
|
from Cryptodome.Cipher import AES
|
||||||
from Cryptodome.Random import get_random_bytes
|
from Cryptodome.Random import get_random_bytes
|
||||||
from Cryptodome.Hash import HMAC, SHA256
|
from Cryptodome.Hash import HMAC, SHA1
|
||||||
CRYPTODOME = True
|
CRYPTODOME = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from Crypto.Protocol.KDF import PBKDF2
|
from Crypto.Protocol.KDF import PBKDF2
|
||||||
from Crypto.Cipher import AES
|
from Crypto.Cipher import AES
|
||||||
from Crypto.Random import get_random_bytes
|
from Crypto.Random import get_random_bytes
|
||||||
from Crypto.Hash import HMAC, SHA256
|
from Crypto.Hash import HMAC, SHA1
|
||||||
CRYPTODOME = True
|
CRYPTODOME = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
CRYPTODOME = False
|
CRYPTODOME = False
|
||||||
|
@ -716,7 +716,7 @@ class ANDROIDAPP(Notifier):
|
||||||
key_length = 32 # AES256
|
key_length = 32 # AES256
|
||||||
iterations = 1000
|
iterations = 1000
|
||||||
key = PBKDF2(passphrase, salt, dkLen=key_length, count=iterations,
|
key = PBKDF2(passphrase, salt, dkLen=key_length, count=iterations,
|
||||||
prf=lambda p, s: HMAC.new(p, s, SHA256).digest())
|
prf=lambda p, s: HMAC.new(p, s, SHA1).digest())
|
||||||
|
|
||||||
logger.debug("Encryption key (base64): {}".format(base64.b64encode(key)))
|
logger.debug("Encryption key (base64): {}".format(base64.b64encode(key)))
|
||||||
|
|
||||||
|
@ -724,6 +724,7 @@ class ANDROIDAPP(Notifier):
|
||||||
nonce = get_random_bytes(16)
|
nonce = get_random_bytes(16)
|
||||||
cipher = AES.new(key, AES.MODE_GCM, nonce)
|
cipher = AES.new(key, AES.MODE_GCM, nonce)
|
||||||
encrypted_data, gcm_tag = cipher.encrypt_and_digest(json.dumps(plaintext_data))
|
encrypted_data, gcm_tag = cipher.encrypt_and_digest(json.dumps(plaintext_data))
|
||||||
|
encrypted_data += gcm_tag
|
||||||
|
|
||||||
logger.debug("Encrypted data (base64): {}".format(base64.b64encode(encrypted_data)))
|
logger.debug("Encrypted data (base64): {}".format(base64.b64encode(encrypted_data)))
|
||||||
logger.debug("GCM tag (base64): {}".format(base64.b64encode(gcm_tag)))
|
logger.debug("GCM tag (base64): {}".format(base64.b64encode(gcm_tag)))
|
||||||
|
@ -733,8 +734,8 @@ class ANDROIDAPP(Notifier):
|
||||||
payload = {'app_id': self.ONESIGNAL_APP_ID,
|
payload = {'app_id': self.ONESIGNAL_APP_ID,
|
||||||
'include_player_ids': [self.config['device_id']],
|
'include_player_ids': [self.config['device_id']],
|
||||||
'contents': {'en': 'PlexPy Notification'},
|
'contents': {'en': 'PlexPy Notification'},
|
||||||
'data': {'cipher_text': base64.b64encode(encrypted_data),
|
'data': {'encrypted': True,
|
||||||
'gcm_tag': base64.b64encode(gcm_tag),
|
'cipher_text': base64.b64encode(encrypted_data),
|
||||||
'nonce': base64.b64encode(nonce),
|
'nonce': base64.b64encode(nonce),
|
||||||
'salt': base64.b64encode(salt)}
|
'salt': base64.b64encode(salt)}
|
||||||
}
|
}
|
||||||
|
@ -746,7 +747,8 @@ class ANDROIDAPP(Notifier):
|
||||||
payload = {'app_id': self.ONESIGNAL_APP_ID,
|
payload = {'app_id': self.ONESIGNAL_APP_ID,
|
||||||
'include_player_ids': [self.config['device_id']],
|
'include_player_ids': [self.config['device_id']],
|
||||||
'contents': {'en': 'PlexPy Notification'},
|
'contents': {'en': 'PlexPy Notification'},
|
||||||
'data': plaintext_data
|
'data': {'encrypted': False,
|
||||||
|
'plain_text': plaintext_data}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("OneSignal payload: {}".format(payload))
|
logger.debug("OneSignal payload: {}".format(payload))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue