o
    j'                     @  sF  U d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
 d dlmZ d dlmZmZ d dlmZ G dd	 d	ZG d
d dejdZG dd dejdZG dd dejdZeZeejj G dd dejdZeZeejj ejjZejj Z G dd deZ!G dd deZ"G dd deZ#G dd deZ$G dd deZ%G dd deZ&G dd  d eZ'G d!d" d"eZ(G d#d$ d$eZ)e& e# e& e% e# e" e! e$ e' e( e) d%Z*d&e+d'< G d(d) d)eZ,ejj-Z-	d9d:d0d1Z.G d2d3 d3Z/ej&e&ej%e%ej$e$ej#e#ej"e"ej!e!ej0e'ej1e(ej2e)i	Z3d;d7d8Z4dS )<    )annotationsN)utils)UnsupportedAlgorithm_Reasons)ObjectIdentifier)openssl)_serializationhashesc                   @  sT   e Zd ZedZedZedZedZedZedZ	edZ
edZed	Zd
S )EllipticCurveOIDz1.2.840.10045.3.1.1z1.3.132.0.33z1.3.132.0.10z1.2.840.10045.3.1.7z1.3.132.0.34z1.3.132.0.35z1.3.36.3.3.2.8.1.1.7z1.3.36.3.3.2.8.1.1.11z1.3.36.3.3.2.8.1.1.13N)__name__
__module____qualname__r   	SECP192R1	SECP224R1	SECP256K1	SECP256R1	SECP384R1	SECP521R1BRAINPOOLP256R1BRAINPOOLP384R1BRAINPOOLP512R1 r   r   r/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/asymmetric/ec.pyr
      s    r
   c                   @  sH   e Zd ZeejdddZeejdddZeejddd	Zd
S )EllipticCurvereturnstrc                 C     dS )z8
        The name of the curve. e.g. secp256r1.
        Nr   selfr   r   r   name       zEllipticCurve.nameintc                 C  r   z<
        Bit size of a secret scalar for the curve.
        Nr   r   r   r   r   key_size&   r    zEllipticCurve.key_sizec                 C  r   )z1
        The order of the curve's group.
        Nr   r   r   r   r   group_order-   r    zEllipticCurve.group_orderN)r   r   r   r!   )	r   r   r   propertyabcabstractmethodr   r#   r$   r   r   r   r   r      s    r   )	metaclassc                   @  s    e Zd ZeejdddZdS )EllipticCurveSignatureAlgorithmr   +asym_utils.Prehashed | hashes.HashAlgorithmc                 C  r   )z@
        The digest algorithm used with this signature.
        Nr   r   r   r   r   	algorithm6   r    z)EllipticCurveSignatureAlgorithm.algorithmNr   r+   )r   r   r   r&   r'   r(   r,   r   r   r   r   r*   5   s    r*   c                   @  s   e Zd Zejd)ddZejd*d	d
Zeejd+ddZeejd,ddZ	ejd-ddZ
ejd.ddZejd/d d!Zejd0d"d#Zejd1d&d'Zd(S )2EllipticCurvePrivateKeyr,   ECDHpeer_public_keyEllipticCurvePublicKeyr   bytesc                 C  r   )z}
        Performs a key exchange operation using the provided algorithm with the
        provided peer's public key.
        Nr   )r   r,   r0   r   r   r   exchangeA   r    z EllipticCurvePrivateKey.exchangec                 C  r   )zB
        The EllipticCurvePublicKey for this private key.
        Nr   r   r   r   r   
