
    Bwg                     ,   d dl mZmZmZmZ d dlmZ d dlZd dlZd dl	Z	ddl
mZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d	d
l*m+Z+m,Z,m-Z-m.Z. d	dl/m0Z0m1Z1m2Z2 d	dl3m4Z4 ddl5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z< ddl=m>Z>m?Z?m@Z@mAZA g dZB G d de      ZC G d de      ZD G d de      Zd0dZEd ZFd ZGd ZHd1dZId ZJd ZKd1dZLd1dZMd  ZNd! ZOd" ZPd# ZQd$ ZRd% ZSd& ZTd' ZUd( ZVd) ZWd* ZXd+ ZYd, ZZd- Z[d. Z\d/ Z]y)2    )unicode_literalsdivisionabsolute_importprint_function)	b32encodeN   )	CertificateECDomainParametersIntegerKeyExchangeAlgorithmNullPrivateKeyInfoPublicKeyAlgorithmPublicKeyInfoRSAPublicKey)	_CertificateBase_fingerprint_parse_pkcs12_PrivateKeyBase_PublicKeyBase_unwrap_private_key_infoparse_certificateparse_privateparse_public)pretty_message)newunwrapbytes_from_bufferbuffer_from_bytesderefnullis_nullpointer_set   )SecuritySecurityConsthandle_sec_errorosx_version_info)CoreFoundation	CFHelpershandle_cf_error)
rand_bytes)AsymmetricKeyErrorIncompleteAsymmetricKeyErrorSignatureError)add_pss_paddingverify_pss_padding"remove_pkcs1v15_encryption_padding)	type_namestr_clsbyte_cls	int_types)r	   dsa_sign
dsa_verify
ecdsa_signecdsa_verifygenerate_pairload_certificateload_pkcs12load_private_keyload_public_keyparse_pkcs12
PrivateKey	PublicKeyrsa_oaep_decryptrsa_oaep_encryptrsa_pkcs1v15_decryptrsa_pkcs1v15_encryptrsa_pkcs1v15_signrsa_pkcs1v15_verifyrsa_pss_signrsa_pss_verifyc                   H    e Zd ZdZdZdZdZd Zed        Z	ed        Z
d Zy)rA   zM
    Container for the OS crypto library representation of a private key
    Nc                 6    || _         || _        t        | _        y)z
        :param sec_key_ref:
            A Security framework SecKeyRef value from loading/importing the
            key

        :param asn1:
            An asn1crypto.keys.PrivateKeyInfo object
        Nsec_key_refasn1r)   _libselfrN   rO   s      O/var/www/horilla/myenv/lib/python3.12/site-packages/oscrypto/_mac/asymmetric.py__init__zPrivateKey.__init__M        '	"	    c                    | j                   d}	 t        t        d      }t        j                  | j
                  ddt               |      }t        |       t        |      }t        j                  |      }t        |      }|j                  dk(  rOt        t        dt               d      t!        |d   j"                  d   |d   j"                  d   d	      d
      }n|j                  dk(  rv|d   d   }t        t        d|j%                         d      t'        t)        |d   j*                  |d   j"                  j*                  |d   j*                              d
      }nN|j                  dk(  r?t        t        dt-        d| j.                        d      |d   j"                  d   d
      }|rt        j0                  |       	 t3              | _         | j                   S # |rt        j0                  |       w w xY w)z\
        :return:
            A PublicKey object corresponding to this private key.
        NCFDataRef *r   rsa)	algorithm
parametersprivate_keymoduluspublic_exponent)r]   r^   )rZ   
public_keydsaprivate_key_algorithmr[   gpecnamed)namevaluer_   )_public_keyr   r)   r%   SecItemExportrN   r!   r'   r   r*   cf_data_to_bytesr   rZ   r   r   r   r   parsedcopyr   pownativer
   curve	CFRelease	_load_key)rR   cf_data_privatecf_data_private_pointerresultprivate_key_byteskeypublic_asn1paramss           rS   r_   zPrivateKey.public_key[   s    #"O3> +.nm*L'!//0@0@!QPgh ("()@"A$-$>$>$O!#$56==E)"/%7).*.&9 & '3'*='9'@'@'K/2=/A/H/HIZ/[4 '	1 	#K ]]e+ !89,GF"/%7).*0++-9 & '.c"3K...55<<"3K../ '
1 
#K ]]d*"/%7)-*<%,&*jj+9 & '*-&8&?&?&M	1 	#K #",,_=(5D #",,_= #s   F"G' 'Hc                 p    | j                   t        | j                  t              | _         | j                   S )aY  
        Creates a fingerprint that can be compared with a public key to see if
        the two form a pair.

        This fingerprint is not compatible with fingerprints generated by any
        other software.

        :return:
            A byte string that is a sha256 hash of selected components (based
            on the key type)
        )r   rO   r>   rR   s    rS   fingerprintzPrivateKey.fingerprint   s0     $ ,TYY8H ID   rV   c                     | j                   r4| j                  j                  | j                          d | _        d | _         y y NrN   rP   rp   rz   s    rS   __del__zPrivateKey.__del__   7    II 0 01DI#D rV   )__name__
__module____qualname____doc__rN   rh   rP   rT   propertyr_   r{   r    rV   rS   rA   rA   A   sM     KK D# ?  ? B ! !"$rV   rA   c                   $    e Zd ZdZdZdZd Zd Zy)rB   zL
    Container for the OS crypto library representation of a public key
    Nc                 6    || _         || _        t        | _        y)z
        :param sec_key_ref:
            A Security framework SecKeyRef value from loading/importing the
            key

        :param asn1:
            An asn1crypto.keys.PublicKeyInfo object
        NrM   rQ   s      rS   rT   zPublicKey.__init__   rU   rV   c                     | j                   r4| j                  j                  | j                          d | _        d | _         y y r}   r~   rz   s    rS   r   zPublicKey.__del__   r   rV   )r   r   r   r   rN   rP   rT   r   r   rV   rS   rB   rB      s     K D#$rV   rB   c                   X    e Zd ZdZdZdZdZd Zed        Z	ed        Z
