+
    Ai*                     Z   ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHtHt ]P0                  P3                  ]P4                  4       ] P6                  ! R	4      t] P6                  ! R
4      tRtR tRt R t!RR lt"R t# ! R R]4      t$R# )    N)PyAsn1Error)DecryptionError)rsa_private_key_pkcs1_to_pkcs8rsa_private_key_pkcs8_to_pkcs1rsa_public_key_pkcs1_to_pkcs8)Key)
ALGORITHMS)JWEErrorJWKError)base64_to_longlong_to_base64,308204BD020100300D06092A864886F70D010101050030z1.2.840.113549.1.1.1c                ,    V'       d   YV,          rK  V # )zCalculate the Greatest Common Divisor of a and b.

Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
 )abs   &&W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/jose/backends/rsa_backend.py_gcdr   &   s     q51H    i  c                   W!,          ^,
          pTpV^,          ^ 8X  d   V^,          pK  Rp^pV'       gr   V\         8  dg   TpWs8  dT   \        WgV 4      pV^8w  d6   W^,
          8w  d)   \        V^V 4      ^8X  d   \        V^,           V 4      p	RpMV^,          pKY  V^,          pKy  V'       g   \        R4      h\	        V X	4      w  rV^ 8X  g   Q h\        W3RR7      w  rW3# )z
Compute factors p and q from the private exponent d. We assume that n has
no more than two factors. This function is adapted from code in PyCrypto.
FTz2Unable to compute factors p and q from exponent d.)reverse)_MAX_RECOVERY_ATTEMPTSpowr   
ValueErrordivmodsorted)nedktottspottedr   kcandpqrs   &&&         r   _rsa_recover_prime_factorsr)   7   s     519D 	A
a%1*F G	A!44hqQ<DqyT!e_T1aA1E 1%FA	QMNN!Q<DA6M61&$'DA6Mr   c                 X    \        V \        P                  4      pVP                  V4      # N)RSAKeyr	   RS256to_pem)pemfmtkeys   && r   pem_to_spkir2   b   s"    
j&&
'C::c?r   c                    V P                  \        \        ,           4      '       g   \        R4      hV \	        \        4      R # )zLegacy RSA private key PKCS8-to-PKCS1 conversion.

.. warning::

    This is incorrect parsing and only works because the legacy PKCS1-to-PKCS8
    encoding was also incorrect.
zInvalid private key encodingN)
startswithLEGACY_INVALID_PKCS8_RSA_HEADERASN1_SEQUENCE_IDr   len)	pkcs8_keys   &r   "_legacy_private_key_pkcs8_to_pkcs1r9   g   s<      ?BR RSS788S89;<<r   c                   l   a  ] tR t^xt o RtRtRtR tR tR t	R t
R tR	 tRR
 ltR tR tR tRtV tR# )r,   zSHA-256zSHA-384zSHA-512c                f   V\         P                  9  d   \        R V,          4      hV\         P                  9   d(   V\         P                  8w  d   \        RV,          4      h\         P
                  V P                  \         P                  V P                  \         P                  V P                  /P                  V4      V n        W n        \        V\        4      '       d   V P!                  V4      V n        R# \        V\$        P&                  \$        P(                  34      '       d	   Wn        R# \        V\*        4      '       d   VP-                  R4      p\        V\.        4      '       d(    \$        P&                  P1                  V4      V n        R# \        RV,          4      h  \2         d     \$        P&                  P5                  T4      T n         R#   \2         d     \$        P(                  P1                  T4      T n         M  \2         d     \6        P8                  ! TR4      p \;        T4      pM  \<         d    \?        T4      p Mi ; i\$        P(                  P1                  TRR7      T n           R#   \2         d   p\        T4      hRp?ii ; ii ; ii ; i R# i ; i)z*hash_alg: %s is not a valid hash algorithmz+alg: %s is not supported by the RSA backendNzutf-8s   PRIVATE KEYDERformatz'Unable to parse an RSA_JWK from key: %s) r	   RSAr   RSA_KWRSA1_5r-   SHA256RS384SHA384RS512SHA512gethash_alg
