
    Ii                        S r SSKJrJrJrJr  SSKrSSKrSSKJ	r	J
r
  SSKJrJr  SSKJrJrJrJrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#  SS	K$J%r%J&r&   " S
 S\!5      r' " S S\"5      r( " S S\5      r) " S S\!5      r* " S S\!5      r+ " S S\!5      r, " S S5      r- " S S\\-5      r. " S S\\-5      r/ " S S\5      r0 " S S\5      r1 " S  S!\5      r2 " S" S#\!5      r3 " S$ S%\!5      r4 " S& S'\!5      r5 " S( S)\!5      r6 " S* S+\!5      r7 " S, S-\5      r8 " S. S/\5      r9 " S0 S1\5      r: " S2 S3\!5      r; " S4 S5\!5      r< " S6 S7\!5      r= " S8 S9\#5      r> " S: S;\5      r? " S< S=\\!5      r@ " S> S?\!5      rA " S@ SA\!5      rB " SB SC\!5      rC " SD SE\!5      rD " SF SG\5      rE " SH SI\\!5      rF " SJ SK\!5      rGg)La'  
ASN.1 type classes for public and private keys. Exports the following items:

 - DSAPrivateKey()
 - ECPrivateKey()
 - EncryptedPrivateKeyInfo()
 - PrivateKeyInfo()
 - PublicKeyInfo()
 - RSAPrivateKey()
 - RSAPublicKey()

Other type classes are defined that help compose the types listed above.
    )unicode_literalsdivisionabsolute_importprint_functionN   )unwrapAPIException)	type_namebyte_cls)_ForceNullParametersDigestAlgorithmEncryptionAlgorithmRSAESOAEPParamsRSASSAPSSParams)Any	Asn1Value	BitStringChoiceIntegerIntegerOctetStringNullObjectIdentifierOctetBitStringOctetStringParsableOctetStringParsableOctetBitStringSequence
SequenceOfSetOf)int_from_bytesint_to_bytesc                   .    \ rS rSrSrS\4S\4S\4/rSrg)OtherPrimeInfo-   5
Source: https://tools.ietf.org/html/rfc3447#page-46
primeexponentcoefficient N__name__
__module____qualname____firstlineno____doc__r   _fields__static_attributes__r)       5/venv/lib/python3.13/site-packages/asn1crypto/keys.pyr#   r#   -   s(    
 
'	W	 Gr2   r#   c                       \ rS rSrSr\rSrg)OtherPrimeInfos9   r%   r)   N)r+   r,   r-   r.   r/   r#   _child_specr1   r)   r2   r3   r5   r5   9   s     !Kr2   r5   c                   "    \ rS rSrSrSSS.rSrg)RSAPrivateKeyVersionA   zL
Original Name: Version
Source: https://tools.ietf.org/html/rfc3447#page-45
z	two-primemulti)r   r   r)   Nr+   r,   r-   r.   r/   _mapr1   r)   r2   r3   r9   r9   A   s     Dr2   r9   c                   ^    \ rS rSrSrS\4S\4S\4S\4S\4S\4S	\4S
\4S\4S\SS04/
rSr	g)RSAPrivateKeyM   z5
Source: https://tools.ietf.org/html/rfc3447#page-45
versionmoduluspublic_exponentprivate_exponentprime1prime2	exponent1	exponent2r(   other_prime_infosoptionalTr)   N)
r+   r,   r-   r.   r/   r9   r   r5   r0   r1   r)   r2   r3   r?   r?   M   sh    
 
()	G	G$	W%	7	7	g	g	 	o
D/ABGr2   r?   c                   (    \ rS rSrSrS\4S\4/rSrg)RSAPublicKey`   z5
Source: https://tools.ietf.org/html/rfc3447#page-44
rB   rC   r)   Nr*   r)   r2   r3   rL   rL   `   s     
 
G	G$Gr2   rL   c                   @    \ rS rSrSrS\4S\4S\4S\4S\4S\4/rS	rg
)DSAPrivateKeyk   a  
The ASN.1 structure that OpenSSL uses to store a DSA private key that is
not part of a PKCS#8 structure. Reversed engineered from english-language
description on linked OpenSSL documentation page.