ed        Zd Zy)r	   zM
    Container for the OS crypto library representation of a certificate
    Nc                      || _         || _        y)z
        :param sec_certificate_ref:
            A Security framework SecCertificateRef value from loading/importing
            the certificate

        :param asn1:
            An asn1crypto.x509.Certificate object
        N)sec_certificate_refrO   )rR   r   rO   s      rS   rT   zCertificate.__init__   s     $7 	rV   c                 .    | j                   j                  S )zF
        :return:
            The SecKeyRef of the public key
        )r_   rN   rz   s    rS   rN   zCertificate.sec_key_ref   s     ***rV   c                    | j                   s| j                  r| j                  j                  dk(  r@| j                  j	                         }d|d   d   d   d<   t        |      }|j                  }n| j                  }t        t        d      }t        j                  ||      }t        |       t        |      }t        || j                  d   d         | _         | j                   S )zh
        :return:
            The PublicKey object for the public key this certificate contains
        
rsassa_pssrY   tbs_certificatesubject_public_key_inforZ   SecKeyRef *)rh   r   rO   signature_algorl   
_load_x509r   r%   SecCertificateCopyPublicKeyr'   r   rB   )rR   rO   	temp_certsec_cert_refsec_public_key_ref_pointerressec_public_key_refs          rS   r_   zCertificate.public_key   s     D$<$<yy''<7 yy~~'_d&'(AB;OP[\&t,	(<<#77),X})E&66|E_`CS!!'(B!C();TYYGX=YZs=tuDrV   c                 ^   | j                   d| _         | j                  j                  t        ddg      v r| j                  d   j                  }| j                  d   j
                  }|dk(  rt        }n9|dk(  rt        }n-|dk(  rt        }n!|dk(  rt        }nt        t        d	|            	  || j                  | j                  d
   j                  | j                  d   j                         |       d| _         | j                   S | j                   S # t        $ r Y | j                   S w xY w)zT
        :return:
            A boolean - if the certificate is self-signed
        Fyesmaybesignature_algorithmrsassa_pkcs1v15r   r`   ecdsaz
                        Unable to verify the signature of the certificate since
                        it uses the unsupported algorithm %s
                        signature_valuer   T)_self_signedrO   self_signedsetr   	hash_algorH   rJ   r8   r:   OSErrorr   r_   rn   dumpr/   )rR   r   r   verify_funcs       rS   r   zCertificate.self_signed  s4    $ %Dyy$$UG,<(==!%+@!A!P!P II&;<FF	!%66"5K#|3"0K#u,",K#w.".K!. '#  			"34;;		"3499;!	 )-D%    t    '    s   /AD 	D,+D,c                     | j                   r!| j                   j                          d | _         | j                  r't        j                  | j                         d | _        y y r}   )rh   r   r   r)   rp   rz   s    rS   r   zCertificate.__del__;  sO    $$&#D##$$T%=%=>'+D$ $rV   )r   r   r   r   r   rh   r   rT   r   rN   r_   r   r   r   rV   rS   r	   r	      s`     KL + +    2 )! )!V,rV   r	   c                    | t        g d      vrt        t        dt        |                   | dk(  r-|t        g d      vrt        t        dt        |                  | dk(  r,|t        dg      vrPt        t        dt        |                  | d	k(  r-|t        g d
      vrt        t        dt        |                  d}d}d}d}d}d}d}	d}
d}	 t        j
                  t        j                  t        j                  d|    }| d	k(  r
dddd
|   }n|}t        t        d      }t        t        d      }t        j                  d      }d}t        d|z         }|dd }t        |dd       j                  d      }t        j                          }t"        j$                  j'                  ||      j)                  d      }t        t        d      }t        j*                  |||dt-               |      }t/        |       t1        |      }
t        t        d      }t        j2                  |t-               |      }t/        |       t1        |      }	t        j4                  |
||dt        j6                  t        j8                  t        j:                  z  t        j<                  t        j8                  t        j:                  z  |	||      }t/        |       t1        |      }t1        |      }t        t>        d      }t        j@                  |ddt-               |      }t/        |       t1        |      }t        jB                  |      }t        t>        d      }t        j@                  |ddt-               |      }t/        |       t1        |      }t        jB                  |      }t        jD                  |      }t/        |       t        jD                  |      }t/        |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |
r*t        jH                  |
       t?        jF                  |
       |rtK        jL                  |       |	rt?        jF                  |	       	 tO        |      tQ        |      fS # |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |rt?        jF                  |       |