_algorithm
isinstancedict_process_jwk_prepared_keypyrsa	PublicKey
PrivateKeystrencodebytes
load_pkcs1r   load_pkcs1_openssl_pem	pyrsa_pemload_pemr   r   r9   )selfr1   	algorithmder	pkcs1_keyr   s   &&&   r   __init__RSAKey.__init__}   s:   JNN*G)STT
)))i:;L;L.LH9TUU dkkdkkdkk
 #i.	 	
 $c4  !%!2!23!7DcEOOU-=-=>??!$c3**W%Cc5!!.%*__%?%?%D"( @3FGG)  ..).)O)OPS)TD&" ! " ..-2-=-=-H-H-M*% .."+"4"4S."ICT,J3,O	#. T -Os,S		T
 271A1A1L1LY_d1L1eD.   * ."*1+-...* '.s   2$F* *J06$GJ))$HJ0J%J3H?>J?I	JI	)JJ)J0J!	J	J!	!J%%J))J0/J0c                0  a SP                  R 4      R8X  g"   \        RSP                  R 4      ,          4      h\        SP                  R4      4      p\        SP                  R4      4      pRS9  d   \        P                  ! W#R7      # \        SP                  R4      4      p. ROp\
        ;QJ d    V3R	 lV 4       F  '       g   K   R
M	  RM! V3R	 lV 4       4      '       d   \        ;QJ d    V3R lV 4       F  '       d   K   RM	  R
M! V3R lV 4       4      '       g   \        R4      h\        SR,          4      p\        SR,          4      p\        P                  ! W#WFVR7      # \        W2V4      w  rg\        P                  ! W2WFVR7      # )ktyr?   z1Incorrect key type. Expected: 'RSA', Received: %sr   r   r    )r   r   r&   r'   c              3   ,   <"   T F	  qS9   x  K  	  R # 5ir+   r   .0r$   jwk_dicts   & r   	<genexpr>&RSAKey._process_jwk.<locals>.<genexpr>   s     7,Q=,   TFc              3   ,   <"   T F	  qS9   x  K  	  R # 5ir+   r   ra   s   & r   rd   re      s     ?,Q=,rf   z2Precomputed private key parameters are incomplete.)r   r   r    r&   r'   )r   r   r    r&   r'   )r&   r'   dpdqqi)	rG   r   r   rN   rO   anyallrP   r)   )rX   rc   r   r   r    extra_paramsr&   r'   s   &f      r   rL   RSAKey._process_jwk   s+   ||E"e+NQYQ]Q]^cQddee8<<,-8<<,-h??Q,,x||C01A7Ls7,7sss7,777s?,?sss?,??? ##WXX"8C=1"8C=1''!Aa@@1!:''!Aa@@r   c                X    \         P                  ! WP                  V P                  4      # r+   )rN   signrM   rH   )rX   msgs   &&r   rp   RSAKey.sign   s    zz#114==AAr   c                    V P                  4       '       g   \        P                  ! R 4        \        P                  ! WV P
                  4       R#   \        P                  P                   d     R# i ; i)zKAttempting to verify a message with a private key. This is not recommended.TF)	is_publicwarningswarnrN   verifyrM   pkcs1VerificationError)rX   rq   sigs   &&&r   rw   RSAKey.verify   sT    ~~MMjk	LL4#5#56{{,, 		s   !A A43A4c                J    \        V P                  \        P                  4      # r+   )rJ   rM   rN   rO   rX   s   &r   rt   RSAKey.is_public   s    $,,eoo>>r   c                   \        V P                  \        P                  4      '       d   V # V P	                  \        P                  ! V P                  P
                  V P                  P                  R 7      V P                  4      # ))r   r   )rJ   rM   rN   rO   	__class__r   r   rI   r}   s   &r   
