o
    j                     @  s   d dl mZ d dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZ G dd dejd	Zeed
r:eejj G dd dejd	Zeed
rPeejj G dd dejd	Zeed
rfeejj G dd dejd	Zeed
r~eejj dS dS )    )annotationsN)UnsupportedAlgorithm_Reasons)openssl)_serialization)Bufferc                   @  z   e Zd ZedddZ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d#ddZejd$ddZdS )%MLKEM768PublicKeydatar   returnc                 C  ,   ddl m} | stdtjtj|S Nr   backendz,ML-KEM-768 is not supported by this backend.)	,cryptography.hazmat.backends.openssl.backendr   mlkem_supportedr   r    UNSUPPORTED_PUBLIC_KEY_ALGORITHMrust_opensslmlkemfrom_mlkem768_public_bytesclsr
   r    r   u/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/asymmetric/mlkem.pyfrom_public_bytes      z#MLKEM768PublicKey.from_public_bytestuple[bytes, bytes]c                 C     dS zC
        Encapsulate: returns (shared_secret, ciphertext).
        Nr   selfr   r   r   encapsulate       zMLKEM768PublicKey.encapsulateencoding_serialization.Encodingformat_serialization.PublicFormatbytesc                 C  r   z9
        The serialized bytes of the public key.
        Nr   r    r#   r%   r   r   r   public_bytes"   r"   zMLKEM768PublicKey.public_bytesc                 C  r   )z
        The raw bytes of the public key.
        Equivalent to public_bytes(Raw, Raw).

        The public key is 1,184 bytes for ML-KEM-768.
        Nr   r   r   r   r   public_bytes_raw,   r"   z"MLKEM768PublicKey.public_bytes_rawotherobjectboolc                 C  r   z"
        Checks equality.
        Nr   r    r,   r   r   r   __eq__5   r"   zMLKEM768PublicKey.__eq__c                 C  r   z!
        Returns a copy.
        Nr   r   r   r   r   __copy__;   r"   zMLKEM768PublicKey.__copy__memodictc                 C  r   z&
        Returns a deep copy.
        Nr   r    r4   r   r   r   __deepcopy__A   r"   zMLKEM768PublicKey.__deepcopy__N)r
   r   r   r	   r   r   r#   r$   r%   r&   r   r'   r   r'   r,   r-   r   r.   r   r	   )r4   r5   r   r	   __name__
__module____qualname__classmethodr   abcabstractmethodr!   r*   r+   r1   r3   r8   r   r   r   r   r	          	r	   )	metaclassr   c                   @     e Zd Zed ddZed!ddZ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d ddZejd&ddZdS )'MLKEM768PrivateKeyr   c                 C  *   ddl m} | stdtjtj S r   )	r   r   r   r   r   r   r   r   generate_mlkem768_keyr   r   r   r   r   generateM      
zMLKEM768PrivateKey.generater
   r   c                 C  r   r   )	r   r   r   r   r   r   r   r   from_mlkem768_seed_bytesr   r   r   r   from_seed_bytesY   r   z"MLKEM768PrivateKey.from_seed_bytes
ciphertextr'   c                 C  r   z5
        Decapsulate: returns shared_secret.
        Nr   r    rP   r   r   r   decapsulatee   r"   zMLKEM768PrivateKey.decapsulater	   c                 C  r   )zF
        The MLKEM768PublicKey derived from this private key.
        Nr   r   r   r   r   
