
    >wg                        d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZmZmZmZmZmZmZmZ  G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d dee      Z G d de      Z G d de      Z G d de      Z G d de      Z  G d de      Z! G d de      Z" G d  d!ee      Z# G d" d#e      Z$ G d$ d%e      Z% G d& d'e      Z& G d( d)e      Z' G d* d+e      Z( G d, d-e      Z) G d. d/e      Z* G d0 d1e      Z+ G d2 d3e      Z, G d4 d5e      Z- G d6 d7e      Z. G d8 d9e      Z/ G d: d;e      Z0 G d< d=e      Z1 G d> d?e      Z2 G d@ dAe      Z3 G dB dCe      Z4 G dD dEee      Z5 G dF dGe      Z6 G dH dIe      Z7 G dJ dKe      Z8 G dL dMe      Z9e6e5jt                  dN<    G dO dPe      Z; G dQ dRee      Z<yS)Ta  
ASN.1 type classes for various algorithms using in various aspects of public
key cryptography. Exports the following items:

 - AlgorithmIdentifier()
 - AnyAlgorithmIdentifier()
 - DigestAlgorithm()
 - DigestInfo()
 - DSASignature()
 - EncryptionAlgorithm()
 - HmacAlgorithm()
 - KdfAlgorithm()
 - Pkcs5MacAlgorithm()
 - SignedDigestAlgorithm()

Other type classes are defined that help compose the types listed above.
    )unicode_literalsdivisionabsolute_importprint_function   )unwrap)
fill_width)int_from_bytesint_to_bytes)AnyChoiceIntegerNullObjectIdentifierOctetStringSequenceVoidc                   "    e Zd ZdefdeddifgZy)AlgorithmIdentifier	algorithm
parametersoptionalTN)__name__
__module____qualname__r   r   _fields     G/var/www/horilla/myenv/lib/python3.12/site-packages/asn1crypto/algos.pyr   r   +   s!    	&'	sZ./Gr   r   c                   D     e Zd ZdZ eg d      Zd ZdeiZ fdZ xZ	S )_ForceNullParametersz
    Various structures based on AlgorithmIdentifier require that the parameters
    field be core.Null() for certain OIDs. This mixin ensures that happens.
    )
1.2.840.113549.1.1.11.2.840.113549.1.1.111.2.840.113549.1.1.121.2.840.113549.1.1.131.2.840.113549.1.1.141.3.14.3.2.262.16.840.1.101.3.4.2.42.16.840.1.101.3.4.2.12.16.840.1.101.3.4.2.22.16.840.1.101.3.4.2.3c                     | j                   dk(  r,| d   j                  }|| j                  v r| j                  |   S | d   j                  | j                  v rt
        S y )Nr   r   r   )	_oid_pairnative
