
    (ph                       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                  V   \ 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
)RSAPrivateKey   c                    g)z#
Decrypts the provided ciphertext.
N )self
ciphertextpaddings      `/var/www/html/venv/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   c                    gz
Returns a copy.
Nr   r   s    r   __copy__RSAPrivateKey.__copy__B   r   r   r   N)r   bytesr   r   returnr2   r3   intr3   RSAPublicKey)r    r2   r   r   r!   +asym_utils.Prehashed | hashes.HashAlgorithmr3   r2   )r3   RSAPrivateNumbers)r)   _serialization.Encodingr*   z_serialization.PrivateFormatr+   z)_serialization.KeySerializationEncryptionr3   r2   )r3   r   )__name__
__module____qualname____firstlineno__abcabstractmethodr   propertyr   r   r"   r%   r,   r0   __static_attributes__r   r   r   r   r      s    
   
 	 
 	 # ?	
 
  	 
 	) - H	
 
  	 r   r   )	metaclassc                     \ 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\R
                  SS	 j5       rS
rg)r7   M   c                    g)z
Encrypts the given plaintext.
Nr   )r   	plaintextr   s      r   encryptRSAPublicKey.encryptN   r   r   c                    gr   r   r   s    r   r   RSAPublicKey.key_sizeT   r   r   c                    g)z
Returns an RSAPublicNumbers
Nr   r   s    r   public_numbersRSAPublicKey.public_numbers[   r   r   c                    gr(   r   )r   r)   r*   s      r   public_bytesRSAPublicKey.public_bytesa   r   r   c                    g)z%
Verifies the signature of the data.
Nr   )r   	signaturer    r   r!   s        r   verifyRSAPublicKey.verifyk   r   r   c                    g)z0
Recovers the original data from the signature.
Nr   )r   rS   r   r!   s       r   recover_data_from_signature(RSAPublicKey.recover_data_from_signaturew   r   r   c                    g)z
Checks equality.
Nr   )r   others     r   __eq__RSAPublicKey.__eq__   r   r   c                    gr/   r   r   s    r   r0   RSAPublicKey.__copy__   r   r   r   N)rG   r2   r   r   r3   r2   r4   )r3   RSAPublicNumbers)r)   r:   r*   z_serialization.PublicFormatr3   r2   )
rS   r2   r    r2   r   r   r!   r8   r3   None)rS   r2   r   r   r!   zhashes.HashAlgorithm | Noner3   r2   )rZ   objectr3   boolr6   )r;   r<   r=   r>   r?   r@   rH   rA   r   rM   rP   rT   rW   r[   r0   rB   r   r   r   r7   r7   M   sJ    
   
 	 
 	) , 
	  			 	 #		
 ?	 
	 	 	 # /	
 
  	 
 	 r   r7   c                V    [        X5        [        R                  R                  X5      $ N)_verify_rsa_parametersrust_opensslrsagenerate_private_key)public_exponentr   backends      r   rh   rh      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)ri   r   s     r   re   re      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   _modinvrz      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.
)rz   )prw   s     r   rsa_crt_iqmpr}      s     1=r   c                    XS-
  -  $ )z[
Compute the CRT private_exponent % (p - 1) value from the RSA
private_exponent (d) and p.
ro   r   )private_exponentr|   s     r   rsa_crt_dmp1r          
 1u%%r   c                    XS-
  -  $ )z[
Compute the CRT private_exponent % (q - 1) value from the RSA
private_exponent (d) and q.
ro   r   )r   rw   s     r   rsa_crt_dmq1r      r   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.
ro   )r   rz   )rq   r|   rw   lambda_ns       r   rsa_recover_private_exponentr      s5    " A!a% CAq1u$55H1r   i  c                N   US::  d  US::  a  [        S5      e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.
ro   zd, e can't be <= 1   zn, d, e don't match   r   FTz2Unable to compute factors p and q from exponent d.)reverse)rm   pow_MAX_RECOVERY_ATTEMPTSrandomrandintr   rp   sorted)nrq   dktottspottedtriesru   kcandr|   rw   rx   s                r   rsa_recover_prime_factorsr      sM    	Ava-..	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   rd   )ri   r5   r   r5   rj   z
typing.Anyr3   r   )ri   r5   r   r5   r3   r`   )rq   r5   rr   r5   r3   r5   )r|   r5   rw   r5   r3   r5   )r   r5   r|   r5   r3   r5   )r   r5   rw   r5   r3   r5   )rq   r5   r|   r5   rw   r5   r3   r5   )r   r5   rq   r5   r   r5   r3   ztuple[int, int])$
__future__r   r?   r   typingmathr   "cryptography.hazmat.bindings._rustr   rf   cryptography.hazmat.primitivesr   r   *cryptography.hazmat.primitives._asymmetricr   )cryptography.hazmat.primitives.asymmetricr	   
asym_utilsABCMetar   RSAPrivateKeyWithSerializationregisterrg   r7   RSAPublicKeyWithSerializationr9   r_   rh   re   rz   r}   r   r   r   r   r   r   r   r   <module>r      s  
 # 
    F A H I4ckk 4n "/    |''55 6?S[[ ?D !-    l&&33 4 $$66 ##44  LLL L 	LA
&& .  -r   