public_keyJ   r    z"EllipticCurvePrivateKey.public_keyr   c                 C  r   z8
        The EllipticCurve that this key is on.
        Nr   r   r   r   r   curveP   r    zEllipticCurvePrivateKey.curver!   c                 C  r   r"   r   r   r   r   r   r#   W   r    z EllipticCurvePrivateKey.key_sizedatautils.Buffersignature_algorithmr*   c                 C  r   )z 
        Signs the data
        Nr   )r   r7   r9   r   r   r   sign^   r    zEllipticCurvePrivateKey.signEllipticCurvePrivateNumbersc                 C  r   )z9
        Returns an EllipticCurvePrivateNumbers.
        Nr   r   r   r   r   private_numbersh   r    z'EllipticCurvePrivateKey.private_numbersencoding_serialization.Encodingformat_serialization.PrivateFormatencryption_algorithm)_serialization.KeySerializationEncryptionc                 C  r   z6
        Returns the key serialized as bytes.
        Nr   )r   r=   r?   rA   r   r   r   private_bytesn   r    z%EllipticCurvePrivateKey.private_bytesc                 C  r   z!
        Returns a copy.
        Nr   r   r   r   r   __copy__y   r    z EllipticCurvePrivateKey.__copy__memodictc                 C  r   z&
        Returns a deep copy.
        Nr   r   rG   r   r   r   __deepcopy__   r    z$EllipticCurvePrivateKey.__deepcopy__N)r,   r/   r0   r1   r   r2   r   r1   r   r   r%   )r7   r8   r9   r*   r   r2   )r   r;   )r=   r>   r?   r@   rA   rB   r   r2   )r   r.   )rG   rH   r   r.   )r   r   r   r'   r(   r3   r4   r&   r6   r#   r:   r<   rD   rF   rK   r   r   r   r   r.   @   s*    	
r.   c                   @  s   e Zd Zeejd)ddZeejd*ddZejd+d	d
Zejd,ddZ	ejd-ddZ
ed.ddZejd/d d!Zejd0d"d#Zejd1d&d'Zd(S )2r1   r   r   c                 C  r   r5   r   r   r   r   r   r6      r    zEllipticCurvePublicKey.curver!   c                 C  r   r"   r   r   r   r   r   r#      r    zEllipticCurvePublicKey.key_sizeEllipticCurvePublicNumbersc                 C  r   )z8
        Returns an EllipticCurvePublicNumbers.
        Nr   r   r   r   r   public_numbers   r    z%EllipticCurvePublicKey.public_numbersr=   r>   r?   _serialization.PublicFormatr2   c                 C  r   rC   r   )r   r=   r?   r   r   r   public_bytes   r    z#EllipticCurvePublicKey.public_bytes	signaturer8   r7   r9   r*   Nonec                 C  r   )z5
        Verifies the signature of the data.
        Nr   )r   rR   r7   r9   r   r   r   verify   r    zEllipticCurvePublicKey.verifyr6   c                 C  sB   t d| t|dkrtd|d dvrtdtj||S )Nr7   r   z%data must not be an empty byte string)         z%Unsupported elliptic curve point type)r   _check_byteslen
ValueErrorrust_opensslecfrom_public_bytes)clsr6   r7   r   r   r   from_encoded_point   s   z)EllipticCurvePublicKey.from_encoded_pointotherobjectboolc                 C  r   )z"
        Checks equality.
        Nr   )r   r`   r   r   r   __eq__   r    zEllipticCurvePublicKey.__eq__c                 C  r   rE   r   r   r   r   r   rF      r    zEllipticCurvePublicKey.__copy__rG   rH   c                 C  r   rI   r   rJ   r   r   r   rK      r    z#EllipticCurvePublicKey.__deepcopy__NrM   r%   )r   rN   )r=   r>   r?   rP   r   r2   )rR   r8   r7   r8   r9   r*   r   rS   )r6   r   r7   r2   r   r1   )r`   ra   r   rb   rL   )rG   rH   r   r1   )r   r   r   r&   r'   r(   r6   r#   rO   rQ   rT   classmethodr_   rc   rF   rK   r   r   r   r   r1      s*    	
