
    _fo                    @   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
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 G d	 d
          Z G d d          Z	 d!d"dZ	 d!d#dZej        ej        ef         Zd$d ZdS )%    )annotationsN)x509)serialization)PBES)dsaeced448ed25519rsa)PrivateKeyTypes)r   PKCS12PrivateKeyTypesPKCS12CertificatePKCS12KeyAndCertificatesload_key_and_certificatesload_pkcs12serialize_key_and_certificatesc                  ^    e Zd ZddZedd            Zedd            ZddZddZddZ	dS )r   certx509.Certificatefriendly_nametyping.Optional[bytes]c                    t          |t          j                  st          d          |$t          |t                    st          d          || _        || _        d S )Nz!Expecting x509.Certificate objectz#friendly_name must be bytes or None)
isinstancer   Certificate	TypeErrorbytes_cert_friendly_name)selfr   r   s      e/var/www/html/env/lib/python3.11/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py__init__zPKCS12Certificate.__init__)   sb    
 $ 011 	A?@@@$Zu-M-M$ABBB
+    returnc                    | j         S N)r   r   s    r    r   zPKCS12Certificate.friendly_name5   s    ""r"   c                    | j         S r%   r   r&   s    r    certificatezPKCS12Certificate.certificate9   
    zr"   otherobjectboolc                z    t          |t                    st          S | j        |j        k    o| j        |j        k    S r%   )r   r   NotImplementedr)   r   r   r+   s     r    __eq__zPKCS12Certificate.__eq__=   sC    %!233 	"!!  11 :"e&99	
r"   intc                8    t          | j        | j        f          S r%   )hashr)   r   r&   s    r    __hash__zPKCS12Certificate.__hash__F   s    T%t'9:;;;r"   strc                B    d                     | j        | j                  S )Nz+<PKCS12Certificate({}, friendly_name={!r})>)formatr)   r   r&   s    r    __repr__zPKCS12Certificate.__repr__I   s%    <CCd0
 
 	
r"   N)r   r   r   r   )r#   r   )r#   r   r+   r,   r#   r-   r#   r2   r#   r6   )
__name__
__module____qualname__r!   propertyr   r)   r1   r5   r9    r"   r    r   r   (   s        
, 
, 
, 
, # # # X#    X
 
 
 
< < < <
 
 
 
 
 
r"   r   c                  v    e Zd ZddZedd	            Zedd
            Zedd            ZddZddZ	ddZ
dS )r   key typing.Optional[PrivateKeyTypes]r   "typing.Optional[PKCS12Certificate]additional_certstyping.List[PKCS12Certificate]c                |   |Vt          |t          j        t          j        t
          j        t          j        t          j
        f          st          d          |$t          |t                    st          d          t          d |D                       st          d          || _        || _        || _        d S )NLKey must be RSA, DSA, EllipticCurve, ED25519, or ED448 private key, or None.z/cert must be a PKCS12Certificate object or Nonec              3  @   K   | ]}t          |t                    V  d S r%   )r   r   ).0add_certs     r    	<genexpr>z4PKCS12KeyAndCertificates.__init__.<locals>.<genexpr>f   sA       
 
 x!233
 
 
 
 
 
r"   z@all values in additional_certs must be PKCS12Certificate objects)r   r   RSAPrivateKeyr   DSAPrivateKeyr   EllipticCurvePrivateKeyr
   Ed25519PrivateKeyr	   Ed448PrivateKeyr   r   all_keyr   _additional_certs)r   rC   r   rF   s       r    r!   z!PKCS12KeyAndCertificates.__init__P   s     ?:!!*)%	$
 	$
? )   Jt5F$G$GMNNN 
 
,
 
 
 
 
 	    	
!1r"   r#   c                    | j         S r%   )rT   r&   s    r    rC   zPKCS12KeyAndCertificates.keyr   s
    yr"   c                    | j         S r%   r(   r&   s    r    r   zPKCS12KeyAndCertificates.certv   r*   r"   c                    | j         S r%   )rU   r&   s    r    rF   z)PKCS12KeyAndCertificates.additional_certsz   s    %%r"   r+   r,   r-   c                    t          |t                    st          S | j        |j        k    o| j        |j        k    o| j        |j        k    S r%   )r   r   r/   rC   r   rF   r0   s     r    r1   zPKCS12KeyAndCertificates.__eq__~   sT    %!9:: 	"!! H	! @	UZ'@%)??	