_oid_specsdotted_null_algosr   )selfalgos     r   _parameters_specz%_ForceNullParameters._parameters_specJ   s[    >>88$++Dt&t,,##t'7'77Kr   r   c                     t         t        |   ||      }|dk7  r|S | d   j                  | j                  vr|S | d   j
                  t        k7  r|S t               | d<   |S )Nr   r   )superr!   __setitem__r1   r2   	__class__r   r   )r3   keyvalueresr9   s       r   r8   z _ForceNullParameters.__setitem___   sk    ($;CG+J##4+;+;;J''4/J!V\
r   )
r   r   r   __doc__setr2   r5   _spec_callbacksr8   __classcell__)r9   s   @r   r!   r!   2   s7       K	 	&O	 	r   r!   c                   *    e Zd Zddddddddd	d
dddZy)HmacAlgorithmIddes_macsha1sha224sha256sha384sha512
sha512_224
sha512_256sha3_224sha3_256sha3_384sha3_512)z1.3.14.3.2.10z1.2.840.113549.2.7z1.2.840.113549.2.8z1.2.840.113549.2.9z1.2.840.113549.2.10z1.2.840.113549.2.11z1.2.840.113549.2.12z1.2.840.113549.2.13z2.16.840.1.101.3.4.2.13z2.16.840.1.101.3.4.2.14z2.16.840.1.101.3.4.2.15z2.16.840.1.101.3.4.2.16Nr   r   r   _mapr   r   r   rB   rB   k   s-    "$&&''++#-#-#-#-Dr   rB   c                   "    e Zd ZdefdeddifgZy)HmacAlgorithmr   r   r   TN)r   r   r   rB   r   r   r   r   r   rR   rR   |   s     	o&	sZ./Gr   rR   c                   v    e Zd Zi ddddddddd	d
dddddddddddddddddddddd d!d"Zy#)$DigestAlgorithmIdz1.2.840.113549.2.2md2z1.2.840.113549.2.5md5r'   rD   r(   rE   r)   rF   r*   rG   r+   rH   z2.16.840.1.101.3.4.2.5rI   z2.16.840.1.101.3.4.2.6rJ   z2.16.840.1.101.3.4.2.7rK   z2.16.840.1.101.3.4.2.8rL   z2.16.840.1.101.3.4.2.9rM   z2.16.840.1.101.3.4.2.10rN   z2.16.840.1.101.3.4.2.11shake128z2.16.840.1.101.3.4.2.12shake256z2.16.840.1.101.3.4.2.17shake128_lenz2.16.840.1.101.3.4.2.18shake256_lenNrO   r   r   r   rT   rT      s    ee 	 	!(	
 	!( 	!( 	!( 	!, 	!, 	!* 	!* 	!* 	": 	": 	":  	">!" 	">#Dr   rT   c                   "    e Zd ZdefdeddifgZy)DigestAlgorithmr   r   r   TN)r   r   r   rT   r   r   r   r   r   r\   r\      s!    	'(	sZ./Gr   r\   c                       e Zd ZdefdefgZy)
DigestInfodigest_algorithmdigestN)r   r   r   r\   r   r   r   r   r   r^   r^      s    	_-	;Gr   r^   c                       e Zd ZddiZy)MaskGenAlgorithmIdz1.2.840.113549.1.1.8mgf1NrO   r   r   r   rb   rb      s    Dr   rb   c                   .    e Zd ZdefdeddifgZdZdeiZy)MaskGenAlgorithmr   r   r   Tr-   rc   N)	r   r   r   rb   r   r   r.   r\   r0   r   r   r   re   re      s4    	()	sZ./G
 ,IJr   re   c                       e Zd ZddiZy)TrailerFieldr   trailer_field_bcNrO   r   r   r   rg   rg      s    	Dr   rg   c                   V    e Zd Zdedddidfdeddddid	dfd
edddfdedddfgZy)RSASSAPSSParamshash_algorithmr   r   rD   explicitdefaultmask_gen_algorithmr   rc   r-   salt_length      trailer_field   rh   N)r   r   r   r\   re   r   rg   r   r   r   r   rj   rj      s{     '0	
 !!'#."7
	
 	
 -	
9$Gr   rj   c                      e Zd Zi ddddddddddd	dd
dddddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+Zi d'd,d(d-ddddd&d.dddddddd	dddd/dd
dddd0ddd d1ddd2dd3d4d5d6d7d8d9Zy:);SignedDigestAlgorithmIdz1.3.14.3.2.3md5_rsaz1.3.14.3.2.29sha1_rsaz1.3.14.7.2.3.1md2_rsaz1.2.840.113549.1.1.2z1.2.840.113549.1.1.4z1.2.840.113549.1.1.5r&   
sha224_rsar#   
sha256_rsar$   
sha384_rsar%   
sha512_rsaz1.2.840.113549.1.1.10
rsassa_pssz1.2.840.10040.4.3sha1_dsaz1.3.14.3.2.13z1.3.14.3.2.27z2.16.840.1.101.3.4.3.1
sha224_dsaz2.16.840.1.101.3.4.3.2
sha256_dsaz1.2.840.10045.4.1
sha1_ecdsasha224_ecdsasha256_ecdsasha384_ecdsasha512_ecdsasha3_224_ecdsasha3_256_ecdsasha3_384_ecdsasha3_512_ecdsarsassa_pkcs1v15dsaecdsaed25519ed448)1.2.840.10045.4.3.11.2.840.10045.4.3.21.2.840.10045.4.3.31.2.840.10045.4.3.42.16.840.1.101.3.4.3.92.16.840.1.101.3.4.3.102.16.840.1.101.3.4.3.112.16.840.1.101.3.4.3.12r"   1.2.840.10040.4.11.2.840.10045.41.3.101.1121.3.101.113r   r   r"   r   r   r   r   r   r   r   r   r   r   )r   r}   r   r   r   r   r   r   N)r   r   r   rP   _reverse_mapr   r   r   rv   rv      s    !	!! 	)! 			!
 		! 	