r*t        jH                  |
       t?        jF                  |
       |rtK        jL                  |       |	rt?        jF                  |	       w w xY w)a  
    Generates a public/private key pair

    :param algorithm:
        The key algorithm - "rsa", "dsa" or "ec"

    :param bit_size:
        An integer - used for "rsa" and "dsa". For "rsa" the value maye be 1024,
        2048, 3072 or 4096. For "dsa" the value may be 1024.

    :param curve:
        A unicode string - used for "ec" keys. Valid values include "secp256r1",
        "secp384r1" and "secp521r1".

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A 2-element tuple of (PublicKey, PrivateKey). The contents of each key
        may be saved by calling .asn1.dump().
    )rY   r`   rd   zM
            algorithm must be one of "rsa", "dsa", "ec", not %s
            rY   )   i   i      zX
                bit_size must be one of 1024, 2048, 3072, 4096, not %s
                r`   r   z?
                bit_size must be 1024, not %s
                rd   	secp256r1	secp384r1	secp521r1zd
                curve must be one of "secp256r1", "secp384r1", "secp521r1", not %s
                N)r`   rd   rY        i	  r   Temporary oscrypto key   
   utf-8SecKeychainRef *FSecAccessRef *r   rX   ))r   
ValueErrorr   reprr&   CSSM_ALGID_DSACSSM_ALGID_ECDSACSSM_ALGID_RSAr   r%   r*   cf_string_from_unicoder,   r   decodetempfilemkdtempospathjoinencodeSecKeychainCreater!   r'   r   SecAccessCreateSecKeyCreatePairCSSM_KEYUSE_VERIFYCSSM_KEYATTR_EXTRACTABLECSSM_KEYATTR_PERMANENTCSSM_KEYUSE_SIGNr)   ri   rj   SecKeychainItemDeleterp   SecKeychainDeleteshutilrmtreer?   r>   )rZ   bit_sizero   cf_dictpublic_key_refprivate_key_refcf_data_publicrr   	cf_stringsec_access_refsec_keychain_reftemp_diralg_idkey_sizeprivate_key_pointerpublic_key_pointerpassphrase_len	rand_data
passphrasetemp_filename	temp_pathsec_keychain_ref_pointerrt   sec_access_ref_pointercf_data_public_pointerpublic_key_bytesrs   ru   s                               rS   r;   r;   E  s=   2 011 O	
  	 E3788^ X	   
e	3v;&^ X	   
d	CDD^ U	   GNONOINHi5 //00 //
 	     	H  H!(M: =9445MN	 rN23	rs^
!)CR.188A##%GGLL=9@@I	#&x1C#D ++F$
 	 !":;!$X/?!@)))TV=ST  67**,,22]5Y5YY**22]5Y5YY
 	  23 !45!$^]!C''1dfF\]  67$55nE"%nm"D''AtvG^_  !89%66G //? //@  $$W-$$^4$$_5$$^4$$_5$$Y/&&'78$$%56MM(#$$^4,-/?@Q/RSS) $$W-$$^4$$_5$$^4$$_5$$Y/&&'78$$%56MM(#$$^4 s   LS C'Wc                 	   t        | t              st        t        dt	        |                   | dk  rt        d      | dkD  rt        d      | dz  dk7  rt        d      d	}d	}d	}d	}d	}d	}d	}d	}	 t        t        d
      }	t        t        d
      }
t        j                  d      }d}t        d|z         }|dd	 }t        |d	d       j                  d      }t        j                         }t        j                   j#                  ||      j%                  d      }t        t        d      }t        j&                  |||dt)               |      }t+        |       t-        |      }t        t        d      }t        j.                  |t)               |      }t+        |       t-        |      }t        j0                  |t2        j4                  | ddt2        j6                  t2        j8                  z  dt2        j6                  t2        j8                  z  ||	|
      }t+        |       t-        |	      }t-        |
      }t        t:        d      }t        j<                  |ddt)               |      }t+        |       t-        |      }t        j>                  |      }t        j@                  |      }t+        |       t        j@                  |      }t+        |       tC        jD                  |      d   |rt;        jF                  |       |rt;        jF                  |       |rt;        jF                  |       |rt;        jF                  |       |rt;        jF                  |       |r*t        jH                  |       t;        jF                  |       |rtK        jL                  |       |rt;        jF                  |       S S # |rt;        jF                  |       |rt;        jF                  |       |rt;        jF                  |       |rt;        jF                  |       |rt;        jF                  |       |r*t        jH                  |       t;        jF                  |       |rtK        jL                  |       |rt;        jF                  |       w w xY w)a`  
    Generates DH parameters for use with Diffie-Hellman key exchange. Returns
    a structure in the format of DHParameter defined in PKCS#3, which is also
    used by the OpenSSL dhparam tool.

    THIS CAN BE VERY TIME CONSUMING!

    :param bit_size:
        The integer bit size of the parameters to generate. Must be between 512
        and 4096, and divisible by 64. Recommended secure value as of early 2016
        is 2048, with an absolute minimum of 1024.

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        An asn1crypto.algos.DHParameters object. Use
        oscrypto.asymmetric.dump_dh_parameters() to save to disk for usage with
        web servers.
    z=
            bit_size must be an integer, not %s
               z-bit_size must be greater than or equal to 512r   z+bit_size must be less than or equal to 4096@   r   z!bit_size must be a multiple of 64Nr   r   r   r   r   r   Fr   rX   r[   )'
isinstancer6   	TypeErrorr   r3   r   r   r%   r*   r   r,   r   r   r   r   r   r   r   r   r   r!   r'   r   r   r   r&   CSSM_ALGID_DHr   r   r)   ri   rj   r   r   loadrp   r   r   r   )r   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   r   rt   r   rs   ru   s                        rS   generate_dh_parametersr     s   0 h	* h	
  	 #~HII$FGG"}<==NONOINHQ5 =9!(M:445MN	rN23	rs^
!)CR.188A##%GGLL=9@@I	#&x1C#D ++F$
 	 !":;!$X/?!@)))TV=ST  67**''22]5Y5YY22]5Y5YY
 	  23 !45"%nm"D''AtvG^_  !89%66G //? //@ #(():;LI $$^4$$_5$$^4$$_5$$Y/&&'78$$%56MM(#$$^4  $$^4$$_5$$^4$$_5$$Y/&&'78$$%56MM(#$$^4 s   3I6N8 8CRc                    t        | t              r| }t        |      S t        | t              rt        |       }t        |      S t        | t              r9t        | d      5 }t        |j                               }ddd       t        |      S t        t        dt        |                   # 1 sw Y   t              S xY w)a  
    Loads an x509 certificate into a Certificate object

    :param source:
        A byte string of file contents, a unicode string filename or an
        asn1crypto.x509.Certificate object

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A Certificate object
    rbNz
            source must be a byte string, unicode string or
            asn1crypto.x509.Certificate object, not %s
            )r   Asn1Certificater5   r   r4   openreadr   r   r3   r   )sourcecertificatefs      rS   r<   r<     s    " &/*$ k""! 