public_keyRSAKey.public_key   sY    d((%//::K~~eoo0B0B0D0DHZHZH\H\]_c_n_noor   c                n   \        V P                  \        P                  4      '       dy   V P                  P	                  R R7      pVR8X  d&   \        V4      p\        P                  ! VRR7      pV# VR8X  d   \        P                  ! VRR7      pV# \        RV: 24      hVR8X  dB   V P                  P	                  R R7      p\        V4      p\        P                  ! VRR7      pV# VR8X  d7   V P                  P	                  R R7      p\        P                  ! VR	R7      pV# \        RV: 24      h)
r<   r=   PKCS8zPRIVATE KEY)
pem_markerPKCS1zRSA PRIVATE KEYzInvalid pem format specified: z
PUBLIC KEYzRSA PUBLIC KEY)
rJ   rM   rN   rP   
save_pkcs1r   rV   save_pemr   r   )rX   
pem_formatrZ   	pkcs8_derr/   	pkcs1_ders   &&    r   r.   RSAKey.to_pem   s.   d((%*:*:;;$$//u/=CW$:3?	((}M 
 w&((9JK 
 !#A*!PQQW$ ..999G	9)D	((|L 
 w&((3353A((9IJ 
 !#A*!PQQr   c                   V P                  4       '       g   V P                  4       P                  pMV P                  pR V P                  RRR\	        VP
                  4      P                  R4      R\	        VP                  4      P                  R4      /pV P                  4       '       Eg&   VP                  R\	        V P                  P                  4      P                  R4      R\	        V P                  P                  4      P                  R4      R\	        V P                  P                  4      P                  R4      R	\	        V P                  P                  4      P                  R4      R
\	        V P                  P                  4      P                  R4      R\	        V P                  P                  4      P                  R4      /4       V# )algr_   r?   r   ASCIIr   r    r&   r'   rh   ri   rj   )rt   r   rM   rI   r   r   decoder   updater    r&   r'   exp1exp2coef)rX   r   datas   &  r   to_dictRSAKey.to_dict   sb   ~~*88J++J 4??5
-44W=
-44W=	
 ~~KK(:(:(<(<=DDWM(:(:(<(<=DDWM(:(:(<(<=DDWM.););)@)@AHHQ.););)@)@AHHQ.););)@)@AHHQ	 r   c                    V P                  4       '       g   \        P                  ! R 4       \        P                  ! WP
                  4      pV# )zLAttempting to encrypt a message with a private key. This is not recommended.)rt   ru   rv   rN   encryptrM   )rX   key_datawrapped_keys   && r   wrap_keyRSAKey.wrap_key  s6    ~~MMklmmH.@.@Ar   c                     \         P                  ! WP                  4      pV#   \         d   p\	        T4      hR p?ii ; ir+   )rN   decryptrM   r   r
   )rX   r   unwrapped_keyr   s   &&  r   
unwrap_keyRSAKey.unwrap_key  s?    	!MM+7I7IJM   	1+	s    $ ?:?)rI   rM   rH   Nr   )__name__
__module____qualname____firstlineno__rB   rD   rF   r\   rL   rp   rw   rt   r   r.   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r,   r,   x   sP     FFF0HdA8B?p
,6 r   r,   r   )%binasciiru   rsarN   rsa.pemr/   rV   pyasn1.errorr   r   jose.backends._asn1r   r   r   jose.backends.baser   jose.constantsr	   jose.exceptionsr
   r   
jose.utilsr   r   	SUPPORTEDremoveRSA_OAEP	unhexlifyr5   r6   RSA_ENCRYPTION_ASN1_OIDr   r   r)   r2   r9   r,   r   r   r   <module>r      s        $  
 # % . 5 
    J// 0"*"4"4#  %%d+ 0   (V
="cS cr   