
    #	h                       S SK Jr  S SKrS SKrS SKrS SKJr  S SKJr	  S SK
JrJr  S SKJr  S SKJr   " S S	\R$                  S
9r\r\R+                  \	R,                  R&                  5         " S S\R$                  S
9r\r\R+                  \	R,                  R.                  5        \	R,                  R2                  r\	R,                  R4                  r S       SS jjrSS jrSS jrSS jrSS jrSS jr SS jr!Sr"SS jr#g)    )annotationsN)gcd)openssl)_serializationhashes)AsymmetricPadding)utilsc                  .   \ rS rSr\R
                  S
S j5       r\\R
                  SS j5       5       r\R
                  SS j5       r	\R
                          SS j5       r
\R
                  SS j5       r\R
                          SS j5       rSrg	)RSAPrivateKey   c                    g)z#
Decrypts the provided ciphertext.
N )self
ciphertextpaddings      _/var/www/html/env/lib/python3.13/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.pydecryptRSAPrivateKey.decrypt           c                    gz'
The bit length of the public modulus.
Nr   r   s    r   key_sizeRSAPrivateKey.key_size   r   r   c                    g)z4
The RSAPublicKey associated with this private key.
Nr   r   s    r   
public_keyRSAPrivateKey.public_key    r   r   c                    g)z
Signs the data.
Nr   )r   datar   	algorithms       r   signRSAPrivateKey.sign&   r   r   c                    g)z
Returns an RSAPrivateNumbers.
Nr   r   s    r   private_numbersRSAPrivateKey.private_numbers1   r   r   c                    gz&
Returns the key serialized as bytes.
Nr   )r   encodingformatencryption_algorithms       r   private_bytesRSAPrivateKey.private_bytes7   r   r   r   N)r   bytesr   r   returnr.   r/   int)r/   RSAPublicKey)r    r.   r   r   r!   +asym_utils.Prehashed | hashes.HashAlgorithmr/   r.   )r/   RSAPrivateNumbers)r)   _serialization.Encodingr*   z_serialization.PrivateFormatr+   z)_serialization.KeySerializationEncryptionr/   r.   )__name__
__module____qualname____firstlineno__abcabstractmethodr   propertyr   r   r"   r%   r,   __static_attributes__r   r   r   r   r      s     
   
 	 
 	 # ?	
 
  	 
 	) - H	
 
 r   r   )	metaclassc                  f   \ rS rSr\R
                  SS j5       r\\R
                  SS j5       5       r\R
                  SS j5       r	\R
                        SS j5       r
\R
                            SS j5       r\R
                          SS j5       r\R
                  SS j5       rS	rg
)r2   G   c                    g)z
Encrypts the given plaintext.
Nr   )r   	plaintextr   s      r   encryptRSAPublicKey.encryptH   r   r   c                    gr   r   r   s    r   r   RSAPublicKey.key_sizeN   r   r   c                    g)z
Returns an RSAPublicNumbers
Nr   r   s    r   public_numbersRSAPublicKey.public_numbersU   r   r   c                    gr(   r   )r   r)   r*   s      r   public_bytesRSAPublicKey.public_bytes[   r   r   c                    g)z%
Verifies the signature of the data.
Nr   )r   	signaturer    r   r!   s        r   verifyRSAPublicKey.verifye   r   r   c                    g)z0
Recovers the original data from the signature.
Nr   )r   rN   r   r!   s       r   recover_data_from_signature(RSAPublicKey.recover_data_from_signatureq   r   r   c                    g)z
Checks equality.
Nr   )r   others     r   __eq__RSAPublicKey.__eq__|   r   r   r   N)rB   r.   r   r   r/   r.   r0   )r/   RSAPublicNumbers)r)   r5   r*   z_serialization.PublicFormatr/   r.   )
rN   r.   r    r.   r   r   r!   r3   r/   None)rN   r.   r   r   r!   zhashes.HashAlgorithm | Noner/   r.   )rU   objectr/   bool)r6   r7   r8   r9   r:   r;   rC   r<   r   rH   rK   rO   rR   rV   r=   r   r   r   r2   r2   G   s0    
   
 	 
 	) , 
	  			 	 #		
 ?	 
	 	 	 # /	
 
  	 r   r2   c                V    [        X5        [        R                  R                  X5      $ N)_verify_rsa_parametersrust_opensslrsagenerate_private_key)public_exponentr   backends      r   ra   ra      s#    
 ?500KKr   c                H    U S;  a  [        S5      eUS:  a  [        S5      eg )N)   i  zopublic_exponent must be either 3 (for legacy compatibility) or 65537. Almost everyone should choose 65537 here!i   z$key_size must be at least 1024-bits.)
