
    ;3h                       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j0                  ej2                  ej4                  ej6                  ej8                  f   Ze	j<                  Z G d d      Ze	j@                  Z e	jB                  Z!ej.                  ejD                  ef   Z#	 	 	 	 	 	 ddZ$	 	 	 	 	 	 	 	 	 	 	 	 ddZ%y)    )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                  n    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
y)r   c                j   |bt        |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      || _        || _        || _        y )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                y wN)
isinstancer   ).0add_certs     s/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py	<genexpr>z4PKCS12KeyAndCertificates.__init__.<locals>.<genexpr>E   s       
 x!23
s   z@all values in additional_certs must be PKCS12Certificate objects)r   r   RSAPrivateKeyr	   DSAPrivateKeyr
   EllipticCurvePrivateKeyr   Ed25519PrivateKeyr   Ed448PrivateKey	TypeErrorr   all_key_cert_additional_certs)selfkeycertadditional_certss       r   __init__z!PKCS12KeyAndCertificates.__init__/   s     ?:!!!!**))%%	$
 )  Jt5F$GMNN 
,
 
   	
!1    c                    | j                   S r   )r'   r*   s    r   r+   zPKCS12KeyAndCertificates.keyQ   s    yyr/   c                    | j                   S r   )r(   r1   s    r   r,   zPKCS12KeyAndCertificates.certU   s    zzr/   c                    | j                   S r   )r)   r1   s    r   r-   z)PKCS12KeyAndCertificates.additional_certsY   s    %%%r/   c                    t        |t              st        S | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j
                  |j
                  k(  S r   )r   r   NotImplementedr+   r,   r-   )r*   others     r   __eq__zPKCS12KeyAndCertificates.__eq__]   sZ    %!9:!! HH		! @		UZZ'@%%)?)??	
r/   c                l    t        | j                  | j                  t        | j                        f      S r   )hashr+   r,   tupler-   r1   s    r   __hash__z!PKCS12KeyAndCertificates.__hash__g   s'    TXXtyy%0E0E*FGHHr/   c                h    d}|j                  | j                  | j                  | j                        S )Nz@<PKCS12KeyAndCertificates(key={}, cert={}, additional_certs={})>)formatr+   r,   r-   )r*   fmts     r   __repr__z!PKCS12KeyAndCertificates.__repr__j   s-    N 	 zz$((DIIt/D/DEEr/   N)r+   PrivateKeyTypes | Noner,   PKCS12Certificate | Noner-   list[PKCS12Certificate])returnr@   )rC   rA   )rC   rB   )r6   objectrC   bool)rC   int)rC   str)__name__
__module____qualname__r.   propertyr+   r,   r-   r7   r;   r?    r/   r   r   r   .   sq     2# 2 ' 2 2	 2D     & &
IFr/   r   c                    | st        d      t        |t        j                        st	        d      t        j                  | |      S )Nz!You must supply at least one certFKey encryption algorithm must be a KeySerializationEncryption instance)
ValueErrorr   r   KeySerializationEncryptionr%   rust_pkcs12r   )certsencryption_algorithms     r   r   r   {   sP     <==mFF 2
 	

 008LMMr/   c                h   |bt        |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   rN   z1You must supply at least one of key, cert, or cas)r   r   r    r	   r!   r
   r"   r   r#   r   r$   r%   r   rP   rO   rQ   r   )namer+   r,   casrS   s        r   r   r      s     z&&%%!!	
	  %
 	

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

 {t|CLMM55c42 r/   )rR   zIterable[PKCS12Certificate]rS   (serialization.KeySerializationEncryptionrC   bytes)rU   zbytes | Noner+   zPKCS12PrivateKeyTypes | Noner,   zx509.Certificate | NonerV   zIterable[_PKCS12CATypes] | NonerS   rW   rC   rX   )&
__future__r   typingcollections.abcr   cryptographyr   "cryptography.hazmat.bindings._rustr   rQ   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   rL   r/   r   <module>rf      s.  
 #  $  D 8 F  L	 		   11 @F @FF (AA %% N&NBN N$#
#	%# "# 
)	#
 C# #r/   