| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/Cryptodome/Cipher/__pycache__/ |
Upload File : |
�
��e�6 � � � d Z dgZddlmZmZ ddlmZmZ ddlm Z ddl
mZmZ ddl
mZ ddlmZ dd lmZ G d
� de� Zd� Zy)
z-
Synthetic Initialization Vector (SIV) mode.
�SivMode� )�hexlify� unhexlify)�bord�_copy_bytes)� is_buffer)�
long_to_bytes�
bytes_to_long)�_S2V)�BLAKE2s)�get_random_bytesc �V � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z
d � Zd
� Zdd�Z
dd
�Zy)r a� Synthetic Initialization Vector (SIV).
This is an Authenticated Encryption with Associated Data (`AEAD`_) mode.
It provides both confidentiality and authenticity.
The header of the message may be left in the clear, if needed, and it will
still be subject to authentication. The decryption step tells the receiver
if the message comes from a source that really knowns the secret key.
Additionally, decryption detects if any part of the message - including the
header - has been modified or corrupted.
Unlike other AEAD modes such as CCM, EAX or GCM, accidental reuse of a
nonce is not catastrophic for the confidentiality of the message. The only
effect is that an attacker can tell when the same plaintext (and same
associated data) is protected with the same key.
The length of the MAC is fixed to the block size of the underlying cipher.
The key size is twice the length of the key of the underlying cipher.
This mode is only available for AES ciphers.
+--------------------+---------------+-------------------+
| Cipher | SIV MAC size | SIV key length |
| | (bytes) | (bytes) |
+====================+===============+===================+
| AES-128 | 16 | 32 |
+--------------------+---------------+-------------------+
| AES-192 | 16 | 48 |
+--------------------+---------------+-------------------+
| AES-256 | 16 | 64 |
+--------------------+---------------+-------------------+
See `RFC5297`_ and the `original paper`__.
.. _RFC5297: https://tools.ietf.org/html/rfc5297
.. _AEAD: http://blog.cryptographyengineering.com/2012/05/how-to-choose-authenticated-encryption.html
.. __: http://www.cs.ucdavis.edu/~rogaway/papers/keywrap.pdf
:undocumented: __init__
c �� � |j | _ || _ || _ t |� dvrt dt |� z � �|�Bt |� st
d� �t |� dk( rt d� �t d d |� | _ t |� dz }d | _ t |d | || j �� | _ ||d | _ |j |d | |j fi |�� g d�| _ y ) N)� �0 �@ zIncorrect key length (%d bytes)z?When provided, the nonce must be bytes, bytearray or memoryviewr z*When provided, the nonce must be non-empty� )� ciphermod�
cipher_params��update�encrypt�decrypt�digest�verify)�
block_size�_factory�_cipher_params�len�
ValueErrorr � TypeErrorr �nonce�_mac_tagr �_kdf�_subkey_cipher�new�MODE_ECB�_next)�self�factory�keyr"