ValueError)rb   r   s     r   r^   r^      s6    j(?
 	

 $?@@ r   c                h    Su  p#XpTUS:  a#  [        XE5      u  pgX&U-  -
  nXWX84u  pEp#US:  a  M#  X!-  $ )zG
Modular Multiplicative Inverse. Returns x such that: (x*e) mod m == 1
)   r   r   )divmod)	emx1x2abqrxns	            r   _modinvrs      sL     FBq
a%a|b&[R|b a% 6Mr   c                    [        X5      $ )z>
Compute the CRT (q ** -1) % p value from RSA primes p and q.
)rs   )prp   s     r   rsa_crt_iqmprv      s     1=r   c                    XS-
  -  $ )z[
Compute the CRT private_exponent % (p - 1) value from the RSA
private_exponent (d) and p.
rh   r   )private_exponentru   s     r   rsa_crt_dmp1ry          
 1u%%r   c                    XS-
  -  $ )z[
Compute the CRT private_exponent % (q - 1) value from the RSA
private_exponent (d) and q.
rh   r   )rx   rp   s     r   rsa_crt_dmq1r|      rz   r   c                T    US-
  US-
  -  [        US-
  US-
  5      -  n[        X5      $ )z
Compute the RSA private_exponent (d) given the public exponent (e)
and the RSA primes p and q.

This uses the Carmichael totient function to generate the
smallest possible working value of the private exponent.
rh   )r   rs   )rj   ru   rp   lambda_ns       r   rsa_recover_private_exponentr      s5    " A!a% CAq1u$55H1r   i  c                    S[        SX-  U 5      :w  a  [        S5      eX!-  S-
  nUnUS-  S:X  a  US-  nUS-  S:X  a  M  SnSnU(       d  U[        :  a  [        R                  " SU S-
  5      nUS-  nUnX:  aI  [        XxU 5      n	U	S:w  a+  XS-
  :w  a#  [        U	SU 5      S:X  a  [        U	S-   U 5      n
SnOUS-  nX:  a  MI  U(       d  U[        :  a  M  U(       d  [        S5      e[        U W
5      u  pUS:X  d   e[        X4SS	9u  pX4$ )
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.
   zn, d, e don't matchrh      r   FTz2Unable to compute factors p and q from exponent d.)reverse)powrf   _MAX_RECOVERY_ATTEMPTSrandomrandintr   ri   sorted)nrj   dktottspottedtriesrn   kcandru   rp   rq   s                r   rsa_recover_prime_factorsr      s4    
SQUA.//519D 	A
a%1*F a%1* GE%"88NN1a!e$
hqQ<DqyT!e_T1aA1E q!$FA h %"88 MNN!Q<DA6M61&$'DA6Mr   r]   )rb   r1   r   r1   rc   z
typing.Anyr/   r   )rb   r1   r   r1   r/   rY   )rj   r1   rk   r1   r/   r1   )ru   r1   rp   r1   r/   r1   )rx   r1   ru   r1   r/   r1   )rx   r1   rp   r1   r/   r1   )rj   r1   ru   r1   rp   r1   r/   r1   )r   r1   rj   r1   r   r1   r/   ztuple[int, int])$
__future__r   r:   r   typingmathr   "cryptography.hazmat.bindings._rustr   r_   cryptography.hazmat.primitivesr   r   *cryptography.hazmat.primitives._asymmetricr   )cryptography.hazmat.primitives.asymmetricr	   
asym_utilsABCMetar   RSAPrivateKeyWithSerializationregisterr`   r2   RSAPublicKeyWithSerializationr4   rX   ra   r^   rs   rv   ry   r|   r   r   r   r   r   r   <module>r      s  
 # 
    F A H I.ckk .b "/    |''55 69S[[ 9x !-    l&&33 4 $$66 ##44  LLL L 	LA
&& .  +r   