! 	 ! 	 ! 	 ! 	 ! 	 ! 	Z! 	! 	! 	!,!  	!,!!" 	\#!$  .---"2#3#3#3 1"" A!DF"" 	) 	)	
 	1 	- 	' 	) 	* 	. 	- 	- 	. 	- 	-  	-!" 	-#$ .-2333 3Lr   rv   c                   N    e Zd ZdefdeddifgZdZdeiZe	d        Z
e	d        Zy	)
SignedDigestAlgorithmr   r   r   Tr-   r~   c           
          | d   j                   }i ddddddddddddd	dddd
d
ddddddddddddddddddddddddd}||v r||   S t        t        d|            )z
        :return:
            A unicode string of "rsassa_pkcs1v15", "rsassa_pss", "dsa",
            "ecdsa", "ed25519" or "ed448"
        r   ry   r   rw   rx   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   z>
            Signature algorithm not known for %s
            r/   
ValueErrorr   r3   r   algo_maps      r   signature_algoz$SignedDigestAlgorithm.signature_algo4  s=    %,,	
(
(
 )
 +	

 +
 +
 +
 0
 ,
 
 %
 %
 5
 '
 G
  G!
" G#
$ $%%%% 3
6  I&& 	
  	r   c                     | d   j                   }i dddddddd	d
ddddddddd	dddddd	dddddddddd}||v r||   S |dk(  r| d   d   d   j                   S t        t        d|            )z
        :return:
            A unicode string of "md2", "md5", "sha1", "sha224", "sha256",
            "sha384", "sha512", "sha512_224", "sha512_256" or "shake256"
        r   ry   rU   rw   rV   rx   rD   rz   rE   r{   rF   r|   rG   r}   rH   r   r   r   r   r   r   r   r   r   r   rX   r~   r   rk   z9
            Hash algorithm not known for %s
            r   r   s      r   	hash_algozSignedDigestAlgorithm.hash_algoc  s:    %,,	
u
u
 
 (	

 (
 (
 (
 
 (
 (
 &
 H
 H
 H
 H
  x!
" Z#
&  I&&$%&67DKKK 	
  	r   N)r   r   r   rv   r   r   r.   rj   r0   propertyr   r   r   r   r   r   r   )  s]    	-.	sZ./G
 ,IoJ , ,\ ' 'r   r   c                       e Zd ZdefdefgZy)
Pbkdf2Salt	specifiedother_sourceN)r   r   r   r   r   _alternativesr   r   r   r   r     s    	k"	,-Mr   r   c                   8    e Zd Zdefdefdeddifdeddd	iifgZy
)Pbkdf2Paramssaltiteration_count
key_lengthr   Tprfrn   r   rD   N)r   r   r   r   r   rR   r   r   r   r   r   r     s<    		G$	wT 23		K+@AB	Gr   r   c                       e Zd ZddiZy)KdfAlgorithmIdz1.2.840.113549.1.5.12pbkdf2NrO   r   r   r   r   r         Dr   r   c                   .    e Zd ZdefdeddifgZdZdeiZy)KdfAlgorithmr   r   r   Tr-   r   N)	r   r   r   r   r   r   r.   r   r0   r   r   r   r   r     s3    	n%	sZ./G ,I,Jr   r   c                   ,    e Zd ZdZdefdefdeddifgZy)DHParameterszn
    Original Name: DHParameter
    Source: ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-3.asc section 9
    pgprivate_value_lengthr   TN)r   r   r   r=   r   r   r   r   r   r   r     s-     
