
    tf                    D   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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          Zej        Zej        Zej        ej         ef         Z!ddZ"dS )    )annotationsN)x509)pkcs12)serialization)PBES)dsaeced448ed25519rsa)PrivateKeyTypes)r   PKCS12CertificatePKCS12KeyAndCertificatesPKCS12PrivateKeyTypesload_key_and_certificatesload_pkcs12serialize_key_and_certificatesc                  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PrivateKeyTypes | NonecertPKCS12Certificate | Noneadditional_certs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 N)
isinstancer   ).0add_certs     r/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py	<genexpr>z4PKCS12KeyAndCertificates.__init__.<locals>.<genexpr>C   sA       
 
 x!233
 
 
 
 
 
    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   s       r"   __init__z!PKCS12KeyAndCertificates.__init__-   s     ?:!!*)%	$
 	$
? )   Jt5F$G$GMNNN 
 
,
 
 
 
 
 	    	
!1r$   returnc                    | j         S r   )r,   r/   s    r"   r   zPKCS12KeyAndCertificates.keyO   s
    yr$   c                    | j         S r   )r-   r3   s    r"   r   zPKCS12KeyAndCertificates.certS   s
    zr$   c                    | j         S r   )r.   r3   s    r"   r   z)PKCS12KeyAndCertificates.additional_certsW   s    %%r$   otherobjectboolc                    t          |t                    st          S | j        |j        k    o| j        |j        k    o| j        |j        k    S r   )r   r   NotImplementedr   r   r   )r/   r6   s     r"   __eq__zPKCS12KeyAndCertificates.__eq__[   sT    %!9:: 	"!! H	! @	UZ'@%)??	
r$   intc                ^    t          | j        | j        t          | j                  f          S r   )hashr   r   tupler   r3   s    r"   __hash__z!PKCS12KeyAndCertificates.__hash__e   s&    TXty%0E*F*FGHHHr$   strc                R    d}|                     | j        | j        | j                  S )Nz@<PKCS12KeyAndCertificates(key={}, cert={}, additional_certs={})>)formatr   r   r   )r/   fmts     r"   __repr__z!PKCS12KeyAndCertificates.__repr__h   s)    N 	 zz$(DIt/DEEEr$   N)r   r   r   r   r   r   )r1   r   )r1   r   )r1   r   )r6   r7   r1   r8   )r1   r<   )r1   rA   )__name__
__module____qualname__r0   propertyr   r   r   r;   r@   rE    r$   r"   r   r   ,   s         2  2  2  2D    X    X & & & X&
 
 
 
I I I IF F F F F Fr$   r   namebytes | Noner   PKCS12PrivateKeyTypes | Noner   x509.Certificate | Nonecas&typing.Iterable[_PKCS12CATypes] | Noneencryption_algorithm(serialization.KeySerializationEncryptionr1   bytesc                ^   |Vt          |t          j        t          j        t
          j        t          j        t          j
        f          st          d          t          |t          j                  st          d          |||st          d          t          j        | ||||          S )Nr   zFKey encryption algorithm must be a KeySerializationEncryption instancez1You must supply at least one of key, cert, or cas)r   r   r%   r   r&   r	   r'   r   r(   r
   r)   r*   r   KeySerializationEncryption
ValueErrorrust_pkcs12r   )rK   r   r   rO   rQ   s        r"   r   r   y   s     z&%!	
	  	  %
 
 	

 mF  
 2
 
 	

 {t|C|LMMM5c42  r$   )rK   rL   r   rM   r   rN   rO   rP   rQ   rR   r1   rS   )#
__future__r   typingcryptographyr   "cryptography.hazmat.bindings._rustr   rW   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   rJ   r$   r"   <module>rd      s  
 # " " " " "        D D D D D D 8 8 8 8 8 8 F F F F F F              L K K K K K   		   1 @F @F @F @F @F @F @F @FF (A % # # # # # #r$   