§
    ÷¢±j+  ã                   ó,  — d dl Z d dlZd dlmZ d dlmZ d dlZd dlmZm	Z	 d dl
mZmZmZmZmZmZmZmZmZmZmZ  G d„ dej        ¦  «        ZdZd	Ze j        d
ededee         fd„¦   «         Z G d„ dej        ¦  «        Zedk    r e	¦   «          dS dS )é    N)ÚIterator)ÚAny)Úfind_test_fixtureÚtestmain)ÚCERT_QUERY_CONTENT_CERTÚCERT_QUERY_CONTENT_FLAG_CERTÚ CERT_QUERY_FORMAT_BASE64_ENCODEDÚCERT_QUERY_FORMAT_BINARYÚCERT_QUERY_FORMAT_FLAG_ALLÚCERT_QUERY_OBJECT_BLOBÚCERT_QUERY_OBJECT_FILEÚCERT_STORE_ADD_REPLACE_EXISTINGÚCERT_STORE_PROV_SYSTEMÚCERT_SYSTEM_STORE_CURRENT_USERÚCERT_SYSTEM_STORE_LOCAL_MACHINEc                   ó   — e Zd Zd„ Zd„ ZdS )ÚCryptc                 óÚ   — d}d }d}d}d }t          j        |||d ||¦  «        }t          j        ||d ||¦  «        \  }}|                      ||¦  «         |                      ||¦  «         d S )Nó   My test dataúMy descriptionr   ©Ú
win32cryptÚCryptProtectDataÚCryptUnprotectDataÚassertEqual©	ÚselfÚdataÚentropyÚdescÚflagsÚpsÚblobÚgot_descÚgot_datas	            úfC:\Users\johnn\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32/test/test_win32crypt.pyÚ
testSimplezCrypt.testSimple   s‹   € ØˆØˆØˆØˆØˆÝÔ*¨4°°wÀÀbÈ%ÑPÔPˆÝ'Ô:Ø�'˜4  Uñ
ô 
Ñˆ�(ð 	×Ò˜˜xÑ(Ô(Ð(Ø×Ò˜˜xÑ(Ô(Ð(Ð(Ð(ó    c                 óÚ   — d}d}d}d}d }t          j        |||d ||¦  «        }t          j        ||d ||¦  «        \  }}|                      ||¦  «         |                      ||¦  «         d S )Nr   s   My test entropyr   r   r   r   s	            r&   ÚtestEntropyzCrypt.testEntropy'   s‹   € ØˆØ$ˆØˆØˆØˆÝÔ*¨4°°wÀÀbÈ%ÑPÔPˆÝ'Ô:Ø�'˜4  Uñ
ô 
Ñˆ�(ð 	×Ò˜˜xÑ(Ô(Ð(Ø×Ò˜˜xÑ(Ô(Ð(Ð(Ð(r(   N)Ú__name__Ú
__module__Ú__qualname__r'   r*   © r(   r&   r   r      s2   € € € € € ð)ð )ð )ð)ð )ð )ð )ð )r(   r   ÚLocalMachineÚCurrentUserÚ
store_nameÚstore_locationÚreturnc              #   óè   K  — d}	 t          j        t          dd|t          k    rt          nt
          | ¦  «        }|V — |�|                     ¦   «          dS dS # |�|                     ¦   «          w w xY w)z”Open a windows certificate store

    :param store_name: store name
    :param store_location: store location
    :return: handle to cert store
    Nr   )r   ÚCertOpenStorer   Ú_LOCAL_MACHINEr   r   ÚCertCloseStore)r1   r2   Úhandles      r&   Úopen_windows_certstorer9   :   sœ   è è € ð €Fð$ÝÔ)Ý"ØØð "¥^Ò3Ð3õ 0Ð/å3àñ

ô 

ˆð ˆˆˆàÐØ×!Ò!Ñ#Ô#Ð#Ð#Ð#ð Ðøˆ6ÐØ×!Ò!Ñ#Ô#Ð#Ð#ð øøøs   †8A ÁA1c                   ó,   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )Ú	TestCertsc                 ó   — t          t          |¦  «        d¦  «        5 }t          |                     ¦   «         ¦  «        }t	          j        t          |t          t          d¦  «        cd d d ¦  «         S # 1 swxY w Y   d S )NÚrbr   )	Úopenr   Ú	bytearrayÚreadr   ÚCryptQueryObjectr   r   r   )r   Ú	file_nameÚfÚbufs       r&   ÚreadCertFilezTestCerts.readCertFileV   s°   € ÝÕ# IÑ.Ô.°Ñ5Ô5ð 	¸Ý˜AŸFšF™HœHÑ%Ô%ˆCÝÔ.Ý&ØÝ,Ý*Øñô ð	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   žAA3Á3A7Á:A7c                 óö   — d}t          j        t          t          |¦  «        t          t
          d¦  «        }|                      |d         t          ¦  «         |                      |d         t          ¦  «         d S )Núwin32crypt_testcert_base64.cerr   Ú
FormatTypeÚContentType)	r   rA   r   r   r   r   r   r	   r   )r   ÚfilenameÚcerts      r&   ÚtestReadCertFileszTestCerts.testReadCertFilesa   sr   € ð 4ˆÝÔ*Ý"Ý˜hÑ'Ô'Ý(Ý&Øñ
ô 
ˆð 	×Ò˜˜lÔ+Õ-MÑNÔNÐNØ×Ò˜˜mÔ,Õ.EÑFÔFÐFÐFÐFr(   c                 óª  — |                       |¦  «        }|                      |d         |¦  «         |                      |d         t          ¦  «         t          t          d¦  «        5 }|                     |d         t          ¦  «        }|                      t          | 	                    ¦   «         ¦  «        ¦  «         |  
                    t          |                     ¦   «         ¦  «        ¦  «         |                     ¦   «          	 |                     ¦   «          t          d¦  «        ‚# t          $ r Y nw xY w	 d d d ¦  «         d S # 1 swxY w Y   d S )NrH   rI   ÚTempÚContextz-should not be able to close the context twice)rE   r   r   r9   Ú_CURRENT_USERÚ CertAddCertificateContextToStorer   Ú
