(self, key_data, passphrase)
| 409 | return key |
| 410 | |
| 411 | def _load(self, key_data, passphrase): |
| 412 | try: |
| 413 | key = binascii.a2b_base64(key_data) |
| 414 | except (ValueError, binascii.Error): |
| 415 | raise KeyfileInvalidError(self.repository._location.canonical_path(), "(repokey)") from None |
| 416 | if len(key) < 20: |
| 417 | # this is in no way a precise check, usually we have about 400b key data. |
| 418 | raise KeyfileInvalidError(self.repository._location.canonical_path(), "(repokey)") |
| 419 | data = self.decrypt_key_file(key, passphrase) |
| 420 | if data: |
| 421 | data = msgpack.unpackb(data) |
| 422 | key = Key(internal_dict=data) |
| 423 | if key.version not in (1, 2): # legacy: item.Key can still process v1 keys |
| 424 | raise UnsupportedKeyFormatError() |
| 425 | self.repository_id = key.repository_id |
| 426 | self.crypt_key = key.crypt_key |
| 427 | self.id_key = key.id_key |
| 428 | self.chunk_seed = key.chunk_seed |
| 429 | return True |
| 430 | return False |
| 431 | |
| 432 | def decrypt_key_file(self, data, passphrase): |
| 433 | unpacker = get_limited_unpacker("key") |
no test coverage detected