g	g	:t*<=Gr   r   c                       e Zd ZddiZy)KeyExchangeAlgorithmIdz1.2.840.113549.1.3.1dhNrO   r   r   r   r   r     s    Dr   r   c                   .    e Zd ZdefdeddifgZdZdeiZy)KeyExchangeAlgorithmr   r   r   Tr-   r   N)	r   r   r   r   r   r   r.   r   r0   r   r   r   r   r     s4    	,-	sZ./G ,IlJr   r   c                   "    e Zd ZdeddifdefgZy)	Rc2Paramsrc2_parameter_versionr   TivN)r   r   r   r   r   r   r   r   r   r   r     s     	 'J+=>	{Gr   r   c                       e Zd ZddiZy)Rc5ParamVersion   zv1-0NrO   r   r   r   r   r     s    
FDr   r   c                   .    e Zd ZdefdefdefdeddifgZy)	Rc5Paramsversionroundsblock_size_in_bitsr   r   TN)r   r   r   r   r   r   r   r   r   r   r   r     s0    	O$	7	w'	{Z./	Gr   r   c                       e Zd ZdefdefgZy)Pbes1Paramsr   
iterationsNr   r   r   r   r   r   r   r   r   r   r     s    		wGr   r   c                       e Zd ZdefdefgZy)	CcmParams	aes_nonce
aes_icvlenNr   r   r   r   r   r     s     
k"	wGr   r   c                       e Zd ZddiZy)PSourceAlgorithmIdz1.2.840.113549.1.1.9p_specifiedNrO   r   r   r   r   r     s    Dr   r   c                   .    e Zd ZdefdeddifgZdZdeiZy)PSourceAlgorithmr   r   r   Tr-   r   N)	r   r   r   r   r   r   r.   r   r0   r   r   r   r   r     s4    	()	sZ./G
 ,I{Jr   r   c                   N    e Zd Zdedddidfdeddddid	dfd
edddd	dfgZy)RSAESOAEPParamsrk   r   r   rD   rl   ro   r   rc   r-   p_source_algorithmrq   r   r   N)r   r   r   r\   re   r   r   r   r   r   r   r     sk     '0	
 !!'#."7
	
 !!."%
	
)Gr   r   c                   6    e Zd ZdZdefdefgZed        Zd Zy)DSASignaturea  
    An ASN.1 class for translating between the OS crypto library's
    representation of an (EC)DSA signature and the ASN.1 structure that is part
    of various RFCs.

    Original Name: DSS-Sig-Value
    Source: https://tools.ietf.org/html/rfc3279#section-2.2.2
    rsc                     t        |dt        |      dz         }t        |t        |      dz  d       } | ||d      S )a  
        Reads a signature from a byte string encoding accordint to IEEE P1363,
        which is used by Microsoft's BCryptSignHash() function.

        :param data:
            A byte string from BCryptSignHash()

        :return:
            A DSASignature object
        r   rq   N)r   r   )r
   len)clsdatar   r   s       r   