FH	%'/ k"" 
FG	$&$ 	61+AFFH5K	6 k""  f
  			6 k""    B++B>c                    | j                         }d}	 t        j                  |      }t        j                  t
        j                  |      }t        ||       |rt        j                  |       S S # |rt        j                  |       w w xY w)z
    Loads an ASN.1 object of an x509 certificate into a Certificate object

    :param certificate:
        An asn1crypto.x509.Certificate object

    :return:
        A Certificate object
    N)	r   r*   cf_data_from_bytesr%   SecCertificateCreateWithDatar)   kCFAllocatorDefaultr	   rp   )r   r   	cf_sourcerN   s       rS   r   r     s~     FI0008	;;N<^<^`ij;4 $$Y/ 9$$Y/ s   AA1 1Bc                    t        | t              r| }t        |      S |Ot        |t              r|j                  d      }t        |t              st        t        dt        |                  t        | t              r&t        | d      5 }|j                         } ddd       n.t        | t              st        t        dt        |                   t        | |      }t        |      S # 1 sw Y    xY w)a   
    Loads a private key into a PrivateKey object

    :param source:
        A byte string of file contents, a unicode string filename or an
        asn1crypto.keys.PrivateKeyInfo object

    :param password:
        A byte or unicode string to decrypt the private key file. Unicode
        strings will be encoded using UTF-8. Not used is the source is a
        PrivateKeyInfo object.

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        oscrypto.errors.AsymmetricKeyError - when the private key is incompatible with the OS crypto library
        OSError - when an error is returned by the OS crypto library

    :return:
        A PrivateKey object
    Nr   zP
                    password must be a byte string, not %s
                    r   z
                source must be a byte string, unicode string or
                asn1crypto.keys.PrivateKeyInfo object, not %s
                )r   r   r4   r   r5   r   r   r3   r   r   r   rq   )r   passwordprivate_objectr   s       rS   r>   r>     s    . &.): ^$$5 (G,#??73h1 h'	!   fg&fd# "q" " FH-N &!   'vx8^$$" "s   C**C3c                    t        | t              r| }t        |      S t        | t              rt        |       }t        |      S t        | t              r9t        | d      5 }t        |j                               }ddd       t        |      S t        t        dt        |                   # 1 sw Y   t              S xY w)a3  
    Loads a public key into a PublicKey object

    :param source:
        A byte string of file contents, a unicode string filename or an
        asn1crypto.keys.PublicKeyInfo object

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        oscrypto.errors.AsymmetricKeyError - when the public key is incompatible with the OS crypto library
        OSError - when an error is returned by the OS crypto library

    :return:
        A PublicKey object
    r   Nz
            source must be a byte string, unicode string or
            asn1crypto.keys.PublicKeyInfo object, not %s
            )r   r   r5   r   r4   r   r   r   r   r3   rq   )r   r_   r   s      rS   r?   r?     s    $ &-(
$ Z  ! 
FH	%!&)
 Z   
FG	$&$ 	01%affh/J	0 Z    f
  			0 Z  r   c           
         | j                   dk(  rB| j                  \  }}|dk7  rt        d      |t        g d      vrt        t	        d            | j                   dk(  r.| j
                  dk(  rt        t	        d| j                              | j                   dk(  r | j
                  t        t	        d
            t        | t              rY| j                   dk(  r)| j                         }d|d   d<   |j                         }n| j                         }t        j                  }n)t        |       j                         }t        j                  }d	}d	}d	}	 t!        j"                  |      }t%        t&        d      }	t)        |	t        j*                         t%        t&        d      }
t)        |
|       t%        t,        d      }t!        j.                  t&        j0                  g      }t%        t&        d      }t3        |      }d|_        d|_        t9               |_        t9               |_        t9               |_        t9               |_         t9               |_!        ||_"        t'        jF                  |t9               |	|
d|t9               |      }tI        |       t3        |      }t-        jJ                  |      }|dkD  r+t-        jL                  |d      }t-        jN                  |       |t        j                  k(  rRtQ        |       |rt-        jR                  |       |rt-        jR                  |       |rt-        jR                  |       S S |t        j                  k(  rRtU        |       |rt-        jR                  |       |rt-        jR                  |       |rt-        jR                  |       S S 	 |rt-        jR                  |       |rt-        jR                  |       |rt-        jR                  |       y	y	# |rt-        jR                  |       |rt-        jR                  |       |rt-        jR                  |       w w xY w)aN  
    Common code to load public and private keys into PublicKey and PrivateKey
    objects

    :param key_object:
        An asn1crypto.keys.PublicKeyInfo or asn1crypto.keys.PrivateKeyInfo
        object

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        oscrypto.errors.AsymmetricKeyError - when the key is incompatible with the OS crypto library
        OSError - when an error is returned by the OS crypto library

    :return:
        A PublicKey or PrivateKey object
    rd   re   z-OS X only supports EC keys using named curvesr   z
                OS X only supports EC keys using the named curves secp256r1,
                secp384r1 and secp521r1
                r`   sha2z
            OS X only supports DSA keys based on SHA1 (2048 bits or less) - this
            key is based on SHA2 and is %s bits
            Nzz
            The DSA key does not contain the necessary p, q and g parameters
            and can not be used
            r   rY   rZ   z