Original Name: None
Source: https://www.openssl.org/docs/apps/dsa.html
rA   pqg
public_keyprivate_keyr)   Nr*   r)   r2   r3   rO   rO   k   s=     
G	g	g	g	w	 Gr2   rO   c                   .    \ rS rSrSr\S 5       rS rSrg)_ECPoint   z
In both PublicKeyInfo and PrivateKeyInfo, the EC public key is a byte
string that is encoded as a bit string. This class adds convenience
methods for converting to and from the byte string to a pair of integers
that are the X and Y coordinates.
c                 8   [        [        R                  " [        R                  " US5      S-  5      5      n[        [        R                  " [        R                  " US5      S-  5      5      n[	        X45      nSnU[        XS9-  nU[        X%S9-  nU " U5      $ )z
Creates an ECPoint object from the X and Y integer coordinates of the
point

:param x:
    The X coordinate, as an integer

:param y:
    The Y coordinate, as an integer

:return:
    An ECPoint object
          @   )width)intmathceillogmaxr!   )clsxyx_bytesy_bytes	num_bytesbyte_strings          r3   from_coords_ECPoint.from_coords   s      diiA 456diiA 456)	|A77|A77;r2   c                    U R                   nUSS nUS:X  a1  USS n[        U5      S-  n[        USU 5      n[        X4S 5      nXV4$ U[        SS/5      ;  a  [	        [        S5      5      e[	        [        S	5      5      e)
z
Returns the X and Y coordinates for this EC point, as native Python
integers

:return:
    A 2-element tuple containing integers (X, Y)
r   r   r\   NrZ         zQ
                Invalid EC public key - first byte is incorrect
                z|
            Compressed representations of EC public keys are not supported due
            to patent US6252960
            )nativelenr    set
ValueErrorr   )selfdata
first_byte	remaining	field_lenrd   re   s          r3   	to_coords_ECPoint.to_coords   s     {{!AY
  QRII!+Iy956Ay45A6MS'7!344V   
  	r2   r)   N)	r+   r,   r-   r.   r/   classmethodrj   rx   r1   r)   r2   r3   rW   rW      s         4 r2   rW   c                       \ rS rSrSrg)ECPoint   r)   Nr+   r,   r-   r.   r1   r)   r2   r3   r|   r|          r2   r|   c                       \ rS rSrSrg)ECPointBitString   r)   Nr~   r)   r2   r3   r   r      r   r2   r   c                   $    \ rS rSrSrSSSS.rSrg)	SpecifiedECDomainVersion   2
Source: http://www.secg.org/sec1-v2.pdf page 104
ecdpVer1ecdpVer2ecdpVer3)r   rZ      r)   Nr<   r)   r2   r3   r   r      s     Dr2   r   c                   "    \ rS rSrSrSSS.rSrg)	FieldType   zF
Original Name: None
Source: http://www.secg.org/sec1-v2.pdf page 101
prime_fieldcharacteristic_two_field)z1.2.840.10045.1.1z1.2.840.10045.1.2r)   Nr<   r)   r2   r3   r   r      s     +7Dr2   r   c                   $    \ rS rSrSrSSSS.rSrg)	CharacteristicTwoBasis   zF
Original Name: None
Source: http://www.secg.org/sec1-v2.pdf page 102
gn_basistp_basispp_basis)z1.2.840.10045.1.2.1.1z1.2.840.10045.1.2.1.2z1.2.840.10045.1.2.1.3r)   Nr<   r)   r2   r3   r   r      s     ",!+!+Dr2   r   c                   .    \ rS rSrSrS\4S\4S\4/rSrg)Pentanomial   2
Source: http://www.secg.org/sec1-v2.pdf page 102
k1k2k3r)   Nr*   r)   r2   r3   r   r      s%    
 
w	w	wGr2   r   c                   >    \ rS rSrSrS\4S\4S\4/rSr	\
\\S.rSrg	)
CharacteristicTwo   zT
Original Name: Characteristic-two
Source: http://www.secg.org/sec1-v2.pdf page 101
mbasis
parameters)r   r   )r   r   r   r)   N)r+   r,   r-   r.   r/   r   r   r   r0   	_oid_pairr   r   
_oid_specsr1   r)   r2   r3   r   r      s?     
g	()	sG (IJr2   r   c                   6    \ rS rSrSrS\4S\4/rSr\	\
S.rSrg)	FieldIDi  z2
Source: http://www.secg.org/sec1-v2.pdf page 100

field_typer   )r   r   )r   r   r)   N)r+   r,   r-   r.   r/   r   r   r0   r   r   r   r   r1   r)   r2   r3   r   r     s4    
 
y!	sG
 -I$5Jr2   r   c                   4    \ rS rSrSrS\4S\4S\SS04/rSrg	)
Curvei$  r   abseedrJ   Tr)   N)	r+   r,   r-   r.   r/   r   r   r0   r1   r)   r2   r3   r   r   $  s/    
 
k	k	*d!34Gr2   r   c            
       R    \ rS rSrSrS\4S\4S\4S\4S\	4S\	S	S
04S\
S	S
04/rSrg)SpecifiedECDomaini0  z2
Source: http://www.secg.org/sec1-v2.pdf page 103
rA   field_idcurvebaseordercofactorrJ   Thashr)   N)r+   r,   r-   r.   r/   r   r   r   r|   r   r   r0   r1   r)   r2   r3   r   r   0  sW    
 
