(self, data, passphrase)
| 510 | raise ValueError(f"Unexpected algorithm: {algorithm}") |
| 511 | |
| 512 | def encrypt_key_file_pbkdf2(self, data, passphrase): |
| 513 | salt = os.urandom(32) |
| 514 | iterations = PBKDF2_ITERATIONS |
| 515 | key = self.pbkdf2(passphrase, salt, iterations, 32) |
| 516 | hash = hmac_sha256(key, data) |
| 517 | cdata = AES(key, b"\0" * 16).encrypt(data) |
| 518 | enc_key = EncryptedKey(version=1, salt=salt, iterations=iterations, algorithm="sha256", hash=hash, data=cdata) |
| 519 | return msgpack.packb(enc_key.as_dict()) |
| 520 | |
| 521 | def encrypt_key_file_argon2(self, data, passphrase): |
| 522 | salt = os.urandom(ARGON2_SALT_BYTES) |
no test coverage detected