o
    àý°jð  ã                   @  sæ   d dl mZ d dlZd dlmZ d dlmZ d dlmZ	 d dl
mZ d dlmZ d dlmZmZmZmZmZ d d	lmZ g d
¢Zejejejejejejf Ze	jZG dd„ dƒZe	j Z e	j!Z!ejej"ef Z#ddd„Z$d dd„Z%dS )!é    )ÚannotationsN)ÚIterable)Úx509)Úpkcs12)Úserialization)ÚPBES)ÚdsaÚecÚed448Úed25519Úrsa)ÚPrivateKeyTypes)r   ÚPKCS12CertificateÚPKCS12KeyAndCertificatesÚPKCS12PrivateKeyTypesÚload_key_and_certificatesÚload_pkcs12Úserialize_java_truststoreÚserialize_key_and_certificatesc                   @  s^   e Zd Zddd„Zedd
d„ƒZeddd„ƒZeddd„ƒZd dd„Zd!dd„Z	d"dd„Z
dS )#r   ÚkeyúPrivateKeyTypes | NoneÚcertúPKCS12Certificate | NoneÚadditional_certsúlist[PKCS12Certificate]c                 C  sx   |d urt |tjtjtjtjt	j
fƒstdƒ‚|d ur$t |tƒs$tdƒ‚tdd„ |D ƒƒs1tdƒ‚|| _|| _|| _d S )NúLKey must be RSA, DSA, EllipticCurve, ED25519, or ED448 private key, or None.z/cert must be a PKCS12Certificate object or Nonec                 s  s   � | ]}t |tƒV  qd S ©N)Ú
isinstancer   )Ú.0Úadd_cert© r    ú¦/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.pyÚ	<genexpr>E   s
   € ÿ
ÿz4PKCS12KeyAndCertificates.__init__.<locals>.<genexpr>z@all values in additional_certs must be PKCS12Certificate objects)r   r   ÚRSAPrivateKeyr   ÚDSAPrivateKeyr	   ÚEllipticCurvePrivateKeyr   ÚEd25519PrivateKeyr
   ÚEd448PrivateKeyÚ	TypeErrorr   ÚallÚ_keyÚ_certÚ_additional_certs)Úselfr   r   r   r    r    r!   Ú__init__/   s.   
ûþ
ÿþÿ
z!PKCS12KeyAndCertificates.__init__Úreturnc                 C  ó   | j S r   )r*   ©r-   r    r    r!   r   Q   ó   zPKCS12KeyAndCertificates.keyc                 C  r0   r   )r+   r1   r    r    r!   r   U   r2   zPKCS12KeyAndCertificates.certc                 C  r0   r   )r,   r1   r    r    r!   r   Y   r2   z)PKCS12KeyAndCertificates.additional_certsÚotherÚobjectÚboolc                 C  s2   t |tƒstS | j|jko| j|jko| j|jkS r   )r   r   ÚNotImplementedr   r   r   )r-   r3   r    r    r!   Ú__eq__]   s   

ÿ
ýzPKCS12KeyAndCertificates.__eq__Úintc                 C  s   t | j| jt| jƒfƒS r   )Úhashr   r   Útupler   r1   r    r    r!   Ú__hash__g   s   z!PKCS12KeyAndCertificates.__hash__Ústrc                 C  s   d}|  | j| j| j¡S )Nz@<PKCS12KeyAndCertificates(key={}, cert={}, additional_certs={})>)Úformatr   r   r   )r-   Úfmtr    r    r!   Ú__repr__j   s   ÿz!PKCS12KeyAndCertificates.__repr__N)r   r   r   r   r   r   )r/   r   )r/   r   )r/   r   )r3   r4   r/   r5   )r/   r8   )r/   r<   )Ú__name__Ú
__module__Ú__qualname__r.   Úpropertyr   r   r   r7   r;   r?   r    r    r    r!   r   .   s    
"


r   ÚcertsúIterable[PKCS12Certificate]Úencryption_algorithmú(serialization.KeySerializationEncryptionr/   Úbytesc                 C  s,   | st dƒ‚t|tjƒstdƒ‚t | |¡S )Nz!You must supply at least one certúFKey encryption algorithm must be a KeySerializationEncryption instance)Ú
ValueErrorr   r   ÚKeySerializationEncryptionr(   Úrust_pkcs12r   )rD   rF   r    r    r!   r   {   s   ÿÿr   Únameúbytes | Noner   úPKCS12PrivateKeyTypes | Noner   úx509.Certificate | NoneÚcasúIterable[_PKCS12CATypes] | Nonec                 C  sp   |d urt |tjtjtjtjt	j
fƒstdƒ‚t |tjƒs!tdƒ‚|d u r/|d u r/|s/tdƒ‚t | ||||¡S )Nr   rI   z1You must supply at least one of key, cert, or cas)r   r   r#   r   r$   r	   r%   r   r&   r
   r'   r(   r   rK   rJ   rL   r   )rM   r   r   rQ   rF   r    r    r!   r   �   s.   
ûþ
ÿÿÿ
ÿr   )rD   rE   rF   rG   r/   rH   )rM   rN   r   rO   r   rP   rQ   rR   rF   rG   r/   rH   )&Ú
__future__r   ÚtypingÚcollections.abcr   Úcryptographyr   Ú"cryptography.hazmat.bindings._rustr   rL   Úcryptography.hazmat.primitivesr   Ú-cryptography.hazmat.primitives._serializationr   Ú)cryptography.hazmat.primitives.asymmetricr   r	   r
   r   r   Ú/cryptography.hazmat.primitives.asymmetric.typesr   Ú__all__ÚUnionr#   r$   r%   r&   r'   r   r   r   r   r   ÚCertificateÚ_PKCS12CATypesr   r   r    r    r    r!   Ú<module>   s:   üÿ	Cÿÿ