,-	W	%		'	Wz401	:t"45Gr2   r   c                      \ rS rSrSr0 SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S$_0 S%S&_S'S(_S)S*_S+S,_S-S._S/S0_S1S2_S3S4_S5S6_S7S8_S9S:_S;S<_S=S>_S?S@_SASB_SCSD_SESF_E0 SGSH_SISJ_SKSL_SMSN_SOSP_SQSR_SSST_SUSV_SWSX_SYSZ_S[S\_S]S^_S_S`_SaSb_ScSd_SeSf_SgSh_E0 SiSj_SkSl_SmSn_SoSp_SqSr_SsSt_SuSv_SwSx_SySz_S{S|_S}S~_SS_SS_SS_SS_SS_SS_ESSSSS.Er0 SS_SS_SS_S	S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S!S_S#S_0 S%S_S'S_S)S_S+S_S-S_S/S_S1S_S3S_S5S_S7S_S9S_S;S_S=S_S?S_SAS_SCS_SES_E0 SGS_SIS_SKS_SMS_SOS_SQS_SSS_SUS_SWS_SYS_S[S_S]S_S_S_SaS_ScS_SeS_SgS_E0 SiS_SkS_SmS_SoS_SqS_SsS_SuS_SwS_SyS_S{S_S}S_SS_SS_SS_SS_SS_SS_ESSSSS.Er\S 5       rSr	g)
NamedCurvei@  z
Various named curves

Original Name: None
Source: https://tools.ietf.org/html/rfc3279#page-23,
        https://tools.ietf.org/html/rfc5480#page-5
z1.2.840.10045.3.0.1
c2pnb163v1z1.2.840.10045.3.0.2
c2pnb163v2z1.2.840.10045.3.0.3
c2pnb163v3z1.2.840.10045.3.0.4
c2pnb176w1z1.2.840.10045.3.0.5
c2tnb191v1z1.2.840.10045.3.0.6
c2tnb191v2z1.2.840.10045.3.0.7
c2tnb191v3z1.2.840.10045.3.0.8
c2onb191v4z1.2.840.10045.3.0.9
c2onb191v5z1.2.840.10045.3.0.10
c2pnb208w1z1.2.840.10045.3.0.11
c2tnb239v1z1.2.840.10045.3.0.12
c2tnb239v2z1.2.840.10045.3.0.13
c2tnb239v3z1.2.840.10045.3.0.14
c2onb239v4z1.2.840.10045.3.0.15
c2onb239v5z1.2.840.10045.3.0.16
c2pnb272w1z1.2.840.10045.3.0.17
c2pnb304w1z1.2.840.10045.3.0.18
c2tnb359v1z1.2.840.10045.3.0.19
c2pnb368w1z1.2.840.10045.3.0.20
c2tnb431r1z1.2.840.10045.3.1.2
prime192v2z1.2.840.10045.3.1.3
prime192v3z1.2.840.10045.3.1.4
prime239v1z1.2.840.10045.3.1.5
prime239v2z1.2.840.10045.3.1.6
prime239v3z1.2.840.10045.3.1.1	secp192r1z1.2.840.10045.3.1.7	secp256r1z1.3.132.0.1	sect163k1z1.3.132.0.2	sect163r1z1.3.132.0.3	sect239k1z1.3.132.0.4	sect113r1z1.3.132.0.5	sect113r2z1.3.132.0.6	secp112r1z1.3.132.0.7	secp112r2z1.3.132.0.8	secp160r1z1.3.132.0.9	secp160k1z1.3.132.0.10	secp256k1z1.3.132.0.15	sect163r2z1.3.132.0.16	sect283k1z1.3.132.0.17	sect283r1z1.3.132.0.22	sect131r1z1.3.132.0.23	sect131r2z1.3.132.0.24	sect193r1z1.3.132.0.25	sect193r2z1.3.132.0.26	sect233k1z1.3.132.0.27	sect233r1z1.3.132.0.28	secp128r1z1.3.132.0.29	secp128r2z1.3.132.0.30	secp160r2z1.3.132.0.31	secp192k1z1.3.132.0.32	secp224k1z1.3.132.0.33	secp224r1z1.3.132.0.34	secp384r1z1.3.132.0.35	secp521r1z1.3.132.0.36	sect409k1z1.3.132.0.37	sect409r1z1.3.132.0.38	sect571k1z1.3.132.0.39	sect571r1z1.3.36.3.3.2.8.1.1.1brainpoolp160r1z1.3.36.3.3.2.8.1.1.2brainpoolp160t1z1.3.36.3.3.2.8.1.1.3brainpoolp192r1z1.3.36.3.3.2.8.1.1.4brainpoolp192t1z1.3.36.3.3.2.8.1.1.5brainpoolp224r1z1.3.36.3.3.2.8.1.1.6brainpoolp224t1z1.3.36.3.3.2.8.1.1.7brainpoolp256r1z1.3.36.3.3.2.8.1.1.8brainpoolp256t1z1.3.36.3.3.2.8.1.1.9brainpoolp320r1z1.3.36.3.3.2.8.1.1.10brainpoolp320t1brainpoolp384r1brainpoolp384t1brainpoolp512r1brainpoolp512t1)z1.3.36.3.3.2.8.1.1.11z1.3.36.3.3.2.8.1.1.12z1.3.36.3.3.2.8.1.1.13z1.3.36.3.3.2.8.1.1.14            !   %   r$   5             $               0   B   3   4   H      (   @   c                 r    XR                   U'   U R                  b  X R                  U'   X0R                  U'   g)a0  
Registers a new named elliptic curve that is not included in the
default list of named curves

:param name:
    A unicode string of the curve name

:param oid:
    A unicode string of the dotted format OID

:param key_size:
    An integer of the number of bytes the private key should be
    encoded to
N)r=   _reverse_map
_key_sizes)rc   nameoidkey_sizes       r3   registerNamedCurve.register  s5    " '%(T"&sr2   r)   N)
r+   r,   r-   r.   r/   r=   r  rz   r  r1   r)   r2   r3   r   r   @  s   M|M 	|M 	|	M
 	|M 	|M 	|M 	|M 	|M 	|M 	M 	M 	M 	M 	M  	!M" 	#M$ 	%M& 	'M( 	)M* 	+M, 	|-M. 	|/M0 	|1M2 	|3M4 	|5M: 	{;M< 	{=M> 	{?M@ 	{AMB 	{CMD 	{EMF 	{GMH 	{IMJ 	{KML 	{MMN 	{OMP 	QMR 	SMT 	UMV 	WMX 	YMZ 	[M\ 	]M^ 	_M` 	aMb 	cMd 	eMf 	gMh 	iMj 	kMl 	mMn 	oMp 	qMr 	sMt 	uMv 	wMx 	yMz 	{M~ 	 1M@ 	 1AMB 	 1CMD 	 1EMF 	 1GMH 	 1IMJ 	 1KML 	 1MMN 	 1OMP 	 !2QMR "3!2!2!2YMD^Q 	rQ 	r	Q
 	rQ 	rQ 	rQ 	rQ 	rQ 	rQ 	rQ 	Q 	Q 	Q 	Q  	!Q" 	#Q$ 	%Q& 	'Q( 	)Q* 	+Q, 	-Q. 	r/Q0 	r1Q2 	r3Q4 	r5Q6 	r7Q> 	r?Q@ 	rAQB 	rCQD 	rEQF 	rGQH 	rIQJ 	rKQL 	rMQN 	rOQP 	rQQR 	rSQT 	UQV 	WQX 	YQZ 	[Q\ 	]Q^ 	_Q` 	aQb 	cQd 	eQf 	gQh 	iQj 	kQl 	mQn 	oQp 	qQr 	sQt 	uQv 	wQx 	yQz 	{Q| 	}Q~ 	QF 	GQH 	IQJ 	KQL 	MQN 	OQP 	QQR 	SQT 	UQV 	WQX 	 YQZ "$!#!#!#aQJf ' 'r2   r   c                   >    \ rS rSrSrS\4S\4S\4/r\	S 5       r
Srg)	ECDomainParametersi  r   	specifiednamedimplicit_cac                    U R                   S:X  a  [        [        S5      5      eU R                   S:X  aG  U R                  S   R                  n[
        R                  " [
        R                  " US5      S-  5      $ U R                  R                  nU[        R                  ;  a  [        [        S[        U5      5      5      e[        R                  U   $ )Nr"  z
                Unable to calculate key_size from ECDomainParameters
                that are implicitly defined by the CA key
                r   r   g       @r[   z
                The asn1crypto.keys.NamedCurve %s does not have a registered key length,
                please call asn1crypto.keys.NamedCurve.register()
                )r  rr   r   chosenro   r_   r`   ra   dottedr   r  repr)rs   r   r  s      r3   r  ECDomainParameters.key_size  s    99%V   99#KK(//E99TXXeS1C788kk  j+++V S	   $$S))r2   r)   N)r+   r,   r-   r.   r/   r   r   r   _alternativespropertyr  r1   r)   r2   r3   r  r    s=    
 
'(	*	M * *r2   r  c                        \ rS rSrSrSS0rSrg)ECPrivateKeyVersioni'  zF
Original Name: None
Source: http://www.secg.org/sec1-v2.pdf page 108
r   ecPrivkeyVer1r)   Nr<   r)   r2   r3   r+  r+  '  s     	
?Dr2   r+  c                   h   ^  \ rS rSrSrS\4S\4S\SSS.4S	\S
SS.4/r	Sr
U 4S jrS rS rSrU =r$ )ECPrivateKeyi2  z2
Source: http://www.secg.org/sec1-v2.pdf page 108
rA   rU   r   r   T)explicitrJ   rT   r   Nc                   > [         [        U ]  X5      nUS:X  a  U R                  c\  U S   R                  n[        U[        5      (       a6  [        U5      S:  a'  U R                  [        U S   R                  5      5        U$ U R                  b  U R                  5         U$ US:X  aI  [        U S   [        5      (       a1  U S   R                  S:w  a  U R                  U S   R                  5        U$ )NrU   r   r   r"  )superr.  __setitem__	_key_sizecontents
isinstancer   rp   set_key_size_update_key_sizer  r  r  )rs   keyvaluerespkey_contents	__class__s        r3   r2  ECPrivateKey.__setitem__B  s    L$3C?-~~% $] 3 < <mX663};MPQ;Q%%c$}*=*F*F&GH 
 +%%' 
	 L Z\0BDV%W%W\"''=8d<099:
r2   c                 0    Xl         U R                  5         g)z
Sets the key_size to ensure the private key is encoded to the proper length

:param key_size:
    An integer byte length to encode the private_key to
N)r3  r7  )rs   r  s     r3   r6  ECPrivateKey.set_key_sizeU  s     "r2   c                     U R                   b8  [        U S   [        5      (       a  U S   R                  U R                   5        ggg)z7
Ensure the private_key explicit encoding width is set
NrU   )r3  r5  r   set_encoded_widthrs   s    r3   r7  ECPrivateKey._update_key_size`  s@    
 >>%*T-5HJ\*]*]11$..A +^%r2   )r3  )r+   r,   r-   r.   r/   r+  r   r  r   r0   r3  r2  r6  r7  r1   __classcell__r<  s   @r3   r.  r.  2  s`    
 
'(	*+	)t+LM	'aT)JK	G I&	 B Br2   r.  c                   .    \ rS rSrSrS\4S\4S\4/rSrg)	DSAParamsii  zy
Parameters for a DSA public or private key

Original Name: Dss-Parms
Source: https://tools.ietf.org/html/rfc3279#page-9
rQ   rR   rS   r)   Nr*   r)   r2   r3   rG  rG  i  s%     
g	g	gGr2   rG  c                   .    \ rS rSrSrS\4S\S\04/rSr	g)	Attributeix  zi
Source: https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.501-198811-S!!PDF-E&type=items page 8
typevaluesspecr)   N)
r+   r,   r-   r.   r/   r   r   r   r0   r1   r)   r2   r3   rI  rI  x  s'    
 
!"	563-(Gr2   rI  c                       \ rS rSrSr\rSrg)
Attributesi  4
Source: https://tools.ietf.org/html/rfc5208#page-3
r)   N)r+   r,   r-   r.   r/   rI  r7   r1   r)   r2   r3   rN  rN    s     Kr2   rN  c            	       .    \ rS rSrSrSSSSSSS	S
S.rSrg)PrivateKeyAlgorithmIdi  z
These OIDs for various public keys are reused when storing private keys
inside of a PKCS#8 structure

Original Name: None
Source: https://tools.ietf.org/html/rfc3279
rsa
rsassa_pssdsaecx25519x448ed25519ed448)1.2.840.113549.1.1.11.2.840.113549.1.1.101.2.840.10040.4.11.2.840.10045.2.11.3.101.1101.3.101.1111.3.101.1121.3.101.113r)   Nr<   r)   r2   r3   rQ  rQ    s(     !&!-"! Dr2   rQ  c                   >    \ rS rSrSrS\4S\SS04/rSr\	\
\S.rS	rg
)PrivateKeyAlgorithmi  za
Original Name: PrivateKeyAlgorithmIdentifier
Source: https://tools.ietf.org/html/rfc5208#page-3
	algorithmr   rJ   Trd  r   )rT  rU  rS  r)   N)r+   r,   r-   r.   r/   rQ  r   r0   r   rG  r  r   r   r1   r)   r2   r3   rc  rc    s?     
+,	sZ./G
 ,I %Jr2   rc  c                     ^  \ rS rSrSrS\4S\4S\4S\SSS	.4/r	S
 r
S\
0rSrSrSrSr\S 5       rU 4S jrS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrU =r$ )PrivateKeyInfoi  rO  rA   private_key_algorithmrU   
attributesr   T)implicitrJ   c           	          U S   S   R                   n[        [        [        [        [        [        [        [        S.U   $ )Nrh  rd  )rR  rS  rT  rU  rV  rW  rX  rY  )ro   r?   r   r.  r   rs   rd  s     r3   _private_key_spec PrivateKeyInfo._private_key_spec  sF    01+>EE	 ' "" 
  	r2   Nc                 :   [        U[        5      (       d3  [        U[        5      (       d  [        [	        S[        U5      5      5      eUS:X  d  US:X  a5  [        U[        5      (       d  [        R                  U5      n[        5       nOUS:X  aW  [        U[        5      (       d  [        R                  U5      n[        5       nUS   US'   US   US'   US   US'   US   nUS	   nOhUS
:X  aD  [        U[        5      (       d  [        R                  U5      nOUR                  5       nUS   nUS	 O[        [	        S[        U5      5      5      e[        5       n[!        U5      US'   X5S'   U " 5       nX&l        [%        S5      US'   XVS'   XS	'   US:X  a  WUl        U$ )z
Wraps a private key in a PrivateKeyInfo structure

:param private_key:
    A byte string or Asn1Value object of the private key

:param algorithm:
    A unicode string of "rsa", "dsa" or "ec"

:return:
    A PrivateKeyInfo object
zX
                private_key must be a byte string or Asn1Value, not %s
                rR  rS  rT  rQ   rR   rS   rT   rU   rU  r   zU
                algorithm must be one of "rsa", "dsa", "ec", not %s
                rd  r   rA   rh  )r5  r   r   	TypeErrorr   r
   r?   loadr   rO   rG  r.  copyrr   r&  rc  rQ  
_algorithmr   _public_key)rc   rU   rd  paramsrT   private_key_algo	containers          r3   wrapPrivateKeyInfo.wrap  s    +x00KQZ9[9[F +&	   l!:k=99+00=VF%k=99+00=[F%c*F3K%c*F3K%c*F3K$\2J%m4K$k<88*//<)..0 .FL)V Y	   /0(=i(H%)/&E	(&qz	)-=)*#.-  $.I!r2   c                   > [         [        U ]  X5      nU S   nUS:X  d  US:X  a  US   R                  S:X  a  [	        US   [
        5      (       ax  US   R                  S:w  ae  [	        U S   [        5      (       aM  [	        U S   R                  [        5      (       a+  U S   R                  R                  US   R                  5        U$ )Nrh  rU   rd  rU  r   r"  )r1  rg  r2  ro   r5  r  r  r   parsedr.  r6  r  )rs   r8  r9  r:  rd  r<  s        r3   r2  PrivateKeyInfo.__setitem__"  s    ND5cA01	 **c].B+&--59\24FGG,',,=4.0CDD4.55|DD&&33Il4K4T4TU
r2   c                     [        S5      e)z
Unwraps the private key into an RSAPrivateKey, DSAPrivateKey or
ECPrivateKey object

:return:
    An RSAPrivateKey, DSAPrivateKey or ECPrivateKey object
zxasn1crypto.keys.PrivateKeyInfo().unwrap() has been removed, please use oscrypto.asymmetric.PrivateKey().unwrap() insteadr	   rB  s    r3   r   PrivateKeyInfo.unwrap3  s     KL 	Lr2   c                     U R                   S:w  a-  [        [        SU R                   R                  5       5      5      eU S   S   nUR                  nUR
                  S:X  a  SnOUR                  nUR
                  U4$ )  
Returns information about the curve used for an EC key

:raises:
    ValueError - when the key is not an EC key

:return:
    A two-element tuple, with the first element being a unicode string
    of "implicit_ca", "specified" or "named". If the first element is
    "implicit_ca", the second is None. If "specified", the second is
    an OrderedDict that is the native version of SpecifiedECDomain. If
    "named", the second is a unicode string of the curve name.
rU  K
                Only EC keys have a curve, this key is %s
                rh  r   r"  Nrd  rr   r   upperr$  r  ro   rs   ru  r$  r9  s       r3   r   PrivateKeyInfo.curve@  s      >>T!V $$&	   -.|<;;-'EMMEU##r2   c                     U R                   S:w  a-  [        [        SU R                   R                  5       5      5      e[        R
                  " U S   S   S   R                  S5      S-  nUS::  a  S	$ S
$ )z
Returns the name of the family of hash algorithms used to generate a
DSA key

:raises:
    ValueError - when the key is not a DSA key

:return:
    A unicode string of "sha1" or "sha2"
rT  t
                Only DSA keys are generated using a hash algorithm, this key is
                %s
                rh  r   rR   rZ      r  sha1sha2)rd  rr   r   r  r_   ra   ro   )rs   byte_lens     r3   	hash_algoPrivateKeyInfo.hash_algob  s{     >>U"V $$&   88D!89,GLSSUVWZ[[!Rv3V3r2   c                 b    U R                   c  U S   S   R                  U l         U R                   $ )E
:return:
    A unicode string of "rsa", "rsassa_pss", "dsa" or "ec"
rh  rd  rs  ro   rB  s    r3   rd  PrivateKeyInfo.algorithm|  s0     ??""#:;KHOODOr2   c                    U R                   c  U R                  S:X  d  U R                  S:X  a  U S   R                  S   R                  nORU R                  S:X  a  U S   S   S   R                  nO,U R                  S	:X  a  U S   R                  S   R                  n[	        [
        R                  " [
        R                  " WS
5      5      5      U l         U R                   S-  nUS:w  a  U =R                   SU-
  -  sl         U R                   $ )z=
:return:
    The bit size of the private key, as an integer
rR  rS  rU   rB   rT  rh  r   rQ   rU  rZ   r  r   )	_bit_sizerd  r{  ro   r^   r_   r`   ra   rs   r&   rB   s      r3   bit_sizePrivateKeyInfo.bit_size  s     >>!~~&$..L*H]+229=DD5(45lCCHOO4']+22=AHH 488E1+=!>?DNnnq(G!|!g+-~~r2   c                 Z    [        [        R                  " U R                  S-  5      5      $ )z>
:return:
    The byte size of the private key, as an integer
r  r^   r_   r`   r  rB  s    r3   	byte_sizePrivateKeyInfo.byte_size  !     499T]]Q./00r2   c                     [        S5      e)z
:return:
    If an RSA key, an RSAPublicKey object. If a DSA key, an Integer
    object. If an EC key, an ECPointBitString object.
zasn1crypto.keys.PrivateKeyInfo().public_key has been removed, please use oscrypto.asymmetric.PrivateKey().public_key.unwrap() insteadr~  rB  s    r3   rT   PrivateKeyInfo.public_key  s     VW 	Wr2   c                     [        S5      e)zD
:return:
    A PublicKeyInfo object derived from this private key.
zasn1crypto.keys.PrivateKeyInfo().public_key_info has been removed, please use oscrypto.asymmetric.PrivateKey().public_key.asn1 insteadr~  rB  s    r3   public_key_infoPrivateKeyInfo.public_key_info  s     RS 	Sr2   c                     [        S5      e)a  
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)
z~asn1crypto.keys.PrivateKeyInfo().fingerprint has been removed, please use oscrypto.asymmetric.PrivateKey().fingerprint insteadr~  rB  s    r3   fingerprintPrivateKeyInfo.fingerprint  s     NO 	Or2   )rs  r  )r+   r,   r-   r.   r/   r   rc  r   rN  r0   rm  _spec_callbacksrs  r  rt  _fingerprintrz   rx  r2  r   r)  r   r  rd  r  r  rT   r  r  r1   rD  rE  s   @r3   rg  rg    s+   
 
G	 "56	+,	zt#DE	G  	(O JIKLA AJ"L $ $B 4 42    & 1 1 	W 	W S S O Or2   rg  c                   (    \ rS rSrSrS\4S\4/rSrg)EncryptedPrivateKeyInfoi  z4
Source: https://tools.ietf.org/html/rfc5208#page-4
encryption_algorithmencrypted_datar)   N)	r+   r,   r-   r.   r/   r   r   r0   r1   r)   r2   r3   r  r    s!    
 
 !45	;'Gr2   r  c                   (    \ rS rSrSrS\4S\4/rSrg)ValidationParmsi  5
Source: https://tools.ietf.org/html/rfc3279#page-10
r   pgen_counterr)   N)	r+   r,   r-   r.   r/   r   r   r0   r1   r)   r2   r3   r  r    s     
 
	!Gr2   r  c                   F    \ rS rSrSrS\4S\4S\4S\SS04S	\SS04/rS
rg)DomainParametersi  r  rQ   rS   rR   jrJ   Tvalidation_paramsr)   N)	r+   r,   r-   r.   r/   r   r  r0   r1   r)   r2   r3   r  r    sC    
 
g	g	g	g
D)*	o
D/ABGr2   r  c                   2    \ rS rSrSrSSSSSSS	S
SSS.
rSrg)PublicKeyAlgorithmIdi  zA
Original Name: None
Source: https://tools.ietf.org/html/rfc3279
rR  
rsaes_oaeprS  rT  rU  dhrV  rW  rX  rY  )
rZ  z1.2.840.113549.1.1.7r[  r\  r]  z1.2.840.10046.2.1r^  r_  r`  ra  r)   Nr<   r)   r2   r3   r  r    s.     !& ,!-"!! #Dr2   r  c                   B    \ rS rSrSrS\4S\SS04/rSr\	\
\\\S.rS	rg
)PublicKeyAlgorithmi  zX
Original Name: AlgorithmIdentifier
Source: https://tools.ietf.org/html/rfc5280#page-18
rd  r   rJ   Tre  )rT  rU  r  r  rS  r)   N)r+   r,   r-   r.   r/   r  r   r0   r   rG  r  r  r   r   r   r1   r)   r2   r3   r  r    sE     
*+	sZ./G
 ,I %%Jr2   r  c                       \ rS rSrSrS\4S\4/rS rS\0r	Sr