public_keyk   r"   zMLKEM768PrivateKey.public_keyr#   r$   r%   _serialization.PrivateFormatencryption_algorithm)_serialization.KeySerializationEncryptionc                 C  r   z:
        The serialized bytes of the private key.
        Nr   r    r#   r%   rV   r   r   r   private_bytesq   r"   z MLKEM768PrivateKey.private_bytesc                 C  r   z
        The raw bytes of the private key (64-byte seed).
        Equivalent to private_bytes(Raw, Raw, NoEncryption()).
        Nr   r   r   r   r   private_bytes_raw|   r"   z$MLKEM768PrivateKey.private_bytes_rawc                 C  r   r2   r   r   r   r   r   r3      r"   zMLKEM768PrivateKey.__copy__r4   r5   c                 C  r   r6   r   r7   r   r   r   r8      r"   zMLKEM768PrivateKey.__deepcopy__N)r   rH   )r
   r   r   rH   rP   r   r   r'   r=   r#   r$   r%   rU   rV   rW   r   r'   r;   )r4   r5   r   rH   r?   r@   rA   rB   rL   rO   rC   rD   rS   rT   rZ   r\   r3   r8   r   r   r   r   rH   L   "    
rH   c                   @  r   )%MLKEM1024PublicKeyr
   r   r   c                 C  r   Nr   r   z-ML-KEM-1024 is not supported by this backend.)	r   r   r   r   r   r   r   r   from_mlkem1024_public_bytesr   r   r   r   r      r   z$MLKEM1024PublicKey.from_public_bytesr   c                 C  r   r   r   r   r   r   r   r!      r"   zMLKEM1024PublicKey.encapsulater#   r$   r%   r&   r'   c                 C  r   r(   r   r)   r   r   r   r*      r"   zMLKEM1024PublicKey.public_bytesc                 C  r   )z
        The raw bytes of the public key.
        Equivalent to public_bytes(Raw, Raw).

        The public key is 1,568 bytes for ML-KEM-1024.
        Nr   r   r   r   r   r+      r"   z#MLKEM1024PublicKey.public_bytes_rawr,   r-   r.   c                 C  r   r/   r   r0   r   r   r   r1      r"   zMLKEM1024PublicKey.__eq__c                 C  r   r2   r   r   r   r   r   r3      r"   zMLKEM1024PublicKey.__copy__r4   r5   c                 C  r   r6   r   r7   r   r   r   r8      r"   zMLKEM1024PublicKey.__deepcopy__N)r
   r   r   ra   r9   r:   r;   r<   r   ra   )r4   r5   r   ra   r>   r   r   r   r   ra      rE   ra   c                   @  rG   )'MLKEM1024PrivateKeyr   c                 C  rI   rb   )	r   r   r   r   r   r   r   r   generate_mlkem1024_keyrK   r   r   r   rL      rM   zMLKEM1024PrivateKey.generater
   r   c                 C  r   rb   )	r   r   r   r   r   r   r   r   from_mlkem1024_seed_bytesr   r   r   r   rO      r   z#MLKEM1024PrivateKey.from_seed_bytesrP   r'   c                 C  r   rQ   r   rR   r   r   r   rS      r"   zMLKEM1024PrivateKey.decapsulatera   c                 C  r   )zG
        The MLKEM1024PublicKey derived from this private key.
        Nr   r   r   r   r   rT      r"   zMLKEM1024PrivateKey.public_keyr#   r$   r%   rU   rV   rW   c                 C  r   rX   r   rY   r   r   r   rZ      r"   z!MLKEM1024PrivateKey.private_bytesc                 C  r   r[   r   r   r   r   r   r\     r"   z%MLKEM1024PrivateKey.private_bytes_rawc                 C  r   r2   r   r   r   r   r   r3     r"   zMLKEM1024PrivateKey.__copy__r4   r5   c                 C  r   r6   r   r7   r   r   r   r8     r"   z MLKEM1024PrivateKey.__deepcopy__N)r   re   )r
   r   r   re   r]   rd   r^   r;   )r4   r5   r   re   r_   r   r   r   r   re      r`   re   )
__future__r   rC   cryptography.exceptionsr   r   "cryptography.hazmat.bindings._rustr   r   cryptography.hazmat.primitivesr   cryptography.utilsr   ABCMetar	   hasattrregisterr   rH   ra   re   r   r   r   r   <module>   s&   
9
D
9
D