
    M j,!                       S SK Jr  S SKrS SKrS SKrS SKJr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.                  R0                  5        \
R.                  R4                  r\
R.                  R6                  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lcm)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\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      ~/root/GenerationalWealth/GenerationalWealth/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_numbers3   r   r   c                    gz&
Returns the key serialized as bytes.
Nr   )r   encodingformatencryption_algorithms       r   private_bytesRSAPrivateKey.private_bytes9   r   r   c                    gz
Returns a copy.
Nr   r   s    r   __copy__RSAPrivateKey.__copy__D   r   r   c                    gz
Returns a deep copy.
Nr   r   memos     r   __deepcopy__RSAPrivateKey.__deepcopy__J   r   r   r   N)r   bytesr   r	   returnr9   r:   intr:   RSAPublicKey)r!   r9   r   r	   r"   zEasym_utils.Prehashed | hashes.HashAlgorithm | asym_utils.NoDigestInfor:   r9   )r:   RSAPrivateNumbers)r*   _serialization.Encodingr+   z_serialization.PrivateFormatr,   z)_serialization.KeySerializationEncryptionr:   r9   )r:   r   )r6   dictr:   r   )__name__
__module____qualname____firstlineno__abcabstractmethodr   propertyr   r   r#   r&   r-   r1   r7   __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\R
                  SS
 j5       rSrg)r>   U   c                    g)z
Encrypts the given plaintext.
Nr   )r   	plaintextr   s      r   encryptRSAPublicKey.encryptV   r   r   c                    gr   r   r   s    r   r   RSAPublicKey.key_size\   r   r   c                    g)z
Returns an RSAPublicNumbers
Nr   r   s    r   public_numbersRSAPublicKey.public_numbersc   r   r   c                    gr)   r   )r   r*   r+   s      r   public_bytesRSAPublicKey.public_bytesi   r   r   c                    g)z%
Verifies the signature of the data.
Nr   )r   	signaturer!   r   r"   s        r   verifyRSAPublicKey.verifys   r   r   c                    g)z0
Recovers the original data from the signature.
Nr   )r   rZ   r   r"   s       r   recover_data_from_signature(RSAPublicKey.recover_data_from_signature   r   r   c                    g)z
Checks equality.
Nr   )r   others     r   __eq__RSAPublicKey.__eq__   r   r   c                    gr0   r   r   s    r   r1   RSAPublicKey.__copy__   r   r   c                    gr4   r   r5   s     r   r7   RSAPublicKey.__deepcopy__   r   r   r   N)rN   r9   r   r	   r:   r9   r;   )r:   RSAPublicNumbers)r*   r@   r+   z_serialization.PublicFormatr:   r9   )
rZ   r9   r!   r9   r   r	   r"   z+asym_utils.Prehashed | hashes.HashAlgorithmr:   None)rZ   r9   r   r	   r"   z5hashes.HashAlgorithm | asym_utils.NoDigestInfo | Noner:   r9   )ra   objectr:   boolr=   )r6   rA   r:   r>   )rB   rC   rD   rE   rF   rG   rO   rH   r   rT   rW   r[   r^   rb   r1   r7   rI   r   r   r   r>   r>   U   se    
   
 	 
 	) , 
	  			 	 #		
 ?	 
	 	 	 # I	
 
  	 
 	 
 	 r   r>   c                V    [        X5        [        R                  R                  X5      $ N)_verify_rsa_parametersrust_opensslrsagenerate_private_key)public_exponentr   backends      r   rq   rq      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)rr   r   s     r   rn   rn      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   _modinvr      sL     FBq
a%a|b&[R|b a% 6Mr   c                F    U S::  d  US::  a  [        S5      e[        X5      $ )z>
Compute the CRT (q ** -1) % p value from RSA primes p and q.
ry   Values can't be <= 1)rw   r   )pr   s     r   rsa_crt_iqmpr      s'     	Ava/001=r   c                >    U S::  d  US::  a  [        S5      eXS-
  -  $ )z[
Compute the CRT private_exponent % (p - 1) value from the RSA
private_exponent (d) and p.
ry   r   rv   )private_exponentr   s     r   rsa_crt_dmp1r      +    
 1Q/001u%%r   c                >    U S::  d  US::  a  [        S5      eXS-
  -  $ )z[
Compute the CRT private_exponent % (q - 1) value from the RSA
private_exponent (d) and q.
ry   r   rv   )r   r   s     r   rsa_crt_dmq1r      r   r   c                t    U S::  d  US::  d  US::  a  [        S5      e[        U [        US-
  US-
  5      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.
ry   r   )rw   r   r   )r{   r   r   s      r   rsa_recover_private_exponentr      s?     	Ava16/001c!a%Q'((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.
ry   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)rw   pow_MAX_RECOVERY_ATTEMPTSrandomrandintr   rz   sorted)nr{   dktottspottedtriesr   kcandr   r   r   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   rm   )rr   r<   r   r<   rs   z
typing.Anyr:   r   )rr   r<   r   r<   r:   ri   )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<   r   r<   r   r<   r:   r<   )r   r<   r{   r<   r   r<   r:   ztuple[int, int])%
__future__r   rF   r   typingmathr   r   "cryptography.hazmat.bindings._rustr   ro   cryptography.hazmat.primitivesr   r   *cryptography.hazmat.primitives._asymmetricr	   )cryptography.hazmat.primitives.asymmetricr
   
asym_utilsABCMetar   RSAPrivateKeyWithSerializationregisterrp   r>   RSAPublicKeyWithSerializationr?   rh   rq   rn   r   r   r   r   r   r   r   r   r   r   <module>r      s  
 # 
    F A H I<ckk <~ "/    |''55 6ES[[ EP !-    l&&33 4 $$66 ##44  LLL L 	LA
&&)*  -r   