r"   r2   c                ^    t          | j        | j        t          | j                  f          S r%   )r4   rC   r   tuplerF   r&   s    r    r5   z!PKCS12KeyAndCertificates.__hash__   s&    TXty%0E*F*FGHHHr"   r6   c                R    d}|                     | j        | j        | j                  S )Nz@<PKCS12KeyAndCertificates(key={}, cert={}, additional_certs={})>)r8   rC   r   rF   )r   fmts     r    r9   z!PKCS12KeyAndCertificates.__repr__   s)    N 	 zz$(DIt/DEEEr"   N)rC   rD   r   rE   rF   rG   )r#   rD   )r#   rE   )r#   rG   r:   r;   r<   )r=   r>   r?   r!   r@   rC   r   rF   r1   r5   r9   rA   r"   r    r   r   O   s         2  2  2  2D    X    X & & & X&
 
 
 
I I I IF F F F F Fr"   r   datar   passwordr   backend
typing.Anyr#   ptyping.Tuple[typing.Optional[PrivateKeyTypes], typing.Optional[x509.Certificate], typing.List[x509.Certificate]]c                :    ddl m} |                    | |          S Nr   r`   ),cryptography.hazmat.backends.openssl.backendr`   %load_key_and_certificates_from_pkcs12r^   r_   r`   ossls       r    r   r      s-     MLLLLL55dHEEEr"   c                :    ddl m} |                    | |          S rd   )rf   r`   r   rh   s       r    r   r      s-    
 MLLLLLD(+++r"   namerC   &typing.Optional[PKCS12PrivateKeyTypes]r   !typing.Optional[x509.Certificate]cas0typing.Optional[typing.Iterable[_PKCS12CATypes]]encryption_algorithm(serialization.KeySerializationEncryptionc                4   |Vt          |t          j        t          j        t
          j        t          j        t          j
        f          st          d          |)t          |t          j                  st          d          |7t          |          }t          d |D                       st          d          t          |t           j                  st          d          |||st%          d          ddlm} |                    | ||||          S )	NrI   z"cert must be a certificate or Nonec              3  X   K   | ]%}t          |t          j        t          f          V  &d S r%   )r   r   r   r   )rK   vals     r    rM   z1serialize_key_and_certificates.<locals>.<genexpr>   sS       	
 	
  $% 	
 	
 	
 	
 	
 	
r"   z&all values in cas must be certificateszFKey encryption algorithm must be a KeySerializationEncryption instancez1You must supply at least one of key, cert, or casr   re   )r   r   rN   r   rO   r   rP   r
   rQ   r	   rR   r   r   r   listrS   r   KeySerializationEncryption
ValueErrorrf   r`   (serialize_key_and_certificates_to_pkcs12)rk   rC   r   rn   rp   r`   s         r    r   r      sX    z&%!	
	  	  %
 
 	
 
41A B B<===
3ii 	
 	
 	
 	
 	
 	
 	
 
	F DEEEmF  
 2
 
 	

 {t|C|LMMMDDDDDD;;c42  r"   r%   )r^   r   r_   r   r`   ra   r#   rb   )r^   r   r_   r   r`   ra   r#   r   )rk   r   rC   rl   r   rm   rn   ro   rp   rq   r#   r   ) 
__future__r   typingcryptographyr   cryptography.hazmat.primitivesr   -cryptography.hazmat.primitives._serializationr   )cryptography.hazmat.primitives.asymmetricr   r   r	   r
   r   /cryptography.hazmat.primitives.asymmetric.typesr   __all__UnionrN   rO   rP   rQ   rR   r   r   r   r   r   r   _PKCS12CATypesr   rA   r"   r    <module>r      s  
 # " " " " "        8 8 8 8 8 8 F F F F F F              L K K K K K   		 $
 $
 $
 $
 $
 $
 $
 $
N@F @F @F @F @F @F @F @FL F F F F F" , , , , , 5 5 5 5 5 5r"   