uint32_t *zCFArrayRef *z"SecItemImportExportKeyParameters *r   )+rZ   ro   r-   r   r   r   r   r.   r   r   rl   r   r&   kSecItemTypePublicKeyr   kSecItemTypePrivateKeyr*   r   r   r%   r#   kSecFormatOpenSSLr)   cf_array_from_listkSecAttrIsExtractabler   versionflagsr!   r   
alertTitlealertPrompt	accessRefkeyUsagekeyAttributesSecItemImportr'   CFArrayGetCountCFArrayGetValueAtIndexCFRetainrB   rp   rA   )
key_object
curve_typedetailstemp_key_objectr   	item_typer   
keys_array
attr_arrayformat_pointertype_pointerkeys_pointerimport_export_params_pointerimport_export_paramsr   lengthrN   s                    rS   rq   rq     s   & t#(..
G $%TUU#EFF$^&   
			&:+?+?6+I  "
  	 
			&:+?+?+G*>,
  	 *m,</ )oo/O8=OK(5$))+F__&F!77	 **5::<!88	IJJ60008	X|4NM$C$CD8\2L),>>:11**3
 
 (+85Y'Z$%&BC'($%&"*.&'*.&'+/6()-&(,%-7*$$F(F	
 	L)
//
;A:(??
ANK##K0;;;[*5 $$Z0$$Z0$$Y/  <<<k:6 $$Z0$$Z0$$Y/  = $$Z0$$Z0$$Y/ 	 $$Z0$$Z0$$Y/ s   F/O: O: :AQc                 $    t        | |t              S )a  
    Parses a PKCS#12 ANS.1 DER-encoded structure and extracts certs and keys

    :param data:
        A byte string of a DER-encoded PKCS#12 file

    :param password:
        A byte string of the password to any encrypted data

    :raises:
        ValueError - when any of the parameters are of the wrong type or value
        OSError - when an error is returned by one of the OS decryption functions

    :return:
        A three-element tuple of:
         1. An asn1crypto.keys.PrivateKeyInfo object
         2. An asn1crypto.x509.Certificate object
         3. A list of zero or more asn1crypto.x509.Certificate objects that are
            "extra" certificates, possibly intermediates from the cert chain
    )r   r>   )datar   s     rS   r@   r@     s    , x)9::rV   c                 $   |Ot        |t              r|j                  d      }t        |t              st	        t        dt        |                  t        | t              r&t        | d      5 }|j                         } ddd       n.t        | t              st	        t        dt        |                   t        | |      \  }}}d}d}|rt        |      }|rt        |      }|D cg c]  }t        |       }	}|||	fS # 1 sw Y   TxY wc c}w )a  
    Loads a .p12 or .pfx file into a PrivateKey object and one or more
    Certificates objects

    :param source:
        A byte string of file contents or a unicode string filename

    :param password:
        A byte or unicode string to decrypt the PKCS12 file. Unicode strings
        will be encoded using UTF-8.

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        oscrypto.errors.AsymmetricKeyError - when a contained key is incompatible with the OS crypto library
        OSError - when an error is returned by the OS crypto library

    :return:
        A three-element tuple containing (PrivateKey, Certificate, [Certificate, ...])
    Nr   zH
                password must be a byte string, not %s
                r   zR
            source must be a byte string or a unicode string, not %s
            )r   r4   r   r5   r   r   r3   r   r   r@   rq   r   )
r   r   r   key_info	cert_infoextra_certs_inforv   certinfoextra_certss
             rS   r=   r=     s   , h(w/H(H-N (#	   &'"&$ 	1VVXF	 	 ) f	
  	 -9,J)Hi)
CD!)$0@A:d#AKA{##1	 	, Bs   .D(DD
c                    t        | t        t        f      st        t	        dt        |                   t        |t              st        t	        dt        |                  | j                  }t        |      }t        t        d|      }t        j                  | j                  t        j                  |t        |      ||      }t!        |       t#        |t%        |            S )aF  
    Encrypts a byte string using an RSA public key or certificate. Uses PKCS#1
    v1.5 padding.

    :param certificate_or_public_key:
        A PublicKey or Certificate object

    :param data:
        A byte string, with a maximum length 11 bytes less than the key length
        (in bytes)

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the encrypted data
    
            certificate_or_public_key must be an instance of the Certificate or
            PublicKey class, not %s
            <
            data must be a byte string, not %s
            size_t *)r   r	   rB   r   r   r3   r5   	byte_sizer   r   r%   SecKeyEncryptrN   r&   kSecPaddingPKCS1lenr'   r   r    )certificate_or_public_keyr!  
