
    Wwg                       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j0                  ej2                  ej4                  f   Zej8                  Z G d
 d      Zej<                  Zej>                  Zej*                  ej@                  ef   Z!	 	 	 	 	 	 	 	 	 	 	 	 ddZ"y)    )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                  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     j/var/www/horilla/myenv/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py	<genexpr>z4PKCS12KeyAndCertificates.__init__.<locals>.<genexpr>C   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.keyO   s    yyr-   c                    | j                   S r   )r&   r/   s    r   r*   zPKCS12KeyAndCertificates.certS   s    zzr-   c                    | j                   S r   )r'   r/   s    r   r+   z)PKCS12KeyAndCertificates.additional_certsW   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+   r/   s    r   __hash__z!PKCS12KeyAndCertificates.__hash__e   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__h   s-    N 	 zz$((DIIt/D/DEEr-   N)r)   PrivateKeyTypes | Noner*   PKCS12Certificate | Noner+   list[PKCS12Certificate])returnr>   )rA   r?   )rA   r@   )r4   objectrA   bool)rA   int)rA   str)__name__
__module____qualname__r,   propertyr)   r*   r+   r5   r9   r=    r-   r   r   r   ,   sq     2# 2 ' 2 2	 2D     & &
IFr-   r   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   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   )namer)   r*   casencryption_algorithms        r   r   r   y   s     z&&%%!!	
	  %
 	

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

 {t|CLMM55c42 r-   )rO   zbytes | Noner)   zPKCS12PrivateKeyTypes | Noner*   zx509.Certificate | NonerP   z&typing.Iterable[_PKCS12CATypes] | NonerQ   z(serialization.KeySerializationEncryptionrA   bytes)#
__future__r   typingcryptographyr   "cryptography.hazmat.bindings._rustr   rN   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>r_      s  
 #   D 8 F  L 		   11 @F @FF (AA %% #
#	%# "# 
0	#
 C# #r-   