mirror of
				https://github.com/python-kasa/python-kasa.git
				synced 2025-11-04 06:32:07 +00:00 
			
		
		
		
	Use hashlib for klap since its faster (#711)
This commit is contained in:
		@@ -467,13 +467,9 @@ class KlapEncryptionSession:
 | 
				
			|||||||
        padder = padding.PKCS7(128).padder()
 | 
					        padder = padding.PKCS7(128).padder()
 | 
				
			||||||
        padded_data = padder.update(msg) + padder.finalize()
 | 
					        padded_data = padder.update(msg) + padder.finalize()
 | 
				
			||||||
        ciphertext = encryptor.update(padded_data) + encryptor.finalize()
 | 
					        ciphertext = encryptor.update(padded_data) + encryptor.finalize()
 | 
				
			||||||
 | 
					        signature = hashlib.sha256(
 | 
				
			||||||
        digest = hashes.Hash(hashes.SHA256())
 | 
					 | 
				
			||||||
        digest.update(
 | 
					 | 
				
			||||||
            self._sig + self._seq.to_bytes(4, "big", signed=True) + ciphertext
 | 
					            self._sig + self._seq.to_bytes(4, "big", signed=True) + ciphertext
 | 
				
			||||||
        )
 | 
					        ).digest()
 | 
				
			||||||
        signature = digest.finalize()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return (signature + ciphertext, self._seq)
 | 
					        return (signature + ciphertext, self._seq)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def decrypt(self, msg):
 | 
					    def decrypt(self, msg):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user