U
    /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
rteejj G dd dejd	Zeed
reejj G dd dejd	Zeed
reejj G dd dejd	Zeed
reejj dS )    )annotationsN)UnsupportedAlgorithm_Reasons)openssl)_serialization)Bufferc                   @  s   e Zd Zedd dddZejddddZejd	d
ddddZejddddZ	ejdddddZ
ejd dddZejdd dddZdS )MLKEM768PublicKeyr   datareturnc                 C  s,   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mlkemZfrom_mlkem768_public_bytesclsr
   r    r   S/tmp/pip-unpacked-wheel-qzbw3lpx/cryptography/hazmat/primitives/asymmetric/mlkem.pyfrom_public_bytes   s    z#MLKEM768PublicKey.from_public_bytestuple[bytes, bytes]r   c                 C  s   dS zC
        Encapsulate: returns (shared_secret, ciphertext).
        Nr   selfr   r   r   encapsulate   s    zMLKEM768PublicKey.encapsulate_serialization.Encoding_serialization.PublicFormatbytesencodingformatr   c                 C  s   dS z9
        The serialized bytes of the public key.
        Nr   r   r#   r$   r   r   r   public_bytes"   s    zMLKEM768PublicKey.public_bytesc                 C  s   dS )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,   s    z"MLKEM768PublicKey.public_bytes_rawobjectboolotherr   c                 C  s   dS z"
        Checks equality.
        Nr   r   r,   r   r   r   __eq__5   s    zMLKEM768PublicKey.__eq__c                 C  s   dS z!
        Returns a copy.
        Nr   r   r   r   r   __copy__;   s    zMLKEM768PublicKey.__copy__dictmemor   c                 C  s   dS z&
        Returns a deep copy.
        Nr   r   r4   r   r   r   __deepcopy__A   s    zMLKEM768PublicKey.__deepcopy__N__name__
__module____qualname__classmethodr   abcabstractmethodr   r'   r(   r/   r1   r7   r   r   r   r   r      s   	r   )	metaclassr   c                   @  s   e Zd Zed dddZedd dddZejddd	d
dZejddddZ	ejdddddddZ
ejddddZejd dddZejdd dddZdS )MLKEM768PrivateKeyr   c                 C  s*   ddl m} | s tdtjtj S r   )	r   r   r   r   r   r   r   r   Zgenerate_mlkem768_keyr   r   r   r   r   generateM   s    zMLKEM768PrivateKey.generater   r	   c                 C  s,   ddl m} | s tdtjtj|S r   )	r   r   r   r   r   r   r   r   Zfrom_mlkem768_seed_bytesr   r   r   r   from_seed_bytesY   s    z"MLKEM768PrivateKey.from_seed_bytesr!   
ciphertextr   c                 C  s   dS z5
        Decapsulate: returns shared_secret.
        Nr   r   rE   r   r   r   decapsulatee   s    zMLKEM768PrivateKey.decapsulater   c                 C  s   dS )zF
        The MLKEM768PublicKey derived from this private key.
        Nr   r   r   r   r   
public_keyk   s    zMLKEM768PrivateKey.public_keyr   _serialization.PrivateFormat)_serialization.KeySerializationEncryptionr#   r$   encryption_algorithmr   c                 C  s   dS z:
        The serialized bytes of the private key.
        Nr   r   r#   r$   rM   r   r   r   private_bytesq   s    z MLKEM768PrivateKey.private_bytesc                 C  s   dS 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|   s    z$MLKEM768PrivateKey.private_bytes_rawc                 C  s   dS r0   r   r   r   r   r   r1      s    zMLKEM768PrivateKey.__copy__r2   r3   c                 C  s   dS r5   r   r6   r   r   r   r7      s    zMLKEM768PrivateKey.__deepcopy__Nr9   r:   r;   r<   rB   rC   r=   r>   rH   rI   rP   rR   r1   r7   r   r   r   r   r@   L   s    
r@   c                   @  s   e Zd Zedd dddZejddddZejd	d
ddddZejddddZ	ejdddddZ
ejd dddZejdd dddZdS )MLKEM1024PublicKeyr   r	   c                 C  s,   ddl m} | s tdtjtj|S Nr   r   z-ML-KEM-1024 is not supported by this backend.)	r   r   r   r   r   r   r   r   Zfrom_mlkem1024_public_bytesr   r   r   r   r      s    z$MLKEM1024PublicKey.from_public_bytesr   r   c                 C  s   dS r   r   r   r   r   r   r      s    zMLKEM1024PublicKey.encapsulater   r    r!   r"   c                 C  s   dS r%   r   r&   r   r   r   r'      s    zMLKEM1024PublicKey.public_bytesc                 C  s   dS )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(      s    z#MLKEM1024PublicKey.public_bytes_rawr)   r*   r+   c                 C  s   dS r-   r   r.   r   r   r   r/      s    zMLKEM1024PublicKey.__eq__c                 C  s   dS r0   r   r   r   r   r   r1      s    zMLKEM1024PublicKey.__copy__r2   r3   c                 C  s   dS r5   r   r6   r   r   r   r7      s    zMLKEM1024PublicKey.__deepcopy__Nr8   r   r   r   r   rT      s   	rT   c                   @  s   e Zd Zed dddZedd dddZejddd	d
dZejddddZ	ejdddddddZ
ejddddZejd dddZejdd dddZdS )MLKEM1024PrivateKeyr   c                 C  s*   ddl m} | s tdtjtj S rU   )	r   r   r   r   r   r   r   r   Zgenerate_mlkem1024_keyrA   r   r   r   rB      s    zMLKEM1024PrivateKey.generater   r	   c                 C  s,   ddl m} | s tdtjtj|S rU   )	r   r   r   r   r   r   r   r   Zfrom_mlkem1024_seed_bytesr   r   r   r   rC      s    z#MLKEM1024PrivateKey.from_seed_bytesr!   rD   c                 C  s   dS rF   r   rG   r   r   r   rH      s    zMLKEM1024PrivateKey.decapsulaterT   c                 C  s   dS )zG
        The MLKEM1024PublicKey derived from this private key.
        Nr   r   r   r   r   rI      s    zMLKEM1024PrivateKey.public_keyr   rJ   rK   rL   c                 C  s   dS rN   r   rO   r   r   r   rP      s    z!MLKEM1024PrivateKey.private_bytesc                 C  s   dS rQ   r   r   r   r   r   rR     s    z%MLKEM1024PrivateKey.private_bytes_rawc                 C  s   dS r0   r   r   r   r   r   r1     s    zMLKEM1024PrivateKey.__copy__r2   r3   c                 C  s   dS r5   r   r6   r   r   r   r7     s    z MLKEM1024PrivateKey.__deepcopy__NrS   r   r   r   r   rV      s    
rV   )
__future__r   r=   Zcryptography.exceptionsr   r   Z"cryptography.hazmat.bindings._rustr   r   Zcryptography.hazmat.primitivesr   Zcryptography.utilsr   ABCMetar   hasattrregisterr   r@   rT   rV   r   r   r   r   <module>   s"   9
D
9
D
