1234567891011121314151617181920212223 |
- def decrypt(self, key, ciphertext, verify=False):
- """ decrypt data with convergence encryption.
-
- Args
- key: str, encryption key
- cipher: str, ciphertext
- verify: bool, verify decrypted data, default: False
-
- Returns
- the plain text
- """
- plain = aes(key, ciphertext)
- if verify:
- h = SHA256d(plain)
- if self.__convergence_secret:
- h.update(self.__convergence_secret)
- digest = h.digest()
- # can verify only if convergence secret is known!
- if self.__convergence_secret and not key == digest:
- msg = "Block verification error on %s." % SHA256d(key).hexdigest()
- log.error(msg)
- raise CryptError(msg)
- return plain
|