from_p1363zDSASignature.from_p13637  sF     4#d)q.124D	Q01#$$r   c                     t        | d   j                        }t        | d   j                        }t        t        |      t        |            }t	        ||      }t	        ||      }||z   S )z
        Dumps a signature to a byte string compatible with Microsoft's
        BCryptVerifySignature() function.

        :return:
            A byte string compatible with BCryptVerifySignature()
        r   r   )r   r/   maxr   r	   )r3   r_bytess_bytesint_byte_lengths       r   to_p1363zDSASignature.to_p1363H  sc     tCy//0tCy//0c'lCL9Wo6Wo6  r   N)	r   r   r   r=   r   r   classmethodr   r   r   r   r   r   r   (  s7     
g	gG
 % % !r   r   c                       e Zd Zi ddddddddd	d
dddddddddddddddddddddd d!d"i d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdO
ZyP)QEncryptionAlgorithmIdz1.3.14.3.2.7desz1.2.840.113549.3.7tripledes_3keyz1.2.840.113549.3.2rc2z1.2.840.113549.3.4rc4z1.2.840.113549.3.9rc5z2.16.840.1.101.3.4.1.1
aes128_ecbz2.16.840.1.101.3.4.1.2
aes128_cbcz2.16.840.1.101.3.4.1.3
aes128_ofbz2.16.840.1.101.3.4.1.4
aes128_cfbz2.16.840.1.101.3.4.1.5aes128_wrapz2.16.840.1.101.3.4.1.6
aes128_gcmz2.16.840.1.101.3.4.1.7
aes128_ccmz2.16.840.1.101.3.4.1.8aes128_wrap_padz2.16.840.1.101.3.4.1.21
aes192_ecbz2.16.840.1.101.3.4.1.22
aes192_cbcz2.16.840.1.101.3.4.1.23
aes192_ofbz2.16.840.1.101.3.4.1.24
aes192_cfbz2.16.840.1.101.3.4.1.25aes192_wrapz2.16.840.1.101.3.4.1.26
aes192_gcmz2.16.840.1.101.3.4.1.27
aes192_ccmz2.16.840.1.101.3.4.1.28aes192_wrap_padz2.16.840.1.101.3.4.1.41
aes256_ecbz2.16.840.1.101.3.4.1.42
aes256_cbcz2.16.840.1.101.3.4.1.43
aes256_ofbz2.16.840.1.101.3.4.1.44
aes256_cfbz2.16.840.1.101.3.4.1.45aes256_wrapz2.16.840.1.101.3.4.1.46
aes256_gcmz2.16.840.1.101.3.4.1.47
aes256_ccmz2.16.840.1.101.3.4.1.48aes256_wrap_padz1.2.840.113549.1.5.13pbes2z1.2.840.113549.1.5.1pbes1_md2_desz1.2.840.113549.1.5.3pbes1_md5_desz1.2.840.113549.1.5.4pbes1_md2_rc2z1.2.840.113549.1.5.6pbes1_md5_rc2pbes1_sha1_despbes1_sha1_rc2pkcs12_sha1_rc4_128pkcs12_sha1_rc4_40pkcs12_sha1_tripledes_3keypkcs12_sha1_tripledes_2keypkcs12_sha1_rc2_128pkcs12_sha1_rc2_40rsaes_pkcs1v15
rsaes_oaep)
z1.2.840.113549.1.5.10z1.2.840.113549.1.5.11z1.2.840.113549.1.12.1.1z1.2.840.113549.1.12.1.2z1.2.840.113549.1.12.1.3z1.2.840.113549.1.12.1.4z1.2.840.113549.1.12.1.5z1.2.840.113549.1.12.1.6r"   z1.2.840.113549.1.1.7NrO   r   r   r   r   r   [  s   11.1 	e1 	e	1
 	e1 	!,1 	!,1 	!,1 	!,1 	!-1 	!,1 	!,1 	!"31 	"<1  	"<!1" 	"<#1$ 	"<%1& 	"='1( 	"<)1* 	"<+1, 	"#4-1. 	"</10 	"<112 	"<314 	"<516 	"=718 	"<91: 	"<;1< 	"#4=1@ 	 A1B 	C1D 	E1F 	G1H 	I1J "2!1#8#7#?#?#8#7 0 ,a1Dr   r   c                   8   e Zd ZdefdeddifgZdZi dededed	e	d
