
    .Ph                    X   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          Ze	j         Z e	j!        Z!ej        ej"        ef         Z#ddZ$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                  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     s/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py	<genexpr>z4PKCS12KeyAndCertificates.__init__.<locals>.<genexpr>E   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.   r1   s    r$   r   zPKCS12KeyAndCertificates.keyQ   s
    yr&   c                    | j         S r    )r/   r5   s    r$   r   zPKCS12KeyAndCertificates.certU   s
    zr&   c                    | j         S r    )r0   r5   s    r$   r   z)PKCS12KeyAndCertificates.additional_certsY   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   )r1   r8   s     r$   __eq__zPKCS12KeyAndCertificates.__eq__]   sT    %!9:: 	"!! H	! @	UZ'@%)??	
r&   intc                ^    t          | j        | j        t          | j                  f          S r    )hashr   r   tupler   r5   s    r$   __hash__z!PKCS12KeyAndCertificates.__hash__g   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   )r1   fmts     r$   __repr__z!PKCS12KeyAndCertificates.__repr__j   s)    N 	 zz$(DIt/DEEEr&   N)r   r   r   r   r   r   )r3   r   )r3   r   )r3   r   )r8   r9   r3   r:   )r3   r>   )r3   rC   )__name__
__module____qualname__r2   propertyr   r   r   r=   rB   rG    r&   r$   r   r   .   s         2  2  2  2D    X    X & & & X&
 
 
 
I I I IF F F F F Fr&   r   certsIterable[PKCS12Certificate]encryption_algorithm(serialization.KeySerializationEncryptionr3   bytesc                    | 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   )rM   rO   s     r$   r   r   {   sd      ><===mF  
 2
 
 	

 08LMMMr&   namebytes | Noner   PKCS12PrivateKeyTypes | Noner   x509.Certificate | NonecasIterable[_PKCS12CATypes] | Nonec                ^   |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   rS   z1You must supply at least one of key, cert, or cas)r!   r   r'   r	   r(   r
   r)   r   r*   r   r+   r,   r   rU   rT   rV   r   )rW   r   r   r[   rO   s        r$   r   r      s     z&%!	
	  	  %
 
 	

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

 {t|C|LMMM5c42  r&   )rM   rN   rO   rP   r3   rQ   )rW   rX   r   rY   r   rZ   r[   r\   rO   rP   r3   rQ   )&
__future__r   typingcollections.abcr   cryptographyr   "cryptography.hazmat.bindings._rustr   rV   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>rk      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 % N N N N$# # # # # #r&   