Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_hmac.cpython-310.pyc
o

�9j�e�@sFddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZzddl
Zddl
mZddl
mZddl
mZWneySdZdZdZdZYnwzddlZWneyedZYnwdd�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�Zedkr�e� �dSdS)�N)�hashlib_helper�check_disallow_instantiation)�_compare_digest)�HMAC)�hmac_new)�compare_digestcst����fdd��}|S)NcsHt���tjdtd��|i|��Wd�S1swYdS)N�ignore)�category)�warnings�catch_warnings�filterwarnings�DeprecationWarning)�args�kwargs��func��%/usr/lib/python3.10/test/test_hmac.py�wrappers
�$�zignore_warning.<locals>.wrapper)�	functools�wraps)rrrrr�ignore_warningsrc@s�eZdZdd�Zdd�Zejddd�dd	��Zejd
dd�dd��Zd
d�Z	ejddd�dd��Z
ejddd�dd��Zejddd�dd��Zejddd�dd��Z
e�d�dd��Zdd�ZdS) �TestVectorsTestCasecCsb|�|����|���|�|��t�|��|�|jd|���|�|j|�|�|j|�dS)Nzhmac-)	�assertEqual�	hexdigest�upper�digest�binascii�	unhexlify�name�digest_size�
block_size)�self�hr�hashnamer r!rrr�assert_hmac_internals*s
z)TestVectorsTestCase.assert_hmac_internalscCsptj|||d�}|�|||||�tj|||d�}|�|||||�tj||d�}|��}	|	�d�|�|�|�|����|���tj|||d�}|�|||||�tj|d|d�}|�|�|�|����|���tj||d�}|�|�|�|����|���tj|||d�}|�|����|���|�tj	|||d�t
�|��|�tj	|||d�t
�|��tj�tj�}|j
|||d�|�|||||�tdu�r6t|||d�}|�|||||�t||d�}|��}	|	�d�|�|�|�|����|���ttd|���}
t|||
d�}|�|||||�tj�tj�}|j|||d�|�|||||�dSdS)N��	digestmodstest update)r�openssl_)�hmacrr%�copy�updaterrr�newrrr�__new__�	_init_old�
c_hmac_new�getattr�_hashopenssl�
_init_hmac)r"�key�datar�hashfuncr$r r!r#�h2rrrr�assert_hmac3sv
�
�


�

��
�

�


�
��zTestVectorsTestCase.assert_hmac�md5T)�opensslc�n�fdd�}|ddd�|ddd�|d	d
d�|ttdd
��dd�|ddd�|ddd�|ddd�dS)Nc	��j|||tjdddd�dS)Nr8��@�r5r$r r!)r7�hashlibr8�r3r4r�r"rr�md5test��
�z5TestVectorsTestCase.test_md5_vectors.<locals>.md5test��Hi There� 9294727A3638BB1C13F48EF8158BFC9D�Jefe�what do ya want for nothing?� 750c783e6ab0b503eaa86e310a5db738s�����������������2��������������������������������������������������� 56be34521d144c88dbb8c733f0e8b3f6���2��������������������������������������������������� 697eaf0aca3a3aea3a75164746ffaa79s�Test With Truncation� 56461ef2342edc00f9bab995690efd4c�P���������������������������������������������������������������������������������6Test Using Larger Than Block-Size Key - Hash Key First� 6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd�ITest Using Larger Than Block-Size Key and Larger Than One Block-Size Data� 6f630fad67cda0ee1fb1f562db3aa53e��bytes�range)r"rBrrAr�test_md5_vectors}s:	�������z$TestVectorsTestCase.test_md5_vectors�sha1cr:)Nc	r;)Nr[�r=r>)r7r?r[r@rArr�shatest�rCz5TestVectorsTestCase.test_sha_vectors.<locals>.shatest�rE�(b617318655057264e28bc0b6fb378c8ef146be00rGrH�(effcdf6ae5eb2fa2d27416d5f184df9c259a7c79���������������������rJ�(125d7342b9ac11cd91a39af48aa17b4f63f175d3rLrMrN�(4c9007f4026250c6bc8414f9bf50c86c2d7235dasrP�(4c1a03424b55e07fe7f27be1d58bb9324a9a5a04rRrS�(aa4ae5e15272d00e95705637ce8a3b55ed402112rU�(e8e99d0f45237d786d6bbaa7965c7808bbff1a91rW)r"r]rrAr�test_sha_vectors�s:	�������z$TestVectorsTestCase.test_sha_vectorscs�����fdd�}|ddtjdtjdtjdtjdid	�|d
dtjdtjd
tjdtjdid	�|ddtjdtjdtjdtjdid	�|tdd�tdd�D��dtjdtjdtjdtjdid	�|dd tjd!tjd"tjd#tjd$id	�|dd%tjd&tjd'tjd(tjd)id	�dS)*Nc	s$|�}�j|||����d�dS)Nr>)r7)r3r4�
hexdigestsr�r!r �	hash_namer5r"rr�hmactest�s
�z9TestVectorsTestCase._rfc4231_test_cases.<locals>.hmactestr^rE�8896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22�@b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7�`afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6ڀ87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854)r3r4rhrGrH�8a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44�@5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843�`af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649ڀ164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737rarJ�87fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea�@773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe�`88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27ڀfa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fbcss�|]}|VqdS�Nr)�.0�xrrr�	<genexpr>s�z:TestVectorsTestCase._rfc4231_test_cases.<locals>.<genexpr>rLrMrN�86c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a�@82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b�`3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffbڀb0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dds������������������������������������������������������������������������������������������������������������������������������������rS�895e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e�@60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54�`4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952ڀ80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598s�This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.�83a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1�@9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2�`6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523eڀe37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58)r?�sha224�sha256�sha384�sha512rXrY)r"r5rjr r!rkrrir�_rfc4231_test_cases�sb�����������
�z'TestVectorsTestCase._rfc4231_test_casesr�cC�|�tjddd�dS)Nr��r=)r�r?r�rArrr�test_sha224_rfc4231F�z'TestVectorsTestCase.test_sha224_rfc4231r�cCr�)Nr�� r=)r�r?r�rArrr�test_sha256_rfc4231Jr�z'TestVectorsTestCase.test_sha256_rfc4231r�cCr�)Nr��0�)r�r?r�rArrr�test_sha384_rfc4231Nr�z'TestVectorsTestCase.test_sha384_rfc4231r�cCr�)Nr�r=r�)r�r?r�rArrr�test_sha512_rfc4231Rr�z'TestVectorsTestCase.test_sha512_rfc4231c	Cs�Gdd�dt�}t���^t�dt�|�t��tjdd|d�|�d�Wd�n1s0wYd|_	|�t��tjdd|d�|�d	�Wd�n1sUwYWd�dSWd�dS1smwYdS)
Nc@s(eZdZdZdd�Zdd�Zdd�ZdS)	zJTestVectorsTestCase.test_legacy_block_size_warnings.<locals>.MockCrazyHashz#Ain't no block_size attribute here.cWstj|�|_|jj|_dSrx)r?r��_xr )r"rrrr�__init__ZszSTestVectorsTestCase.test_legacy_block_size_warnings.<locals>.MockCrazyHash.__init__cSs|j�|�dSrx)r�r+)r"�vrrrr+]szQTestVectorsTestCase.test_legacy_block_size_warnings.<locals>.MockCrazyHash.updatecSs
|j��Srx)r�rrArrrr_s
zQTestVectorsTestCase.test_legacy_block_size_warnings.<locals>.MockCrazyHash.digestN)�__name__�
__module__�__qualname__�__doc__r�r+rrrrr�
MockCrazyHashXs
r��error�a�br&z)Expected warning about missing block_sizerLz'Expected warning about small block_size)
�objectr
r�simplefilter�RuntimeWarning�assertRaisesr)r�failr!)r"r�rrr�test_legacy_block_size_warningsVs

���"�z3TestVectorsTestCase.test_legacy_block_size_warningscCs�|�td��d}d}tj||dd�Wd�n1swY|�td��t�||�Wd�n1s9wY|�td��tj||dd�Wd�dS1sXwYdS)z5The digestmod parameter is required as of Python 3.8.zrequired.*digestmodrDrENr&�)�msgr')�assertRaisesRegex�	TypeErrorr)rr,)r"r3r4rrr�test_with_digestmod_no_defaultms��"�z2TestVectorsTestCase.test_with_digestmod_no_defaultN)r�r�r�r%r7r�requires_hashdigestrZrgr�r�r�r�r�r�r�rrrrr(s&	J
)
'w




rc@s�eZdZdZe�d�dd��Ze�d�dd��Ze�d�dd��Ze�d�d	d
��Z	e�d�dd��Z
e�d�d
d��Ze�d�dd��Ze
�edud�dd��Ze
�edud�dd��ZdS)�ConstructorTestCase�@6c845b47f52b3b47f6590c502db7825aad757bf4fadc8fa972f7cd2e76a5bdebr�cCs4z
tjddd�WdSty|�d�YdSw)N�keyr�r&z+Standard constructor call raised exception.)r)r�	Exceptionr�rArrr�test_normals
�zConstructorTestCase.test_normalcC�>|�t��tjddd�}Wd�dS1swYdS�Nr3r�r&)r�r�r)r�r"r#rrr�test_with_str_key��"�z%ConstructorTestCase.test_with_str_keycCr�r�)r�r�r)r,r�rrr�test_dot_new_with_str_key�r�z-ConstructorTestCase.test_dot_new_with_str_keycCsHz
tjdddd�}Wnty|�d�Ynw|�|��|j�dS)Nr��
hash this!r�r&z5Constructor call with text argument raised exception.)r)rr�r�rr�expectedr�rrr�
test_withtext�s�z!ConstructorTestCase.test_withtextcCsPztjtd�td�dd�}Wnty|�d�Ynw|�|��|j�dS)Nr�r�r�r&z;Constructor call with bytearray arguments raised exception.)r)r�	bytearrayr�r�rrr�r�rrr�test_with_bytearray�s
��z'ConstructorTestCase.test_with_bytearraycCsLztjdtd�dd�}Wnty|�d�Ynw|�|��|j�dS)Nr�r�r�r&z6Constructor call with memoryview msg raised exception.)r)r�
memoryviewr�r�rrr�r�rrr�test_with_memoryview_msg�s�z,ConstructorTestCase.test_with_memoryview_msgcCs6zt�ddtj�}WdSty|�d�YdSw)Nr��z6Constructor call with hashlib.sha256 raised exception.)r)rr?r�r�r�r�rrr�test_withmodule�s
�z#ConstructorTestCase.test_withmoduleNz
need _hashlibcCsBt|t�|�td��dt_Wd�dS1swYdS)Nzimmutable type)r�C_HMACr�r��valuerArrr�test_internal_types�s
"�z'ConstructorTestCase.test_internal_typeszneed _sha256cCsZtjddtjd�}|�|��|j�|�|jd�t�ddtj�}|�|t	�
|j��dS)Nr�r�r&zhmac-sha256)r)r�
sha256_moduler�rrr�rrrr)r"r#rrrr�test_with_sha256_module�s
z+ConstructorTestCase.test_with_sha256_module)r�r�r�r�rr�r�r�r�r�r�r�r��unittest�
skipUnlessr�r�r�r�rrrrr�ys*�







r�c@seZdZe�d�dd��ZdS)�SanityTestCaser�cCsVztjddd�}|�d�|��|��|��WdSty*|�d�YdSw)Ns
my secret keyr�r&scompute the hash of this text!z3Exception raised during normal usage of HMAC class.)r)rr+rrr*r�r�r�rrr�test_exercise_all_methods�s
�z(SanityTestCase.test_exercise_all_methodsN)r�r�r�rr�r�rrrrr��sr�c@sveZdZe�d�dd��Ze�d�dd��Ze�e	dud�e�d�dd	���Z
e�d�d
d��Ze�d�dd
��ZdS)�CopyTestCaser�cCs^tj�tj�}|jdddd�|��}|�t|j�t|j�d�|�t|j�t|j�d�dS)Nr��msgr�r&zTypes of inner don't match.zTypes of outer don't match.)	r)rr-r.r*r�type�_inner�_outer�r"�h1r6rrr�test_attributes_old�s��z CopyTestCase.test_attributes_oldcCs�tj�tj�}|jdddd�|��}|�t|�t|�kd�|�t|j�t|j�kd�|�t|j�t|j�kd�|�	|j
d�dS)Nr�r�r�r&�"No real copy of the HMAC instance.z&No real copy of the attribute 'inner'.z&No real copy of the attribute 'outer'.)r)rr-r.r*�
assertTrue�idr�r��assertIs�_hmacr�rrr�test_realcopy_old�s��zCopyTestCase.test_realcopy_oldNztest requires _hashopensslcCsDtj�tj�}|jdddd�|��}|�t|j�t|j�k�dS)Nr�r�r�r&)r)rr-r2r*r�r�r�r�rrr�test_realcopy_hmac�szCopyTestCase.test_realcopy_hmaccCsPtjddd�}|�d�|��}|�|��|��d�|�|��|��d�dS)Nr�r�r&�some random text�-Digest of copy doesn't match original digest.�3Hexdigest of copy doesn't match original hexdigest.)r)rr+r*rrrr�rrr�
test_equality�s
��zCopyTestCase.test_equalitycCshtjddd�}|�d�|��}|�t|�t|�kd�|�|��|��d�|�|��|��d�dS)Nr�r�r&r�r�r�r�)	r)r,r+r*r�r�rrrr�rrr�test_equality_news
���zCopyTestCase.test_equality_new)
r�r�r�rr�r�r�r��skipIfr1r�r�r�rrrrr��s





r�c@s<eZdZdd�Zdd�Ze�edud�dd��Zd	d
�Z	dS)�CompareDigestTestCasecCs8|�tj�tdur|�tjt�dS|�tjt�dSrx)�_test_compare_digestr)r�openssl_compare_digestr��operator_compare_digestrArrr�test_hmac_compare_digestsz.CompareDigestTestCase.test_hmac_compare_digestcC�|�t�dSrx)r�r�rArrr�test_operator_compare_digestsz2CompareDigestTestCase.test_operator_compare_digestNztest requires _hashlibcCr�rx)r�r�rArrr�test_openssl_compare_digest!sz1CompareDigestTestCase.test_openssl_compare_digestcCs�d\}}|�t|||�d\}}|�t|||�d\}}|�t|||�d\}}|�t|||�d\}}|�t|||�d\}}|�|||��d\}}|�|||��d\}}|�|||��d	\}}|�|||��d
\}}|�|||��d\}}|�|||��td�td�}}|�|||��td�td
�}}|�|||��td�td�}}|�|||��td�d}}|�|||��|�|||��td�d
}}|�|||��|�|||��td�d}}|�|||��|�|||��d\}}|�|||��d\}}|�|||��d\}}|�|||��d\}}|�t|||�d\}}|�t|||�d\}}|�t|||�d\}}|�t|||�d\}}|�t|||�Gdd�dt�}|d�|d�}}|�|||��|d�d}}|�|||��|d�|d�}}|�|||��Gdd�dt�}|d�|d�}}|�|||��|d�d}}|�|||��|d�|d�}}|�|||��dS)N)�d��)r��foobar)r�r�)�foobarr�)r�r�)r��foo)�ޭ��sޭ)r��foobaz)r�s���)r�r�)r�r�r�r�r�)r�r�)�foor�)r��foobaz)r�rL)�fooär�c@�eZdZdd�ZdS)z9CompareDigestTestCase._test_compare_digest.<locals>.mystrcS�dS�NFr�r"�otherrrr�__eq__y�z@CompareDigestTestCase._test_compare_digest.<locals>.mystr.__eq__N�r�r�r�r�rrrr�mystrx�r�r�r�c@r�)z;CompareDigestTestCase._test_compare_digest.<locals>.mybytescSr�r�rr�rrrr��r�zBCompareDigestTestCase._test_compare_digest.<locals>.mybytes.__eq__Nr�rrrr�mybytes�r�r�)r�r��assertFalser�r��strrX)r"r�a�br�r�rrrr�%s�z*CompareDigestTestCase._test_compare_digest)
r�r�r�r�r�r�r�r�r�r�rrrrr�s
r��__main__)!rrr)r?r��
unittest.mockr
�test.supportrr�	_operatorrr��_hashlibr1rr�rr/rr��ImportError�_sha256r�r�TestCaserr�r�r�r�r��mainrrrr�<module>sH��
SO=z�

Youez - 2016 - github.com/yon3zu
LinuXploit