assertTrueÚlenÚCertEnumCertificatesInStoreÚassertFalseÚCertEnumCTLsInStoreÚCertFreeCertificateContextÚAssertionErrorÚ
ValueError)r   rJ   Úexpected_formatrK   ÚstoreÚcontexts         r&   ÚcheckCertFilezTestCerts.checkCertFiler   sŸ  € Ø× Ò  Ñ*Ô*ˆØ×Ò˜˜lÔ+¨_Ñ=Ô=Ð=Ø×Ò˜˜mÔ,Õ.EÑFÔFÐFå#¥M°6Ñ:Ô:ð 	V¸eØ×<Ò<Ø�Y”Õ!@ñô ˆGð �OŠO�C × AÒ AÑ CÔ CÑDÔDÑEÔEÐEØ×Ò�S ×!:Ò!:Ñ!<Ô!<Ñ=Ô=Ñ>Ô>Ð>Ø×.Ò.Ñ0Ô0Ð0ðVØ×2Ò2Ñ4Ô4Ð4õ %Ð%TÑUÔUÐUøõ ð ð ð Ø�ðøøøØð	Vð 	Vð 	Vñ 	Vô 	Vð 	Vð 	Vð 	Vð 	Vð 	Vð 	Vð 	Vøøøð 	Vð 	Vð 	Vð 	Vð 	Vð 	Vs7   Á(BEÄD*ÄEÄ*
D7Ä4EÄ6D7Ä7EÅEÅEc                 ó<   — |                       dt          ¦  «         d S )NrG   )r]   r	   ©r   s    r&   ÚtestCertBase64zTestCerts.testCertBase64†   s*   € Ø×ÒØ,Õ.Nñ	
ô 	
ð 	
ð 	
ð 	
r(   c                 ó<   — |                       dt          ¦  «         d S )Nzwin32crypt_testcert_bin.cer)r]   r
   r_   s    r&   ÚtestCertBinaryzTestCerts.testCertBinary‹   s    € Ø×ÒÐ8Õ:RÑSÔSÐSÐSÐSr(   N)r+   r,   r-   rE   rL   r]   r`   rb   r.   r(   r&   r;   r;   U   sj   € € € € € ð	ð 	ð 	ðGð Gð Gð"Vð Vð Vð(
ð 
ð 
ð
Tð Tð Tð Tð Tr(   r;   Ú__main__)Ú
contextlibÚunittestÚcollections.abcr   Útypingr   r   Úpywin32_testutilr   r   Úwin32cryptconr   r   r	   r
   r   r   r   r   r   r   r   ÚTestCaser   r6   rP   ÚcontextmanagerÚstrr9   r;   r+   r.   r(   r&   ú<module>rm      s¶  ðð Ð Ð Ð Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð)ð )ð )ð )ð )ˆHÔñ )ô )ð )ð:  €Ø€ð Ôð$ sð $¸Cð $ÀHÈSÄMð $ð $ð $ñ Ôð$ð47Tð 7Tð 7Tð 7Tð 7T�Ô!ñ 7Tô 7Tð 7Tðt ˆzÒÐØ€H�J„J€J€J€Jð Ðr(   