key_lengthbufferoutput_lengthrt   s         rS   rF   rF     s    * /+y1IJ /0
  	 dH% dO	
  	 +44Jz*F*j9M##!--&&D	F VVU=%9::rV   c                 &   t        | t              st        t        dt	        |                   t        |t
              st        t        dt	        |                  | j                  }t        |      }t        t        d|      }t        dk  rt        j                  }nt        j                  }t        j                  | j                  ||t!        |      ||      }t#        |       t%        |t'        |            }t        dk  rt)        ||      }|S )a  
    Decrypts a byte string using an RSA private key. Uses PKCS#1 v1.5 padding.

    :param private_key:
        A PrivateKey object

    :param ciphertext:
        A byte string of the encrypted data

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the original plaintext
    zV
            private_key must an instance of the PrivateKey class, not %s
            r+  r,  )r      )r   rA   r   r   r3   r5   r-  r   r   r%   r(   r&   kSecPaddingNoner/  SecKeyDecryptrN   r0  r'   r   r    r2   )r\   
ciphertextr2  r3  r4  paddingrt   outputs           rS   rE   rE   &  s   & k:. k"	
  	 j(+ j!	
  	 &&Jz*F*j9M'!//00##JF Vvu]';<F'!3JGMrV   c                 8    t        | |t        j                        S )aZ  
    Encrypts a byte string using an RSA public key or certificate. Uses PKCS#1
    OAEP padding with SHA1.

    :param certificate_or_public_key:
        A PublicKey or Certificate object

    :param data:
        A byte string, with a maximum length 41 bytes (or more) less than the
        key length (in bytes)

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the encrypted data
    )_encryptr%   kSecPaddingOAEPKey)r1  r!  s     rS   rD   rD   d  s    * -tX5P5PQQrV   c                 8    t        | |t        j                        S )a  
    Decrypts a byte string using an RSA private key. Uses PKCS#1 OAEP padding
    with SHA1.

    :param private_key:
        A PrivateKey object

    :param ciphertext:
        A byte string of the encrypted data

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the original plaintext
    )_decryptr%   r>  )r\   r9  s     rS   rC   rC   |  s    ( KX-H-HIIrV   c                    t        | t        t        f      st        t	        dt        |                   t        |t              st        t	        dt        |                  |st        d      d}d}	 t        j                  |      }t        t        d      }t        j                  | j                  |      }t        |       |r1t        j                   |t        j"                  ||       t        |       t        j                   |t        j$                  ||       t        |       t        j&                  ||      }t        |       t        j(                  |      |rt        j*                  |       |rt        j*                  |       S S # |rt        j*                  |       |rt        j*                  |       w w xY w)a>  
    Encrypts plaintext using an RSA public key or certificate

    :param certificate_or_public_key:
        A Certificate or PublicKey object

    :param data:
        The plaintext - a byte string

    :param padding:
        The padding mode to use, specified as a kSecPadding*Key value

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the ciphertext
    r*  r+  padding must be specifiedNCFErrorRef *)r   r	   rB   r   r   r3   r5   r   r*   r   r   r)   r%   SecEncryptTransformCreaterN   r+   SecTransformSetAttributekSecPaddingKeykSecTransformInputAttributeNameSecTransformExecuterj   rp   )r1  r!  r:  cf_datasec_transformerror_pointerr9  s          rS   r=  r=    s   , /+y1IJ /0
  	 dH% dO	
  	 455GM$4..t4NN; ::%11
 	&--''	 M*))44		
 	&11-O
&))*5 $$W-$$]3  $$W-$$]3 s   5C)F 1F?c                 t   t        | t              st        t        dt	        |                   t        |t
              st        t        dt	        |                  |st        d      d}d}	 t        j                  |      }t        t        d      }t        j                  | j                  |      }t        |       t        j                  |t        j                   ||       t        |       t        j                  |t        j"                  ||       t        |       t        j$                  ||      }t        |       t        j&                  |      |rt        j(                  |       |rt        j(                  |       S S # |rt        j(                  |       |rt        j(                  |       w w xY w)a  
    Decrypts RSA ciphertext using a private key

    :param private_key:
        A PrivateKey object

    :param ciphertext:
        The ciphertext - a byte string

    :param padding:
        The padding mode to use, specified as a kSecPadding*Key value

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the plaintext
    Y
            private_key must be an instance of the PrivateKey class, not %s
            zB
            ciphertext must be a byte string, not %s
            rB  NrC  )r   rA   r   r   r3   r5   r   r*   r   r   r)   r%   SecDecryptTransformCreaterN   r+   rE  rF  rG  rH  rj   rp   )r\   r9  r:  rI  rJ  rK  	plaintexts          rS   r@  r@    s   , k:. k"	
  	 j(+ j!	
  	 455GM#4..z:NN; ::##
 	&))##		
 	&))44		
 	&00N	&)))4 $$W-$$]3  $$W-$$]3 s   /C'F 1F7c                 R    | j                   dk7  rt        d      t        | |||      S )a  
    Verifies an RSASSA-PKCS-v1.5 signature.

    When the hash_algorithm is "raw", the operation is identical to RSA
    public key decryption. That is: the data is not hashed and no ASN.1
    structure with an algorithm identifier of the hash algorithm is placed in
    the encrypted byte string.

    :param certificate_or_public_key:
        A Certificate or PublicKey instance to verify the signature with

    :param signature:
        A byte string of the signature to verify

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384", "sha512" or "raw"

    :raises:
        oscrypto.errors.SignatureError - when the signature is determined to be invalid
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library
    rY   *The key specified is not an RSA public keyrZ   r   _verifyr1  	signaturer!  hash_algorithms       rS   rH   rH   9  s0    8 !**e3EFF,i~NNrV   c                    t        | t        t        f      st        t	        dt        |                   t        |t              st        t	        dt        |                  | j                  }|dk7  r|dk7  rt        d      dddd	d