r1   c                   @     e Zd ZdZdZdZdS )r   	secp521r1i	  l#   	dp"z\}[z3"nZ;PK#
`7roCQNr   r   r   r   r#   r$   r   r   r   r   r          r   c                   @  re   )r   	secp384r1  l   s)e`gwlX_[nlv|Nrg   r   r   r   r   r      rh   r   c                   @  re   )r   	secp256r1   l   Q%x+Ohbi+}s   @ Nrg   r   r   r   r   r      
    r   c                   @  re   )r   	secp256k1rl   l   AAl 3z~i9nW~ Nrg   r   r   r   r   r      rm   r   c                   @  re   )r   	secp224r1   l   =*8%(?Nrg   r   r   r   r   r      rh   r   c                   @  re   )r   	secp192r1   l   1(i&^#a;Nrg   r   r   r   r   r      rh   r   c                   @  re   )BrainpoolP256R1brainpoolP256r1rl   l   V.
: yo4,(qvBT0C7U{h+) Nrg   r   r   r   r   rs     rm   rs   c                   @  re   )BrainpoolP384R1brainpoolP384r1rj   l   eeRHA\1o+['K2s31
U{8/C{u%NQA9Nrg   r   r   r   r   ru     rh   ru   c                   @  re   )BrainpoolP512R1brainpoolP512r1i   l#   i R9
Z<,-B`XG Xe3$*S .>U@Sf9fAtrY0'qjNg"qmU Nrg   r   r   r   r   rw     rh   rw   )
prime192v1
prime256v1rq   ro   rk   ri   rf   rn   rt   rv   rx   zdict[str, EllipticCurve]_CURVE_TYPESc                   @  s6   e Zd Z	ddddZedd	d
ZedddZdS )ECDSAFr,   r+   deterministic_signingrb   c                 C  s4   ddl m} |r| stdtj|| _|| _d S )Nr   )backendzZECDSA with deterministic signature (RFC 6979) is not supported by this version of OpenSSL.),cryptography.hazmat.backends.openssl.backendr~   ecdsa_deterministic_supportedr   r    UNSUPPORTED_PUBLIC_KEY_ALGORITHM
_algorithm_deterministic_signing)r   r,   r}   r~   r   r   r   __init__(  s   
zECDSA.__init__r   c                 C     | j S N)r   r   r   r   r   r,   ;     zECDSA.algorithmc                 C  r   r   )r   r   r   r   r   r}   A  r   zECDSA.deterministic_signingN)F)r,   r+   r}   rb   r-   )r   rb   )r   r   r   r   r&   r,   r}   r   r   r   r   r|   '  s    r|   private_valuer!   r6   r~   
typing.Anyr   c                 C  s0   t | ts	td| dkrtdtj| |S )Nz&private_value must be an integer type.r   z)private_value must be a positive integer.)
isinstancer!   	TypeErrorrZ   r[   r\   derive_private_key)r   r6   r~   r   r   r   r   K  s
   
r   c                   @  s   e Zd ZdS )r/   N)r   r   r   r   r   r   r   r/   Y  s    r/   oidr   type[EllipticCurve]c                 C  s"   zt |  W S  ty   tdw )NzCThe provided object identifier has no matching elliptic curve class)_OID_TO_CURVEKeyErrorLookupError)r   r   r   r   get_curve_for_oidj  s   
r   r   )r   r!   r6   r   r~   r   r   r.   )r   r   r   r   )5
__future__r   r'   typingcryptographyr   cryptography.exceptionsr   r   cryptography.hazmat._oidr   "cryptography.hazmat.bindings._rustr   r[   cryptography.hazmat.primitivesr   r	   )cryptography.hazmat.primitives.asymmetric
asym_utilsr
   ABCMetar   r*   r.   (EllipticCurvePrivateKeyWithSerializationregisterr\   ECPrivateKeyr1   'EllipticCurvePublicKeyWithSerializationECPublicKeyr;   rN   r   r   r   r   r   r   rs   ru   rw   r{   __annotations__r|   generate_private_keyr   r/   r   r   r   r   r   r   r   r   r   <module>   sr   FK!