
    h	                     N    S SK r S SKJs  Jr   " S S\R
                  5      rS rg)    Nc                   *    \ rS rSrSrS rS rS rSrg)InMemoryKmsClient   zJThis is a mock class implementation of KmsClient, built for testing
only.
c                 d    [         R                  R                  U 5        UR                  U l        g)z%Create an InMemoryKmsClient instance.N)pe	KmsClient__init__custom_kms_confmaster_keys_map)selfconfigs     Z/home/james-whalen/.local/lib/python3.13/site-packages/pyarrow/tests/parquet/encryption.pyr	   InMemoryKmsClient.__init__   s"    
d#%55    c                     U R                   U   R                  S5      nSR                  X1/5      n[        R                  " U5      nU$ )zXNot a secure cipher - the wrapped key
is just the master key concatenated with key bytesutf-8r   )r   encodejoinbase64	b64encode)r   	key_bytesmaster_key_identifiermaster_key_byteswrapped_keyresults         r   wrap_keyInMemoryKmsClient.wrap_key    sK      //0EFMMhh 0<=!!+.r   c                     U R                   U   n[        R                  " U5      nUSS nUSS nX5R                  S5      :X  a  U$ [	        SXV5      e)z?Not a secure cipher - just extract the key from
the wrapped keyN   r   zIncorrect master key used)r   r   	b64decodedecode
ValueError)r   r   r   expected_master_keydecoded_wrapped_keyr   decrypted_keys          r   
unwrap_keyInMemoryKmsClient.unwrap_key)   sj     #223HI$..{;.s3+BC0#:#:7#CC  4): 	:r   )r   N)	__name__
__module____qualname____firstlineno____doc__r	   r   r&   __static_attributes__ r   r   r   r      s    6

:r   r   c                     [        U S5       nUR                  S5      nUS:X  d   e SSS5        g! , (       d  f       g= f)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.rb   s   PAREN)openread)pathfile	magic_strs      r   verify_file_encryptedr7   6   s7     
dD	TIIaL	G### 
		s   1
?)r   pyarrow.parquet.encryptionparquet
encryptionr   r   r   r7   r.   r   r   <module>r;      s&   "  ' ': :@$r   