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ÚmlkemZfrom_mlkem768_public_bytes©Úclsr
   r   © r   úyC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\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   r3   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	   )r3   r4   r   r	   ©Ú__name__Ú
__module__Ú__qualname__Úclassmethodr   ÚabcÚabstractmethodr    r)   r*   r0   r2   r7   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   Z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   Z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   rM   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$   rS   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   r1   r   r   r   r   r   r2   ƒ   r!   zMLKEM768PrivateKey.__copy__r3   r4   c                 C  r   r5   r   r6   r   r   r   r7   ‰   r!   zMLKEM768PrivateKey.__deepcopy__N)r   rG   )r
   r   r   rG   ©rM   r   r   r&   r<   ©r"   r#   r$   rR   rS   rT   r   r&   r:   )r3   r4   r   rG   ©r>   r?   r@   rA   rJ   rL   rB   rC   rP   rQ   rW   rY   r2   r7   r   r   r   r   rG   L   ó"    
rG   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   Z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   r/   r   r   r   r0   º   r!   zMLKEM1024PublicKey.__eq__c                 C  r   r1   r   r   r   r   r   r2   À   r!   zMLKEM1024PublicKey.__copy__r3   r4   c                 C  r   r5   r   r6   r   r   r   r7   Æ   r!   zMLKEM1024PublicKey.__deepcopy__N)r
   r   r   r^   r8   r9   r:   r;   ©r   r^   )r3   r4   r   r^   r=   r   r   r   r   r^   ”   rD   r^   c                   @  rF   )'ÚMLKEM1024PrivateKeyr   c                 C  rH   r_   )	r   r   r   r   r   r   r   r   Zgenerate_mlkem1024_keyrI   r   r   r   rJ   Ò   rK   zMLKEM1024PrivateKey.generater
   r   c                 C  r   r_   )	r   r   r   r   r   r   r   r   Zfrom_mlkem1024_seed_bytesr   r   r   r   rL   Þ   r   z#MLKEM1024PrivateKey.from_seed_bytesrM   r&   c                 C  r   rN   r   rO   r   r   r   rP   ê   r!   zMLKEM1024PrivateKey.decapsulater^   c                 C  r   )zG
        The MLKEM1024PublicKey derived from this private key.
        Nr   r   r   r   r   rQ   ð   r!   zMLKEM1024PrivateKey.public_keyr"   r#   r$   rR   rS   rT   c                 C  r   rU   r   rV   r   r   r   rW   ö   r!   z!MLKEM1024PrivateKey.private_bytesc                 C  r   rX   r   r   r   r   r   rY     r!   z%MLKEM1024PrivateKey.private_bytes_rawc                 C  r   r1   r   r   r   r   r   r2     r!   zMLKEM1024PrivateKey.__copy__r3   r4   c                 C  r   r5   r   r6   r   r   r   r7     r!   z MLKEM1024PrivateKey.__deepcopy__N)r   ra   )r
   r   r   ra   rZ   r`   r[   r:   )r3   r4   r   ra   r\   r   r   r   r   ra   Ñ   r]   ra   )Ú
__future__r   rB   Zcryptography.exceptionsr   r   Z"cryptography.hazmat.bindings._rustr   r   Zcryptography.hazmat.primitivesr   Zcryptography.utilsr   ÚABCMetar	   ÚhasattrÚregisterr   rG   r^   ra   r   r   r   r   Ú<module>   s&   
9
D
9
Dÿ