Skip to content

Commit

Permalink
Increase Remote app PBKDF2 iterations to 600,000 and SHA256 hash
Browse files Browse the repository at this point in the history
OWASP Cheat Sheet recommends 600,000 iterations for SHA256.

https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2
  • Loading branch information
JonnyWong16 committed Apr 5, 2024
1 parent 4582ff4 commit 282810e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plexpy/notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
from Cryptodome.Protocol.KDF import PBKDF2
from Cryptodome.Cipher import AES
from Cryptodome.Random import get_random_bytes
from Cryptodome.Hash import HMAC, SHA1
from Cryptodome.Hash import SHA256
CRYPTODOME = True
except ImportError:
try:
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from Crypto.Hash import HMAC, SHA1
from Crypto.Hash import SHA256
CRYPTODOME = True
except ImportError:
CRYPTODOME = False
Expand Down Expand Up @@ -3825,9 +3825,8 @@ def agent_notify(self, subject='', body='', action='', notification_id=None, **k
salt = get_random_bytes(16)
passphrase = device['device_token']
key_length = 32 # AES256
iterations = 1000
key = PBKDF2(passphrase, salt, dkLen=key_length, count=iterations,
prf=lambda p, s: HMAC.new(p, s, SHA1).digest())
iterations = 600000
key = PBKDF2(passphrase, salt, dkLen=key_length, count=iterations, hmac_hash_module=SHA256)

#logger.debug("Encryption key (base64): {}".format(base64.b64encode(key)))

Expand All @@ -3846,6 +3845,7 @@ def agent_notify(self, subject='', body='', action='', notification_id=None, **k
'include_player_ids': [device['onesignal_id']],
'contents': {'en': 'Tautulli Notification'},
'data': {'encrypted': True,
'version': 2,
'cipher_text': base64.b64encode(encrypted_data),
'nonce': base64.b64encode(nonce),
'salt': base64.b64encode(salt),
Expand Down

0 comments on commit 282810e

Please sign in to comment.