SrSrSrSr\S 5       rS r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrg)PublicKeyInfoi$  zY
Original Name: SubjectPublicKeyInfo
Source: https://tools.ietf.org/html/rfc5280#page-17
rd  rT   c                     U S   S   R                   n[        [        [        [        [        S 4[        [        S 4[        S 4[        S 4[        S 4S.
U   $ )Nrd  )
rR  r  rS  rT  rU  r  rV  rW  rX  rY  )ro   rL   r   r   r   rl  s     r3   _public_key_specPublicKeyInfo._public_key_spec/  sf    %k299	&& $T* &t,#T*&-$d+
  	r2   Nc                    [        U[        5      (       d3  [        U[        5      (       d  [        [	        S[        U5      5      5      eUS:w  a$  US:w  a  [        [	        S[        U5      5      5      e[        5       n[        U5      US'   [        5       US'   U " 5       nX4S'   [        U[        5      (       a  UR                  5       R                  5       n[        U5      US'   U$ )z
Wraps a public key in a PublicKeyInfo structure

:param public_key:
    A byte string or Asn1Value object of the public key

:param algorithm:
    A unicode string of "rsa"

:return:
    A PublicKeyInfo object
zW
                public_key must be a byte string or Asn1Value, not %s
                rR  rS  z>
                algorithm must "rsa", not %s
                rd  r   rT   )r5  r   r   rp  r   r
   rr   r&  r  r  r   untagdumpr   )rc   rT   rd  algorw  s        r3   rx  PublicKeyInfo.wrapL  s     *h//
:y8Y8YF *%	   )|";V Y	   "#0;[!V\E	!%+j),,#))+002J"8"D	,r2   c                     [        S5      e)z
Unwraps an RSA public key into an RSAPublicKey object. Does not support
DSA or EC public keys since they do not have an unwrapped form.

:return:
    An RSAPublicKey object
zvasn1crypto.keys.PublicKeyInfo().unwrap() has been removed, please use oscrypto.asymmetric.PublicKey().unwrap() insteadr~  rB  s    r3   r   PublicKeyInfo.unwrapw  s     JK 	Kr2   c                     U R                   S:w  a-  [        [        SU R                   R                  5       5      5      eU S   S   nUR                  nUR
                  S:X  a  SnOUR                  nUR
                  U4$ )r  rU  r  rd  r   r"  Nr  r  s       r3   r   PublicKeyInfo.curve  s~      >>T!V $$&	   k"<0;;-'EMMEU##r2   c                 
   U R                   S:w  a-  [        [        SU R                   R                  5       5      5      eU S   S   nUR                  c  g[
        R                  " US   R                  S5      S-  nUS	::  a  S
$ S$ )z
Returns the name of the family of hash algorithms used to generate a
DSA key

:raises:
    ValueError - when the key is not a DSA key

:return:
    A unicode string of "sha1" or "sha2" or None if no parameters are
    present
rT  r  rd  r   NrR   rZ   r  r  r  r  )rd  rr   r   r  ro   r_   ra   )rs   r   r  s      r3   r  PublicKeyInfo.hash_algo  s     >>U"V $$&   +&|4
$88JsO22A6:!Rv3V3r2   c                 b    U R                   c  U S   S   R                  U l         U R                   $ )r  rd  r  rB  s    r3   rd  PublicKeyInfo.algorithm  s/     ??"";/<CCDOr2   c                 \   U R                   Gc  U R                  S:X  a;  [        [        U S   R                  5      S-
  S-  S-  5      U l         U R                   $ U R                  S:X  d  U R                  S:X  a  U S   R
                  S   R                  nO%U R                  S	:X  a  U S
   S   S   R                  n[        [        R                  " [        R                  " WS5      5      5      U l         U R                   S-  nUS:w  a  U =R                   SU-
  -  sl         U R                   $ )z<
:return:
    The bit size of the public key, as an integer
rU  rT   r   rZ   r  rR  rS  rB   rT  rd  r   rQ   r   )	r  rd  r^   rp   ro   r{  r_   r`   ra   r  s      r3   r  PublicKeyInfo.bit_size  s     >>!~~%!$s4+=+D+D'E'IQ&NRS%S!T ~~ >>U*dnn.L .55i@GGE^^u, -l;C@GGE!$TYYtxxq/A%B!C..1,a<NNa'k1N~~r2   c                 Z    [        [        R                  " U R                  S-  5      5      $ )z=
:return:
    The byte size of the public key, as an integer
r  r  rB  s    r3   r  PublicKeyInfo.byte_size  r  r2   c                     U R                   c5  [        R                  " [        U S   5      5      R	                  5       U l         U R                   $ )zM
:return:
    The SHA1 hash of the DER-encoded bytes of this public key info
rT   )_sha1hashlibr  r   digestrB  s    r3   r  PublicKeyInfo.sha1  s;     :: htL/A&BCJJLDJzzr2   c                     U R                   c5  [        R                  " [        U S   5      5      R	                  5       U l         U R                   $ )zP
:return:
    The SHA-256 hash of the DER-encoded bytes of this public key info
rT   )_sha256r  sha256r   r  rB  s    r3   r  PublicKeyInfo.sha256  s;     <<">>(43E*FGNNPDL||r2   c                     [        S5      e)a  
Creates a fingerprint that can be compared with a private 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)
z|asn1crypto.keys.PublicKeyInfo().fingerprint has been removed, please use oscrypto.asymmetric.PublicKey().fingerprint insteadr~  rB  s    r3   r  PublicKeyInfo.fingerprint  s     MN 	Nr2   )rs  r  r  r  )r+   r,   r-   r.   r/   r  r   r0   r  r  rs  r  r  r  r  rz   rx  r   r)  r   r  rd  r  r  r  r  r  r1   r)   r2   r3   r  r  $  s    
()	-.G
( 	&O JILEG( (TK $ $B 4 4<    * 1 1     N Nr2   r  )Hr/   
__future__r   r   r   r   r  r_   _errorsr   r	   _typesr
   r   algosr   r   r   r   r   corer   r   r   r   r   r   r   r   r   r   r   r   r   r   r   utilr    r!   r#   r5   r9   r?   rL   rO   rW   r|   r   r   r   r   r   r   r   r   r   r   r  r+  r.  rG  rI  rN  rQ  rc  rg  r  r  r  r  r  r  r)   r2   r3   <module>r     s   S R   ) ' o o    " /	X 	!j !	7 	H &8 H (C CL	k8 	
	~x 	
w 	  	
- 
	( 	 (h "	H 	  '! 'D"* "*J' 4B8 4Bn   , 4. &SOX SOlh h x + 6-x *qNH qNr2   