K i NddlZddlmcmZGddej ZdZy)Nc"eZdZdZdZdZdZy)InMemoryKmsClientzRThis is a mock class implementation of KmsClient, built for testing only. cdtjj||j|_y)z%Create an InMemoryKmsClient instance.N)pe KmsClient__init__custom_kms_confmaster_keys_map)selfconfigs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pyarrow/tests/parquet/encryption.pyrzInMemoryKmsClient.__init__s" d#%55c|j|jd}dj||g}tj|}|S)z`Not a secure cipher - the wrapped key is just the master key concatenated with key bytesutf-8r)r encodejoinbase64 b64encode)r key_bytesmaster_key_identifiermaster_key_bytes wrapped_keyresults r wrap_keyzInMemoryKmsClient.wrap_key sM //0EFMM hh 0)<= !!+. rc|j|}tj|}|dd}|dd}||jdk(r|St d||)zGNot a secure cipher - just extract the key from the wrapped keyNrzIncorrect master key used)r r b64decodedecode ValueError)r rrexpected_master_keydecoded_wrapped_keyr decrypted_keys r unwrap_keyzInMemoryKmsClient.unwrap_key)so#223HI$..{;.s3+BC0 #3#:#:7#C C 4)=: :rN)__name__ __module__ __qualname____doc__rrr#rr rrs6  :rrcxt|d5}|jd}|dk(sJ dddy#1swYyxYw)zVerify that the file is encrypted by looking at its first 4 bytes. If it's the magic string PARE then this is a parquet with encrypted footer.rbsPAREN)openread)pathfile magic_strs r verify_file_encryptedr16s@ dD $TIIaL G###$$$s09)rpyarrow.parquet.encryptionparquet encryptionrrrr1r(rr r5s&"'': :@$r