edededededede
de
de
dedededeeeeeeeeeed	Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed         Zy!)"EncryptionAlgorithmr   r   r   Tr-   r   r   r   r   r   r   r  r   r   r  r   r  r  r  r  r  r  )	r  r  r  r  r  r  r  r  r  c                 :   | d   j                   }|dk(  r| d   d   d   j                   S |j                  d      dk(  rJ|j                  d      dk7  r!|j                  dd      \  }}|d	k(  ry
|dk(  ryt        t	        d|            t        t	        d|            )z
        Returns the name of the key derivation function to use.

        :return:
            A unicode from of one of the following: "pbkdf1", "pbkdf2",
            "pkcs12_kdf"
        r   r  r   key_derivation_func._r   pbes1pbkdf1pkcs12
pkcs12_kdf~
                Encryption algorithm "%s" does not have a registered key
                derivation function
                zw
            Unrecognized encryption algorithm "%s", can not determine key
            derivation function
            r/   findsplitr   r   )r3   encryption_algor#  s      r   kdfzEncryptionAlgorithm.kdf  s     {+22g%%&;<[IPPP$*##C(B.%4%:%:3%B""g-#"h.'V      
  	r   c                 4   | d   j                   }|dk(  r| d   d   d   d   d   j                   S |j                  d      dk(  rA|j                  d      dk7  r|j                  dd	      \  }}}|S t        t	        d
