| 430 | return False |
| 431 | |
| 432 | def decrypt_key_file(self, data, passphrase): |
| 433 | unpacker = get_limited_unpacker("key") |
| 434 | unpacker.feed(data) |
| 435 | data = unpacker.unpack() |
| 436 | encrypted_key = EncryptedKey(internal_dict=data) |
| 437 | if encrypted_key.version != 1: |
| 438 | raise UnsupportedKeyFormatError() |
| 439 | else: |
| 440 | self._encrypted_key_algorithm = encrypted_key.algorithm |
| 441 | if encrypted_key.algorithm == "sha256": |
| 442 | return self.decrypt_key_file_pbkdf2(encrypted_key, passphrase) |
| 443 | elif encrypted_key.algorithm == "argon2 chacha20-poly1305": |
| 444 | return self.decrypt_key_file_argon2(encrypted_key, passphrase) |
| 445 | else: |
| 446 | raise UnsupportedKeyFormatError() |
| 447 | |
| 448 | @staticmethod |
| 449 | def pbkdf2(passphrase, salt, iterations, output_len_in_bytes): |