From fcd4883645d53f8488d4f92508a74139271008ef Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 25 Jan 2024 23:33:18 -1000 Subject: [PATCH] Use hashlib for klap since its faster (#711) --- kasa/klaptransport.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kasa/klaptransport.py b/kasa/klaptransport.py index cd0e3de6..66052f59 100644 --- a/kasa/klaptransport.py +++ b/kasa/klaptransport.py @@ -467,13 +467,9 @@ class KlapEncryptionSession: padder = padding.PKCS7(128).padder() padded_data = padder.update(msg) + padder.finalize() ciphertext = encryptor.update(padded_data) + encryptor.finalize() - - digest = hashes.Hash(hashes.SHA256()) - digest.update( + signature = hashlib.sha256( self._sig + self._seq.to_bytes(4, "big", signed=True) + ciphertext - ) - signature = digest.finalize() - + ).digest() return (signature + ciphertext, self._seq) def decrypt(self, msg):