dj                  |d      }| j                  }t        |      }t        t        d|      }t        j                  | j                  t         j"                  |t%        |      ||      }	t'        |	       t)        |t+        |            }
t-        ||| j.                  ||
      st1        d      y)a  
    Verifies an RSASSA-PSS signature. For the PSS padding the mask gen algorithm
    will be mgf1 using the same hash algorithm as the signature. The salt length
    with be the length of the hash algorithm, and the trailer field with be the
    standard 0xBC byte.

    :param certificate_or_public_key:
        A Certificate or PublicKey instance to verify the signature with

    :param signature:
        A byte string of the signature to verify

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or "sha512"

    :raises:
        oscrypto.errors.SignatureError - when the signature is determined to be invalid
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library
    r*  r+  rY   r   rQ            0   r   sha1sha224sha256sha384sha512r   r,  Signature is invalidN)r   r	   rB   r   r   r3   r5   rZ   r   getr-  r   r   r%   r.  rN   r&   r7  r0  r'   r   r    r1   r   r/   )r1  rU  r!  rV  cp_algohash_lengthr2  r3  r4  rt   rO  s              rS   rJ   rJ   [  sT   4 /+y1IJ /0
  	 dH% dO	
  	 (11G%G|3EFF  
c.!  +44Jz*F*j9M##!--%%IF V!&%*>?Ink;T;];]_ceno344 prV   c                 R    | j                   dk7  rt        d      t        | |||      S )a  
    Verifies a DSA signature

    :param certificate_or_public_key:
        A Certificate or PublicKey instance to verify the signature with

    :param signature:
        A byte string of the signature to verify

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or "sha512"

    :raises:
        oscrypto.errors.SignatureError - when the signature is determined to be invalid
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library
    r`   z)The key specified is not a DSA public keyrR  rT  s       rS   r8   r8     s0    . !**e3DEE,i~NNrV   c                 R    | j                   dk7  rt        d      t        | |||      S )a  
    Verifies an ECDSA signature

    :param certificate_or_public_key:
        A Certificate or PublicKey instance to verify the signature with

    :param signature:
        A byte string of the signature to verify

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or "sha512"

    :raises:
        oscrypto.errors.SignatureError - when the signature is determined to be invalid
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library
    rd   z)The key specified is not an EC public keyrR  rT  s       rS   r:   r:     s0    . !**d2DEE,i~NNrV   c           
      	   t        | t        t        f      st        t	        dt        |                   t        |t              st        t	        dt        |                  t        |t              st        t	        dt        |                  t        g d      }| j                  dk(  r|t        dg      z  }||vr5d}| j                  dk(  r|dz  }t        t	        d	|t        |                  | j                  dk(  r|dk(  rt        |      | j                  d
z
  kD  r)t        t	        d| j                  t        |                  t        j                  | j                  t         j"                  |t        |      |t        |            }|t         j$                  k(  s|t         j&                  k(  rt)        d      t+        |       yd}d}d}	d}
	 t-        t.        d      }t1        j2                  |      }t        j4                  | j                  ||      }
t7        |       t        j8                  t        j:                  t        j<                  t        j<                  t        j<                  t        j<                  d|   }t        j>                  |
t        j@                  ||       t7        |       |t        g d      v rPddddd|   }t1        jB                  |      }	t        j>                  |
t        jD                  |	|       t7        |       | j                  dk(  r?t        j>                  |
t        jF                  t        jH                  |       t7        |       t1        j2                  |      }t        j>                  |
t        jJ                  ||       t7        |       t        jL                  |
|      }tO        |      s!tQ        |      }tO        |      st)        d      tS        t/        jT                  |            }|st)        d      	 |
rt/        jV                  |
       |rt/        jV                  |       |rt/        jV                  |       |	rt/        jV                  |	       yy# |
rt/        jV                  |
       |rt/        jV                  |       |rt/        jV                  |       |	rt/        jV                  |	       w w xY w)a  
    Verifies an RSA, DSA or ECDSA signature

    :param certificate_or_public_key:
        A Certificate or PublicKey instance to verify the signature with

    :param signature:
        A byte string of the signature to verify

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or "sha512"

    :raises:
        oscrypto.errors.SignatureError - when the signature is determined to be invalid
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library
    r*  zA
            signature must be a byte string, not %s
            r+  md5r]  r^  r_  r`  ra  rY   raw5"md5", "sha1", "sha224", "sha256", "sha384", "sha512", "raw"B
            hash_algorithm must be one of %s, not %s
               z
                data must be 11 bytes shorter than the key size when
                hash_algorithm is "raw" - key size is %s bytes, but data
                is %s bytes long
                rb  NrC  r^  r_  r`  ra     r   r   r   ),r   r	   rB   r   r   r3   r5   r   rZ   r   r   r0  r-  r%   SecKeyRawVerifyrN   r&   r/  errSecVerifyFailederrSSLCryptor/   r'   r   r)   r*   r   SecVerifyTransformCreater+   kSecDigestMD5kSecDigestSHA1kSecDigestSHA2rE  kSecDigestTypeAttributecf_number_from_integerkSecDigestLengthAttributerF  kSecPaddingPKCS1KeyrG  rH  r"   r   boolCFBooleanGetValuerp   )r1  rU  r!  rV  valid_hash_algorithmsvalid_hash_algorithms_errorrt   cf_signaturerI  cf_hash_lengthrJ  rK  hash_constantre  r   errors                   rS   rS  rS    s   . /+y1IJ /0
  	 i* i 	
  	 dH% dO	
  	   WX **e3eW-22&]#$..%7'94' ( 
  	 !**e3%8Ot90::R??^
 *33D	   ))%11**I	N
 ]555=C]C]9] !788 LGNMR5NN; 33I> 99%11

 	& ))++--------
  	)),,		
 	&S!IJJ	
 K '==kJN--22	 M*$..%7--'',,	 M*..t4))44		
 	&**=-H}%=)E5>$%;<<>33C89 !788  $$]3$$\2$$W-$$^4  $$]3$$\2$$W-$$^4 s   IQ8 8ASc                 P    | j                   dk7  rt        d      t        | ||      S )a^  
    Generates an RSASSA-PKCS-v1.5 signature.

    When the hash_algorithm is "raw", the operation is identical to RSA
    private key encryption. That is: the data is not hashed and no ASN.1
    structure with an algorithm identifier of the hash algorithm is placed in
    the encrypted byte string.

    :param private_key:
        The PrivateKey to generate the signature with

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384",
        "sha512" or "raw"

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the signature
    rY   +The key specified is not an RSA private keyrZ   r   _signr\   r!  rV  s      rS   rG   rG     s-    8 %FGGdN33rV   c                 b   t        | t              st        t        dt	        |                   t        |t
              st        t        dt	        |                  | j                  }|dk7  r|dk7  rt        d      dddd	d
dj                  |d      }t        ||| j                  |      }| j                  }t        |      }t        t        d|      }t        j                  | j                   t"        j$                  |t'        |      ||      }	t)        |	       t+        |t-        |            S )a6  
    Generates an RSASSA-PSS signature. For the PSS padding the mask gen
    algorithm will be mgf1 using the same hash algorithm as the signature. The
    salt length with be the length of the hash algorithm, and the trailer field
    with be the standard 0xBC byte.

    :param private_key:
        The PrivateKey to generate the signature with

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or
        "sha512"

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the signature
    rM  r+  rY   r   r  rX  rY  rZ  r[  r   r\  r   r,  )r   rA   r   r   r3   r5   rZ   r   rc  r0   r   r-  r   r   r%   r8  rN   r&   r7  r0  r'   r   r    )
r\   r!  rV  pk_algore  encoded_datar2  r3  r4  rt   s
             rS   rI   rI     s;   4 k:. k"	
  	 dH% dO	
  	 ##G%G|3FGG  
c.!  #>;@T@TVZ[L&&Jz*F*j9M##%%LF VVU=%9::rV   c                 P    | j                   dk7  rt        d      t        | ||      S )aI  
    Generates a DSA signature

    :param private_key:
        The PrivateKey to generate the signature with

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or
        "sha512"

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the signature
    r`   z*The key specified is not a DSA private keyr  r  s      rS   r7   r7     s-    . %EFFdN33rV   c                 P    | j                   dk7  rt        d      t        | ||      S )aL  
    Generates an ECDSA signature

    :param private_key:
        The PrivateKey to generate the signature with

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or
        "sha512"

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the signature
    rd   z*The key specified is not an EC private keyr  r  s      rS   r9   r9     s-    . $EFFdN33rV   c           	         t        | t              st        t        dt	        |                   t        |t
              st        t        dt	        |                  t        g d      }| j                  dk(  r|t        dg      z  }||vr5d}| j                  dk(  r|dz  }t        t        d|t        |                  | j                  dk(  r|dk(  rt        |      | j                  d	z
  kD  r)t        t        d
| j                  t        |                  | j                  }t        |      }t        t        d|      }t        j                  | j                   t"        j$                  |t        |      ||      }t'        |       t)        |t+        |            S d}	d}
d}d}	 t        t,        d      }t        j.                  | j                   |      }t1        |       t        j2                  t        j4                  t        j6                  t        j6                  t        j6                  t        j6                  d|   }t        j8                  |t        j:                  ||       t1        |       |t        g d      v rPddddd|   }t=        j>                  |      }t        j8                  |t        j@                  ||       t1        |       | j                  dk(  r?t        j8                  |t        jB                  t        jD                  |       t1        |       t=        jF                  |      }
t        j8                  |t        jH                  |
|       t1        |       t        jJ                  ||      }	t1        |       t=        jL                  |	      |rt-        jN                  |       |	rt-        jN                  |	       |
rt-        jN                  |
       |rt-        jN                  |       S S # |rt-        jN                  |       |	rt-        jN                  |	       |
