o
    �õ±jÐ  ã                   @   sj   d dl Z d dlmZ G dd„ dƒZG dd„ dƒZG dd„ dƒZG d	d
„ d
ƒZdd„ Zedkr3eƒ  dS dS )é    N)Úkeyblobselectorc                   @   óB   e Zd Zdd„ Zedefdd„ƒZedejfdd„ƒZ	d	d
„ Z
dS )ÚCryptoAPIKeyPropertyc                 C   s.   d | _ d | _d | _d | _d | _d | _d | _d S ©N©ÚlengthÚtypeÚunknown1Úname_lenÚnameÚ	value_lenÚvalue©Úself© r   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/winacl/dtyp/wcee/cryptoapikey.pyÚ__init__   s   
zCryptoAPIKeyProperty.__init__Údatac                 C   ó   t  t | ¡¡S r   )r   Úfrom_bufferÚioÚBytesIO©r   r   r   r   Ú
from_bytes   ó   zCryptoAPIKeyProperty.from_bytesÚbuffc                 C   s¶   t ƒ }tj|  d¡ddd�|_tj|  d¡ddd�|_|  d¡|_tj|  d¡ddd�|_tj|  d¡ddd�|_|  |j¡ 	d¡|_
|  |j¡|_|j
dkrYtj|jddd�|_|S )Né   ÚlittleF©Ú	byteorderÚsignedú	utf-16-leÚNgcSoftwareKeyPbkdf2Round)r   Úintr   Úreadr   r   r	   r
   r   Údecoder   r   )r   Úpropr   r   r   r      s   
z CryptoAPIKeyProperty.from_bufferc                 C   sj   d}|d| j  7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|S )	Nz= CryptoAPIKeyProperty =
zLength: %s
ú	Type: %s
úUnknown1: %s
zName Length: %s
z	Name: %s
zValue Length: %s
z
Value: %s
r   ©r   Útr   r   r   Ú__str__    s   zCryptoAPIKeyProperty.__str__N©Ú__name__Ú
__module__Ú__qualname__r   ÚstaticmethodÚbytesr   r   r   r   r+   r   r   r   r   r      s    	r   c                   @   s:   e Zd Zdd„ Zedefdd„ƒZedejfdd„ƒZ	d	S )
ÚCryptoAPIKeyPropertiesc                 C   s
   i | _ d S r   )Ú
propertiesr   r   r   r   r   -   s   
zCryptoAPIKeyProperties.__init__r   c                 C   r   r   )r2   r   r   r   r   r   r   r   r   0   r   z!CryptoAPIKeyProperties.from_bytesr   c                 C   s:   t ƒ }	 t | ¡}||j|j< |  ¡ t|  ¡ ƒkr|jS qr   )r2   r   r   r3   r   ÚtellÚlenÚ	getbuffer)r   r&   Úpr   r   r   r   4   s   
üz"CryptoAPIKeyProperties.from_bufferN)
r-   r.   r/   r   r0   r1   r   r   r   r   r   r   r   r   r2   +   s    r2   c                   @   r   )ÚCryptoAPIPublicKeyc                 C   s4   d | _ d | _d | _d | _d | _d | _d | _d | _d S r   ©Úheader_sizer	   Úunknown2Úheader1_sizeÚheader2_sizeÚheader1Úheader2Úkeyblobr   r   r   r   r   ?   ó   
zCryptoAPIPublicKey.__init__r   c                 C   r   r   )r8   r   r   r   r   r   r   r   r   I   r   zCryptoAPIPublicKey.from_bytesr   c                 C   s²   |   ¡ }tƒ }tj|  d¡ddd�|_|  d¡|_|  d¡|_tj|  d¡ddd�|_tj|  d¡ddd�|_	|  |j¡ 
d¡|_|  |j	¡|_|  d¡ t| ƒ}| | ¡|_|S )Nr   r   Fr   r!   é   )r4   r8   r#   r   r$   r:   r	   r;   r<   r=   r%   r>   r?   r   r   r@   )r   ÚstartÚkeyÚ	keystructr   r   r   r   M   s   
zCryptoAPIPublicKey.from_bufferc                 C   sx   d}|d| j  7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d	| j 7 }|S )
Nz== CryptoAPIPublicKey ==
zHeader Size: %s
r(   úUnknown2: %s
zHeader1 Size: %s
zHeader2 Size: %s
zHeader1: %s
zHeader2: %s
zKey: %s
r9   r)   r   r   r   r+   _   s   zCryptoAPIPublicKey.__str__Nr,   r   r   r   r   r8   >   s    
r8   c                   @   s:   e Zd Zdd„ Zdefdd„Zdejfdd„Zd	d
„ Z	dS )ÚCryptoAPIKeyFilec                 C   s4   d | _ d | _d | _d | _d | _g | _d | _g | _d S r   )r   r	   Údescription_lenr;   Ú	field_cntÚfiled_lengthsÚdescriptionÚfieldsr   r   r   r   r   n   rA   zCryptoAPIKeyFile.__init__r   c                 C   r   r   )rG   r   r   r   r   r   r   r   r   x   s   zCryptoAPIKeyFile.from_bytesr   c                 C   sê   t ƒ }|  d¡|_|  d¡|_tj|  d¡ddd�|_|  d¡|_tj|  d¡ddd�|_t	d|jƒD ]}|j
 tj|  d¡ddd�¡ q3|  dd¡ |  |j¡ d¡|_t|j
ƒD ]\}}|  |¡}|dkrlt |¡}|j |¡ qZ|S )	Nr   r   Fr   é   r   é,   r!   )rG   r$   r   r	   r#   r   rH   r;   rI   ÚrangerJ   ÚappendÚseekr%   rK   Ú	enumerater8   rL   )r   rD   Ú_ÚiÚsizeÚfieldr   r   r   r   {   s     

zCryptoAPIKeyFile.from_bufferc                 C   s‚   d}|d| j  7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }|d| j 7 }t| jƒD ]}|d|| j| f 7 }q1|S )	Nz== CryptoAPIKeyDescriptor ==
r'   r(   zDescription Length: %s
rF   zField Count: %s
zDescription: %s
zField %d: %s
)r   r	   rH   r;   rI   rK   rO   rL   )r   r*   rT   r   r   r   r+   �   s   zCryptoAPIKeyFile.__str__N)
r-   r.   r/   r   r1   r   r   r   r   r+   r   r   r   r   rG   m   s
    
rG   c                  C   sL   t ddƒ�} |  ¡ }W d   ƒ n1 sw   Y  t |¡}tt|ƒƒ d S )Nz€/home/webdev/Desktop/winhellotest/winhello_test/cryptokeys/5b64a9701545a917d7778d1d19fd2d78_50962b6d-f3c6-40f5-b6ab-81e1beb9be3aÚrb)Úopenr$   rG   r   ÚprintÚstr)Úfr   rD   r   r   r   Úmainš   s
   
ÿ
r\   Ú__main__)	r   Úwinacl.dtyp.wceer   r   r2   r8   rG   r\   r-   r   r   r   r   Ú<module>   s    '/-
ÿ