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    '/-