rt-        jN                  |
       |rt-        jN                  |       w w xY w)aX  
    Generates an RSA, DSA or ECDSA signature

    :param private_key:
        The PrivateKey to generate the signature with

    :param data:
        A byte string of the data the signature is for

    :param hash_algorithm:
        A unicode string of "md5", "sha1", "sha224", "sha256", "sha384" or
        "sha512"

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A byte string of the signature
    zO
            private_key must be an instance of PrivateKey, not %s
            r+  ri  rY   rk  rl  rm  rn  ro  z
                data must be 11 bytes shorter than the key size when
                hash_algorithm is "raw" - key size is %s bytes, but
                data is %s bytes long
                r,  NrC  rp  rq  r   r   r   )(r   rA   r   r   r3   r5   r   rZ   r   r   r0  r-  r   r   r%   SecKeyRawSignrN   r&   r/  r'   r   r    r)   SecSignTransformCreater+   rv  rw  rx  rE  ry  r*   rz  r{  rF  r|  r   rG  rH  rj   rp   )r\   r!  rV  r  r  r2  r3  r4  rt   r  rI  r  rJ  rK  r  re  s                   rS   r  r  6  s   . k:. k"	
  	 dH% dO	
  	   WX%eW-22&]#  E)'94' ( 
  	 %.E*At9{,,r11^
 %%D	   !**
":.Hj*=''##**I
 	  })=>>LGNMG5NN; 778O8OQ^_& ))++--------
  	)),,		
 	&S!IJJ	
 K '==kJN--22	 M*  E)--'',,	 M*..t4))44		
 	&33M=Q&)),7 $$]3$$\2$$W-$$^4  $$]3$$\2$$W-$$^4 s   %G4O7 7AQ)NNr}   )^
__future__r   r   r   r   base64r   r   r   r   _asn1r	   r   r
   r   r   r   r   r   r   r   _asymmetricr   r   r   r   r   r   r   r   r   _errorsr   _ffir   r   r   r   r    r!   r"   r#   	_securityr%   r&   r'   r(   _core_foundationr)   r*   r+   utilr,   errorsr-   r.   r/   _pkcs1r0   r1   r2   _typesr3   r4   r5   r6   __all__rA   rB   r;   r   r<   r   r>   r?   rq   r@   r=   rF   rE   rD   rC   r=  r@  rH   rJ   r8   r:   rS  rG   rI   r7   r9   r  r   rV   rS   <module>r     s3   R R  	  
 
 

 
 
 % g g g R R H H  U U \ \ < <2r$ r$j$ $@l," l,^qThC5L$#N005%p%!Py0x;2:$z3;l;|R0J.Q4hO4dODF5RO:O:q5h4DE;P4:4:^5rV   