|            t        t	        d|            )z
        Returns the HMAC algorithm to use with the KDF.

        :return:
            A unicode string of one of the following: "md2", "md5", "sha1",
            "sha224", "sha256", "sha384", "sha512"
        r   r  r   r   r   r!  r"  r#  rq   r(  z}
            Unrecognized encryption algorithm "%s", can not determine key
            derivation hmac algorithm
            r)  )r3   r,  r#  	hmac_algos       r   kdf_hmaczEncryptionAlgorithm.kdf_hmac  s     {+22g%%&;<\J5QR]^eee$*##C(B."1"7"7Q"?9a  V      
  	r   c                 l   | d   j                   }|dk(  r=| d   d   d   d   }|j                  dk(  rt        t        d            |j                   S |j	                  d      d	k(  r;|j	                  d
      d	k7  r| d   d   j                   S t        t        d|            t        t        d|            )zu
        Returns the byte string to use as the salt for the KDF.

        :return:
            A byte string
        r   r  r   r   r   r   z
                    Can not determine key derivation salt - the
                    reserved-for-future-use other source salt choice was
                    specified in the PBKDF2 params structure
                    r!  r"  r#  r(  zs
            Unrecognized encryption algorithm "%s", can not determine key
            derivation salt
            )r/   namer   r   r*  )r3   r,  r   s      r   kdf_saltzEncryptionAlgorithm.kdf_salt  s     {+22g%%&;<\J6RDyyN* "   ;;$*##C(B.L)&1888V      
  	r   c                 "   | d   j                   }|dk(  r| d   d   d   d   j                   S |j                  d      dk(  r;|j                  d      dk7  r| d   d	   j                   S t        t        d
|            t        t        d|            )z{
        Returns the number of iterations that should be run via the KDF.

        :return:
            An integer
        r   r  r   r   r   r!  r"  r#  r   r(  zy
            Unrecognized encryption algorithm "%s", can not determine key
            derivation iterations
            )r/   r*  r   r   r3   r,  s     r   kdf_iterationsz"EncryptionAlgorithm.kdf_iterations2  s     {+22g%%&;<\JK\]ddd$*##C(B.L),7>>>V      
  	r   c                    | d   j                   }|dd dk(  rdddd|dd	    S d
dd}||v r||   S |dk(  r?| d   d   j                   }dd
dd}||v r||   S |dk\  r|S |yt        t        d            |dk(  r.| d   d   d   d   j                   }||S | d   d   j                  S |j	                  d      dk(  rd
d
d
d
d
d
ddddddd|   S t        t        d|            )a  
        Returns the key length to pass to the cipher/kdf. The PKCS#5 spec does
        not specify a way to store the RC5 key length, however this tends not
        to be a problem since OpenSSL does not support RC5 in PKCS#8 and OS X
        does not provide an RC5 cipher for use in the Security Transforms
        library.

        :raises:
            ValueError - when the key length can not be determined

        :return:
            An integer representing the length in bytes
        r   r   rt   aesr          aes128_aes192_aes256_      )r   r   r   r   r      )   x   :         zw
                Invalid RC2 parameter version found in EncryptionAlgorithm
                parameters
                r  r   r   encryption_schemer!  r"  r  r  r  r  r  r  r  r  r  r  r  r  @
            Unrecognized encryption algorithm "%s"
            )r/   r   r   r   r*  )r3   r,  cipher_lengthsr   encoded_key_bits_mapr   s         r   r   zEncryptionAlgorithm.key_lengthT  s     {+221Q5( a"	$ $  

 n,!/22e#$($67N$O$V$V!
 $  %(<<+,ABB$+,,$,V   g%l+,AB<PQ]^eeJ%!! %&9:EEE$*!"!"!"!""#"#')&'.0.0')&'    	
  	r   c                     | d   j                   }|dd t        g d      v r|dd S |dd dk(  ry|dd d	k(  ry|t        g d
      v ry|dk(  r| d   d   j                  S t        t	        d|            )z
        Returns the name of the encryption mode to use.

        :return:
            A unicode string from one of the following: "cbc", "ecb", "ofb",
            "cfb", "wrap", "gcm", "ccm", "wrap_pad"
        r   r   r?  r;  N   pbes1_cbcpkcs12_)r   r   r   r   r  r   rG  rI  )r/   r>   encryption_moder   r   r5  s     r   rQ  z#EncryptionAlgorithm.encryption_mode  s     {+221Q3'H#II"12&&1Q8+1Q9,c"IJJg%%&9:JJJ 	
  	r   c                    | d   j                   }|dd t        g d      v ry|t        g d      v r|S |dk(  ry|d	k(  r| d
   d   j                  S |j                  d      dk(  rddddddddddddd|   S t	        t        d|            )al  
        Returns the name of the symmetric encryption cipher to use. The key
        length can be retrieved via the .key_length property to disabiguate
        between different variations of TripleDES, AES, and the RC* ciphers.

        :return:
            A unicode string from one of the following: "rc2", "rc5", "des",
            "tripledes", "aes"
        r   r   r?  r;  r8  )r   r   r   r   	tripledesr  r   rG  r!  r"  r   r   r   rH  rI  )r/   r>   encryption_cipherr*  r   r   r5  s     r   rT  z%EncryptionAlgorithm.encryption_cipher  s     {+221Q3'H#IIc"788""..g%%&9:LLL$*!&!&!&!&"'"'',&+.9.9',&+    	
  	r   c                 <   | d   j                   }|dd t        g d      v rydddd}||v r||   S |dk(  r| d	   d
   j                   dz  S |dk(  r| d	   d   j                  S |j                  d      dk(  rddddddddddddd|   S t	        t        d|            )z
        Returns the block size of the encryption cipher, in bytes.

        :return:
            An integer that is the block size in bytes
        r   r   r?  r;  r   r@  )r   r   r   r   r   r   r  rG  r!  r"  rH  rI  )r/   r>   encryption_block_sizer*  r   r   )r3   r,  
cipher_maps      r   rV  z)EncryptionAlgorithm.encryption_block_size  s    {+221Q3'H#II 


 j(o..e#%&:;BBaGGg%%&9:PPP$*!"!"!"!""#"#'(&'././'(&'    	
  	r   c                 $   | d   j                   }|t        ddg      v r| d   d   j                   S t        g d      }||v r| d   j                   S |dk(  r| d   d   j                  S |j                  d	      d
k(  ryt	        t        d|            )a  
        Returns the byte string of the initialization vector for the encryption
        scheme. Only the PBES2 stores the IV in the params. For PBES1, the IV
        is derived from the KDF and this property will return None.

        :return:
            A byte string or None
        r   r   r   r   r   )r   r   r   r   r  r   r   r  r  rG  r!  r"  NrI  )r/   r>   encryption_ivr*  r   r   )r3   r,  octet_string_iv_oidss      r   rY  z!EncryptionAlgorithm.encryption_iv9  s     {+22c5%.11%d+222  # 	$
 	  22%,,,g%%&9:HHH $* 	
  	r   N)r   r   r   r   r   r   r.   r   r   r   r   r   r   r0   r   r-  r0  r3  r6  r   rQ  rT  rV  rY  r   r   r   r  r    s   	+,	sZ./G
 ,I{+ 	y 	y	
 	k 	k 	k 	k 	k 	k 	i 	i 	i  	!" 	#$ 	%& 	'( &%*)&1&1*)%=JB & &P ! !F * *X  B \ \|  B . .` 0 0d - -r   r  c                       e Zd ZdefdefgZy)Pbes2Paramsr   rG  N)r   r   r   r   r  r   r   r   r   r\  r\  j  s    	-	12Gr   r\  c                       e Zd ZdefdefgZy)Pbmac1Paramsr   message_auth_schemeN)r   r   r   r   rR   r   r   r   r   r^  r^  q  s    	-	.Gr   r^  c                       e Zd ZddiZy)
Pkcs5MacIdz1.2.840.113549.1.5.14pbmac1NrO   r   r   r   ra  ra  x  r   r   ra  c                   (    e Zd ZdefdefgZdZdeiZy)Pkcs5MacAlgorithmr   r   r-   rb  N)	r   r   r   ra  r   r   r.   r^  r0   r   r   r   rd  rd  ~  s,    	j!	sG
 ,I,Jr   rd  r  c                       e Zd Zi Zd Zy)AnyAlgorithmIdc                     | j                   j                  }t        t        t        fD ])  }|j                  j                         D ]
  \  }}|||<    + y N)r9   rP   r   rv   rT   items)r3   rP   	other_clsoidr2  s        r   _setupzAnyAlgorithmId._setup  sR    ~~""/1HJ[\ 	!I&^^113 !	T S	!	!r   N)r   r   r   rP   rl  r   r   r   rf  rf    s    D!r   rf  c                   0    e Zd ZdefdeddifgZdZi Zd Zy)AnyAlgorithmIdentifierr   r   r   Tr-   c                     t        j                  |        | j                  j                  }t        t
        fD ])  }|j                  j                         D ]
  \  }}|||<    + y rh  )r   rl  r9   r0   r  r   ri  )r3   specsrj  rk  specs        r   rl  zAnyAlgorithmIdentifier._setup  s]    ))-/DE 	"I&11779 "	T!c
"	"r   N)	r   r   r   rf  r   r   r.   r0   rl  r   r   r   rn  rn    s1    	n%	sZ./G
 ,IJ"r   rn  N)=r=   
__future__r   r   r   r   _errorsr   _intr	   utilr
   r   corer   r   r   r   r   r   r   r   r   objectr!   rB   rR   rT   r\   r^   rb   re   rg   rj   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r\  r^  ra  rd  r0   rf  rn  r   r   r   <module>rx     s  $ S R   .	 	 	"( 66 6r& "H ( ,*H  ) 	x 	7 %h %P>. >Bb0( bJ 8 % 8 
8 
- 8  g  (  ) 	x 	 h  F0!8 0!f2, 2jW. Wt( 8 ! 	 	 +6   w '!% !"18 "r   