MCPcopy Create free account
hub / github.com/apache/arrow / unwrap_key

Method unwrap_key

python/pyarrow/tests/parquet/encryption.py:42–54  ·  view source on GitHub ↗

Not a secure cipher - just extract the key from the wrapped key

(self, wrapped_key, master_key_identifier)

Source from the content-addressed store, hash-verified

40 return result
41
42 def unwrap_key(self, wrapped_key, master_key_identifier):
43 """Not a secure cipher - just extract the key from
44 the wrapped key"""
45 if master_key_identifier not in self.master_keys_map:
46 raise ValueError("Unknown master key", master_key_identifier)
47 expected_master_key = self.master_keys_map[master_key_identifier]
48 decoded_wrapped_key = base64.b64decode(wrapped_key)
49 master_key_bytes = decoded_wrapped_key[:16]
50 decrypted_key = decoded_wrapped_key[16:]
51 if (expected_master_key == master_key_bytes.decode('utf-8')):
52 return decrypted_key
53 raise ValueError("Incorrect master key used",
54 master_key_bytes, decrypted_key)
55
56
57def parse_wrapped_key(wrapped_key: str) -> tuple[str, int, bytes]:

Callers 1

UnwrapKeyMethod · 0.45

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected