+
    Bik              
       	   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	u H
t
 ^ RIt^ RIt^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIHtHtHtHt ^ RIHtHt  ^ RIt^ RIHt  ^ RIt R t! ! R R	4      t" ! R
 R]"4      t#]
PH                  ! 4        ! R R]"4      4       t%]&! 4       t' ! R R4      t( ! R R4      t)R t*R t+ ! R R]"](])4      t, ! R R]"](])4      t-]
P\                  ! 4        ! R R](])4      4       t/ ! R R]%](])4      t0 ! R R4      t1 ! R R](])]14      t2 ! R  R!]#]24      t3 ! R" R#]/]24      t4 ! R$ R%]0]24      t5 ! R& R']]24      t6 ! R( R)]#]4      t7 ! R* R+],]3]]6]7]Pp                  4      t9 ! R, R-],]3]]6]7]Pp                  4      t: ! R. R/]-]3]]6]7]Pp                  4      t; ! R0 R1]-]3]]6]7]Pp                  4      t< ! R2 R3]4]]6]Pp                  4      t= ! R4 R5]5]]6]Pp                  4      t> ! R6 R7](])4      t? ! R8 R9](])]14      t@ ! R: R;]#]?]@4      tA ! R< R=],]A]Pp                  4      tB ! R> R?]-]A]Pp                  4      tC ! R@ RA]?]@4      tD ! RB RC]/]D]Pp                  4      tE ! RD RE]0]D]Pp                  4      tF ! RF RG](4      tG]
P                  ! RH4       ! RI RJ],]#]G]Pp                  4      4       tI]
P                  ! RH4       ! RK RL]/]G]Pp                  4      4       tK ! RM RN]0]G]Pp                  4      tL ! RO RP4      tM]!! 4        ! RQ RR]#]M]Pp                  4      4       tN]
P                  ! RH4       ! RS RT]M]Pp                  4      4       tO ! RU RV]%]M]Pp                  4      tP ! RW RX4      tQ]
P                  ! RH4       ! RY RZ]Q]Pp                  4      4       tR ! R[ R\]Q4      tS]
P                  ! RH4       ! R] R^]S]Pp                  4      4       tT]
PH                  ! 4        ! R_ R`]S]Pp                  4      4       tU ! Ra Rb4      tV ! Rc Rd]V]Pp                  4      tW]
P\                  ! 4        ! Re Rf]V]Pp                  4      4       tX ! Rg Rh]V]Pp                  4      tY ! Ri Rj]Pp                  4      tZ ! Rk Rl]%]Pp                  4      t[]\Rm8X  d   ]P                  ! 4        R# R#   ] d	    RtRt ELOi ; i  ] d    Rt  ELZi ; i)na  Test suite for HMAC.

Python provides three different implementations of HMAC:

- OpenSSL HMAC using OpenSSL hash functions.
- HACL* HMAC using HACL* hash functions.
- Generic Python HMAC using user-defined hash functions.

The generic Python HMAC implementation is able to use OpenSSL
callables or names, HACL* named hash functions or arbitrary
objects implementing PEP 247 interface.

In the two first cases, Python HMAC wraps a C HMAC object (either OpenSSL
or HACL*-based). As a last resort, HMAC is re-implemented in pure Python.
It is however interesting to test the pure Python implementation against
the OpenSSL and HACL* hash functions.
N)_compare_digest)check_disallow_instantiation)BuiltinHashFunctionsTraitHashFunctionsTraitNamedHashFunctionsTraitOpenSSLHashFunctionsTrait)import_fresh_moduleimport_module)compare_digestc                  <    \         P                  ! \        R J R4      # )Nzrequires _sha2)unittestskipIfsha2     %/usr/lib/python3.14/test/test_hmac.pyrequires_builtin_sha2r   5   s    ??44<)9::r   c                       ] tR t^9tRtRtRtR# )ModuleMixinz(Mixin with a HMAC module implementation.Nr   )__name__
__module____qualname____firstlineno____doc__hmac__static_attributes__r   r   r   r   r   9   s
    2Dr   r   c                   @   a a ] tR t^?t oRt]V 3R l4       tRtVtV ;t	# )PyModuleMixinzPure Python implementation of HMAC.

The underlying hash functions may be OpenSSL-based or HACL* based,
depending on whether OpenSSL is present or not.
c                L   < \         SV `  4        \        R RR.R7      V n        R# )r   _hashlib_hmacblockedNsuper
setUpClassr   r   cls	__class__s   &r   r%   PyModuleMixin.setUpClassF   s!    &v
G7LMr   r   
r   r   r   r   r   classmethodr%   r   __classdictcell____classcell__r(   __classdict__s   @@r   r   r   ?   s&      N N Nr   r   c                   @   a a ] tR t^Lt oRt]V 3R l4       tRtVtV ;t	# )BuiltinModuleMixinz&Built-in HACL* implementation of HMAC.c                D   < \         SV `  4        \        R 4      V n        R# )r    Nr#   r&   s   &r   r%   BuiltinModuleMixin.setUpClassP   s    &w/r   r   r*   r.   s   @@r   r1   r1   L   s     00 0 0r   r1   c                   8   a  ] tR t^Zt o RtR]3R ltR tRtV t	R# )CreatorMixinz/Mixin exposing a method creating a HMAC object.Nc                    \         h)zCreate a new HMAC object.

Implementations should accept arbitrary 'digestmod' as this
method can be used to test which exceptions are being raised.
NotImplementedErrorselfkeymsg	digestmods   &&&&r   hmac_newCreatorMixin.hmac_new]   
     "!r   c                F    \         P                  ! V P                  VR7      # )z=Return a specialization of hmac_new() with a bound digestmod.r=   )	functoolspartialr>   r:   r=   s   &&r   bind_hmac_newCreatorMixin.bind_hmac_newe   s      )DDr   r   )
r   r   r   r   r   DIGESTMOD_SENTINELr>   rF   r   r,   r/   s   @r   r5   r5   Z   s     9 $0B "E Er   r5   c                   8   a  ] tR t^jt o RtR]3R ltR tRtV t	R# )DigestMixinz0Mixin exposing a method computing a HMAC digest.Nc                    \         h)zCompute a HMAC digest.

Implementations should accept arbitrary 'digestmod' as this
method can be used to test which exceptions are being raised.
r7   r9   s   &&&&r   hmac_digestDigestMixin.hmac_digestm   r@   r   c                F    \         P                  ! V P                  VR7      # )z@Return a specialization of hmac_digest() with a bound digestmod.rB   )rC   rD   rM   rE   s   &&r   bind_hmac_digestDigestMixin.bind_hmac_digestu   s      !1!1YGGr   r   )
r   r   r   r   r   rH   rM   rP   r   r,   rI   s   @r   rK   rK   j   s     :#'3E "H Hr   rK   c                 :    V\         J d	   V ! W4      # V ! WVR 7      # )rB   rH   )new_funcr;   r<   r=   s   &&&&r   _call_newobj_funcrU   z   s#    &&!!C	22r   c                 :    V\         J d	   V ! W4      # V ! WVR 7      # ))digestrS   )digest_funcr;   r<   r=   s   &&&&r   _call_digest_funcrY      s#    &&3$$s	22r   c                   @   a  ] tR t^t o RtR]3R ltR]3R ltRtV t	R# )ThroughObjectMixinzMixin delegating to <module>.HMAC() and <module>.HMAC(...).digest().

Both the C implementation and the Python implementation of HMAC should
expose a HMAC class with the same functionalities.
Nc                D    \        V P                  P                  WV4      # )z:Create a HMAC object via a module-level class constructor.)rU   r   HMACr9   s   &&&&r   r>   ThroughObjectMixin.hmac_new   s     9EEr   c                L    \        V P                  WV4      P                  4       # )zACall the digest() method on a HMAC object obtained by hmac_new().)rU   r>   rW   r9   s   &&&&r   rM   ThroughObjectMixin.hmac_digest   s     )DKKMMr   r   
r   r   r   r   r   rH   r>   rM   r   r,   rI   s   @r   r[   r[      s,      !%0B F $(3E N Nr   r[   c                   @   a  ] tR t^t o RtR]3R ltR]3R ltRtV t	R# )ThroughModuleAPIMixinz9Mixin delegating to <module>.new() and <module>.digest().Nc                D    \        V P                  P                  WV4      # )z1Create a HMAC object via a module-level function.rU   r   newr9   s   &&&&r   r>   ThroughModuleAPIMixin.hmac_new   s     )DDr   c                D    \        V P                  P                  WV4      # )z!One-shot HMAC digest computation.)rY   r   rW   r9   s   &&&&r   rM   !ThroughModuleAPIMixin.hmac_digest   s     !1!13YGGr   r   ra   rI   s   @r   rc   rc      s(     C $0B E $(3E H Hr   rc   c                   @   a  ] tR t^t o RtR]3R ltR]3R ltRtV t	R# )ThroughOpenSSLAPIMixinzCMixin delegating to _hashlib.hmac_new() and _hashlib.hmac_digest().Nc                8    \        \        P                  WV4      # N)rU   r   r>   r9   s   &&&&r   r>   ThroughOpenSSLAPIMixin.hmac_new   s     !2!2CiHHr   c                8    \        \        P                  WV4      # rm   )rY   r   rM   r9   s   &&&&r   rM   "ThroughOpenSSLAPIMixin.hmac_digest   s     !5!5sKKr   r   ra   rI   s   @r   rk   rk      s(     M $0B I $(3E L Lr   rk   c                   @   a  ] tR t^t o RtR]3R ltR]3R ltRtV t	R# )ThroughBuiltinAPIMixinz;Mixin delegating to _hmac.new() and _hmac.compute_digest().Nc                D    \        V P                  P                  WV4      # rm   re   r9   s   &&&&r   r>   ThroughBuiltinAPIMixin.hmac_new   s     )DDr   c                D    \        V P                  P                  WV4      # rm   )rY   r   compute_digestr9   s   &&&&r   rM   "ThroughBuiltinAPIMixin.hmac_digest   s     !9!93YOOr   r   ra   rI   s   @r   rr   rr      s(     E $0B E $(3E P Pr   rr   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )ObjectCheckerMixinzCMixin for checking HMAC objects (pure Python, OpenSSL or built-in).c                N    V P                  WWE4       V P                  WV4       R# )z1Check a HMAC object 'h' against the given values.N)check_internalscheck_hexdigest)r:   h	hexdigesthashnamedigest_size
block_sizes   &&&&&&r   check_objectObjectCheckerMixin.check_object   s"    Q+BQ;7r   c                    V P                  VP                  RV 24       V P                  VP                  V4       V P                  VP                  V4       R# )z/Check the constant attributes of a HMAC object.hmac-N)assertEqualnamer   r   )r:   r}   r   r   r   s   &&&&&r   r{   "ObjectCheckerMixin.check_internals   sE    5
!344z2r   c                8   V P                  \        VP                  4       4      V4       V P                  VP                  4       \        P                  ! V4      4       V P                  VP                  4       P                  4       VP                  4       4       R# )z*Check the HMAC digest of 'h' and its size.N)r   lenrW   binascii	unhexlifyr~   upper)r:   r}   r~   r   s   &&&&r   r|   "ObjectCheckerMixin.check_hexdigest   sc    QXXZ+6X%7%7	%BC,,.	0ABr   r   N)
r   r   r   r   r   r   r{   r|   r   r,   rI   s   @r   ry   ry      s     M8
3C Cr   ry   c                      a  ] tR t^t o RtRR ltRR ltR tR tR t	]
P                  ! / 4      3R ltR	 tR
 t]
P                  ! / 4      3R ltR tR tRtV tR# )AssertersMixinzMixin class for common tests.Nc               T    V P                  V\        4       V P                  WVR7      # )a  Alternative implementation of hmac_new().

This is typically useful when one needs to test against an HMAC
implementation which only recognizes underlying hash functions
by their name (all HMAC implementations must at least recognize
hash functions by their names but some may use aliases such as
`hashlib.sha1` instead of "sha1").

Unlike hmac_new(), this method may assert the type of 'hashname'
as it should only be used in tests that are expected to create
a HMAC object.
rB   )assertIsInstancestrr>   r:   r;   r<   r   s   &&&$r   hmac_new_by_nameAssertersMixin.hmac_new_by_name   s'     	h,}}S}::r   c               T    V P                  V\        4       V P                  WVR7      # )zAlternative implementation of hmac_digest().

Unlike hmac_digest(), this method may assert the type of 'hashname'
as it should only be used in tests that are expected to compute a
HMAC digest.
rB   )r   r   rM   r   s   &&&$r   hmac_digest_by_name"AssertersMixin.hmac_digest_by_name   s*     	h,H==r   c                   WE8X  d   V.pMWE.pV Fu  p	V P                  V	R7      ;_uu_ 4        V P                  WW9WVV4       V P                  WW9V4       V P                  WW9WVV4       V P	                  WW9WVV4       RRR4       Kw  	  V P                  WW5Wg4       V P                  WW5V4       R#   + '       g   i     K  ; i)a  Check that HMAC(key, msg) == digest.

The 'hashfunc' and 'hashname' are used as 'digestmod' values,
thereby allowing to test the underlying dispatching mechanism.

Note that 'hashfunc' may be a string, a callable, or a PEP-257
module. Note that not all HMAC implementations may recognize the
same set of types for 'hashfunc', but they should always accept
a hash function by its name.
rB   N)subTestassert_hmac_newassert_hmac_hexdigestassert_hmac_common_casesassert_hmac_extra_casesassert_hmac_new_by_nameassert_hmac_hexdigest_by_name)
r:   r;   r<   r~   hashfuncr   r   r   choicesr=   s
   &&&&&&&&  r   assert_hmacAssertersMixin.assert_hmac   s     jG*G I	22$$i: **iK --i: ,,i: 32 !$ 	$$i;	
 	**i;	
) 322s   AB11Cc                J    V P                  WW5WgV P                  RV/R7       R# )zeCheck that HMAC(key, msg) == digest.

This test uses the `hmac_new()` method to create HMAC objects.
r=   hmac_new_funchmac_new_kwdsN)check_hmac_newr>   r:   r;   r<   r~   r=   r   r   r   s   &&&&&&&&r   r   AssertersMixin.assert_hmac_new  s-     	i;--&	2 	 	
r   c                J    V P                  WW4WVV P                  RV/R7       R# )zmCheck that HMAC(key, msg) == digest.

This test uses the `hmac_new_by_name()` method to create HMAC objects.
r   r   N)r   r   )r:   r;   r<   r~   r   r   r   s   &&&&&&&r   r   &AssertersMixin.assert_hmac_new_by_name#  s/     	i;//%x0 	 	
r   c	                  a aaaaaa S! SS3/ SB p	S P                  V	SVSV4       VVVVVVV 3R lp
S P                  R4      ;_uu_ 4        V
! 4        RRR4       S P                  R4      ;_uu_ 4        V
! R4       RRR4       S P                  R4      ;_uu_ 4        V
! R4       RRR4       R#   + '       g   i     Lf; i  + '       g   i     LO; i  + '       g   i     R# ; i)zCheck that HMAC(key, msg) == digest.

This also tests that using an empty/None initial message and
then calling `h.update(msg)` produces the same result, namely
that HMAC(key, msg) is equivalent to HMAC(key).update(msg).
c                  h   < S! S.V O5/ SB pVP                  S4       SP                  VSS4       R # rm   )updater|   )	argsr}   r   r~   r   r   r;   r<   r:   s	   * r   hmac_new_feed4AssertersMixin.check_hmac_new.<locals>.hmac_new_feed=  s4    c:D:M:AHHSM  I{;r   zno initial messageNzinitial message is emptyr   zinitial message is None)r   r   )r:   r;   r<   r~   r   r   r   r   r   r}   r   s   ffff&f&ff  r   r   AssertersMixin.check_hmac_new0  s     #s4m4!Y+zJ	< 	<
 \\.//O 0\\455# 6\\344$ 54	 0/55444s$   B25	C	C2C	C	C)	c           	     H    V P                  WW5V P                  RV/R7       R# )z.Check a HMAC digest computed by hmac_digest().r=   hmac_digest_funchmac_digest_kwdsN)check_hmac_hexdigestrM   )r:   r;   r<   r~   r=   r   s   &&&&&&r   r   $AssertersMixin.assert_hmac_hexdigestI  s-     	!!i!--)95 	" 	
r   c           	     t    V P                  V\        4       V P                  WW5V P                  RV/R7       R# )z6Check a HMAC digest computed by hmac_digest_by_name().r   r   N)r   r   r   r   )r:   r;   r<   r~   r   r   s   &&&&&&r   r   ,AssertersMixin.assert_hmac_hexdigest_by_nameS  s=     	h,!!i!55((3 	" 	
r   c                    V! W3/ VB pV P                  \        V4      V4       V P                  V\        P                  ! V4      4       V# )zCheck and return a HMAC digest computed by hmac_digest_func().

This HMAC digest is computed by:

    hmac_digest_func(key, msg, **hmac_digest_kwds)

This is typically useful for checking one-shot HMAC functions.
)r   r   r   r   )r:   r;   r<   r~   r   r   r   ds   &&&&&&& r   r   #AssertersMixin.check_hmac_hexdigest^  sH     S:)9:Q-H..y9:r   c                    V P                  WR7      pVP                  4       p	V	P                  R4       VP                  V4       V P                  WWVV4       R# )z(Common tests executed by all subclasses.)r   s&   test update should not affect originalN)r   copyr   r   )
r:   r;   r<   r~   r=   r   r   r   h1h2s
   &&&&&&&&  r   r   'AssertersMixin.assert_hmac_common_caseso  sL     ""3":WWY
		;<
		#"
Kr   c                    R# )z,Extra tests that can be added in subclasses.Nr   r   s   &&&&&&&&r   r   &AssertersMixin.assert_hmac_extra_casesy  s    r   r   rm   )r   r   r   r   r   r   r   r   r   r   typesMappingProxyTyper   r   r   r   r   r   r   r,   rI   s   @r   r   r      sf     '; >)
V

 &+%;%;B%? 2
	
 ,1+A+A"+E"L; ;r   r   c                   &   a  ] tR tRt o R tRtV tR# )PyAssertersMixini  c                    V P                   P                  P                  V P                   P                  4      pVP                  WVR 7       V P	                  WWVV4       R# )rB   N)r   r]   __new__	_init_oldr   )	r:   r;   r<   r~   r=   r   r   r   r}   s	   &&&&&&&& r   r   (PyAssertersMixin.assert_hmac_extra_cases  sF     IINN""499>>2	C	2!zJr   r   N)r   r   r   r   r   r   r,   rI   s   @r   r   r     s     K Kr   r   c                   4   a  ] tR tRt o RR ltRR ltRtV tR# )OpenSSLAssertersMixini  Nc               z    V P                  V\        4       \        \        R V 24      pV P	                  WVR7      # openssl_rB   )r   r   getattrr   r>   r:   r;   r<   r   openssl_funcs   &&&$ r   r   &OpenSSLAssertersMixin.hmac_new_by_name  s8    h,x8H:)>?}}S}>>r   c               z    V P                  V\        4       \        \        R V 24      pV P	                  WVR7      # r   )r   r   r   r   rM   r   s   &&&$ r   r   )OpenSSLAssertersMixin.hmac_digest_by_name  s;    h,x8H:)>?LAAr   r   rm   )r   r   r   r   r   r   r   r,   rI   s   @r   r   r     s     ?
B Br   r   c                       ] tR tRtRtR# )BuiltinAssertersMixini  r   N)r   r   r   r   r   r   r   r   r   r     s    r   r   c                   f   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tRtV tR# )RFCTestCaseMixini  a+  Test HMAC implementations against RFC 2202/4231 and NIST test vectors.

- Test vectors for MD5 and SHA-1 are taken from RFC 2202.
- Test vectors for SHA-2 are taken from RFC 4231.
- Test vectors for SHA-3 are NIST's test vectors [1].

[1] https://csrc.nist.gov/projects/message-authentication-codes
c                   a  V 3R  lpV! RRR4       V! RRR4       V! RRR4       V! \        \        ^^4      4      RR4       V! RRR	4       V! RR
R4       V! RRR4       R# )c           	      H   < SP                  WVSP                  R ^^@4       R# )md5N)r   r   r;   r<   r~   r:   s   &&&r   md5test2RFCTestCaseMixin.test_md5_rfc2202.<locals>.md5test  s    Sy$((E2rJr      Hi There 9294727a3638bb1c13f48ef8158bfc9d   Jefe   what do ya want for nothing? 750c783e6ab0b503eaa86e310a5db738 56be34521d144c88dbb8c733f0e8b3f6 697eaf0aca3a3aea3a75164746ffaa79   Test With Truncation 56461ef2342edc00f9bab995690efd4c6   Test Using Larger Than Block-Size Key - Hash Key First 6b1ab7fe4bd7bf8f0b62e6ce61b9d0cdI   Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data 6f630fad67cda0ee1fb1f562db3aa53eNs   s   2   2   s   P   bytesrange)r:   r   s   f r   test_md5_rfc2202!RFCTestCaseMixin.test_md5_rfc2202  s    	K 	2	4 	/2	4 	2	4 	eArl#2	4 	'2	4 	I2	4 	82	4r   c                   a  V 3R  lpV! RRR4       V! RRR4       V! RRR4       V! \        \        ^^4      4      RR4       V! RRR	4       V! RR
R4       V! RRR4       R# )c           	      H   < SP                  WVSP                  R ^^@4       R# )sha1N)r   r   r   s   &&&r   shatest3RFCTestCaseMixin.test_sha1_rfc2202.<locals>.shatest  s    Sy$))VRLr   r   (b617318655057264e28bc0b6fb378c8ef146be00r   r   (effcdf6ae5eb2fa2d27416d5f184df9c259a7c79(125d7342b9ac11cd91a39af48aa17b4f63f175d3(4c9007f4026250c6bc8414f9bf50c86c2d7235dar   (4c1a03424b55e07fe7f27be1d58bb9324a9a5a04r   (aa4ae5e15272d00e95705637ce8a3b55ed402112r   (e8e99d0f45237d786d6bbaa7965c7808bbff1a91N      r   r   s   r   r   )r:   r   s   f r   test_sha1_rfc2202"RFCTestCaseMixin.test_sha1_rfc2202  s    	M 	:	< 	/:	< 	:	< 	eArl#:	< 	':	< 	I:	< 	8:	<r   c                B    V P                  V P                  R ^^@4       R# )sha224N)_test_sha2_rfc4231r  r:   s   &r   test_sha2_224_rfc4231&RFCTestCaseMixin.test_sha2_224_rfc4231      Xr2>r   c                B    V P                  V P                  R ^ ^@4       R# sha256N)r  r  r  s   &r   test_sha2_256_rfc4231&RFCTestCaseMixin.test_sha2_256_rfc4231  r  r   c                B    V P                  V P                  R ^0^4       R# )sha384N)r  r  r  s   &r   test_sha2_384_rfc4231&RFCTestCaseMixin.test_sha2_384_rfc4231      Xr3?r   c                B    V P                  V P                  R ^@^4       R# )sha512N)r  r  r  s   &r   test_sha2_512_rfc4231&RFCTestCaseMixin.test_sha2_512_rfc4231  r  r   c                <  a aaaa VVVVV 3R  lpV! R%RRRRRRRRR	/R
7       V! RRRRRRRRRR/R
7       V! R&R'RRRRRRRR/R
7       V! \        R \        ^^4       4       4      R(RRRRRRRR/R
7       V! R)RRRRRRRRR/R
7       V! R)RRR RR!RR"RR#/R
7       R$# )*c           
      H   < VS,          pSP                  WVSSSSR 7       R# )r   r   r   r   N)r   )	r;   r<   
hexdigestsr~   r   r   r   r   r:   s	   &&& r   hmactest5RFCTestCaseMixin._test_sha2_rfc4231.<locals>.hmactest  s1    "8,I)!!'%  r   r   r  8896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22r  @b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7r  `afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6r  ڀ87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854)r;   r<   r"  r   r   8a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44@5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843`af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649ڀ164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce73787fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea@773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe`88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27ڀfa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fbc              3   $   "   T F  qx  K  	  R # 5irm   r   ).0xs   & r   	<genexpr>6RFCTestCaseMixin._test_sha2_rfc4231.<locals>.<genexpr>2  s     <&;1&;s   86c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a@82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b`3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffbڀb0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298ddr   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ڀe37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58Nr  r  r   r   s   r   )r:   r   r   r   r   r#  s   fffff r   r  #RFCTestCaseMixin._test_sha2_rfc4231  s}   		 		 	\   :  B  B   B	" 	W4  :  B  B   B	" 	\!  :  B  B   B	" 	U<eD(&;<<!  :  B  B   B	" 	]/   :  B  B   B	$ 	]1   :  B  B   B	r   c                    \        \        ^4      4      RR3\        \        ^4      4      RR3\        \        ^4      4      RR33 F'  w  rpV P                  WVV P                  R^^R7       K)  	  R	# )
   "   Sample message for keylen<blocklen8332cfd59347fdb8e576e77260be4aba2d6dc53117b3bfb52c6d18c04"   Sample message for keylen=blocklen8d8b733bcf66c644a12323d564e24dcf3fc75f231f3b67968359100c7"   Sample message for keylen>blocklen8078695eecc227c636ad31d063a15dd05a7e819a66ec6d8de1e193e59sha3_224r!  N)r   r   r   rK  r:   r;   r<   r~   s   &   r   test_sha3_224_nist#RFCTestCaseMixin.test_sha3_224_nisti  s     eBi 5J
 eCj!5J
 eCj!5J$
Ci )3  $
r   c                    \        \        ^ 4      4      RR3\        \        ^4      4      RR3\        \        ^4      4      RR33 F'  w  rpV P                  WVV P                  R^ ^R7       K)  	  R	# )
    rE  @4fe8e202c4f058e8dddc23d8c34e467343e23555e24fc2f025d598f558f67205rG  @68b94e2e538a9be4103bebb5aa016d47961d4d1aa906061313b557f8af2c3faarI  @9bcf2c238e235c3ce88404e813bd2f3a97185ac6f238c63d6229a00b07974258sha3_256r!  N)r   r   r   rT  rL  s   &   r   test_sha3_256_nist#RFCTestCaseMixin.test_sha3_256_nist  s     eBi 53 eCj!53 eCj!53$
Ci$ )3  %$
r   c                    \        \        ^04      4      RR3\        \        ^h4      4      RR3\        \        ^4      4      RR33 F'  w  rpV P                  WVV P                  R^0^hR7       K)  	  R	# )
0   rE  `d588a3c51f3f2d906e8298c1199aa8ff6296218127f6b38a90b6afe2c5617725bc99987f79b22a557b6520db710b7f42rG  `a27d24b592e8c8cbf6d4ce6fc5bf62d8fc98bf2d486640d9eb8099e24047837f5f3bffbe92dcce90b4ed5b1e7e44fa90rI  `e5ae4c739f455279368ebf36d4f5354c95aa184c899d3870e460ebc288ef1f9470053f73f7c6da2a71bcaec38ce7d6acsha3_384r!  N)r   r   r   r\  rL  s   &   r   test_sha3_384_nist#RFCTestCaseMixin.test_sha3_384_nist  s     eBi 53 eCj!53 eCj!53$
Ci* )3  +$
r   c                    \        \        ^@4      4      RR3\        \        ^H4      4      RR3\        \        ^4      4      RR33 F'  w  rpV P                  WVV P                  R^@^HR7       K)  	  R	# )
@   rE  ڀ4efd629d6c71bf86162658f29943b1c308ce27cdfa6db0d9c3ce81763f9cbce5f7ebe9868031db1a8f8eb7b6b95e5c5e3f657a8996c86a2f6527e307f0213196rG  ڀ544e257ea2a3e5ea19a590e6a24b724ce6327757723fe2751b75bf007d80f6b360744bf1b7a88ea585f9765b47911976d3191cf83c039f5ffab0d29cc9d9b6darI  ڀ5f464f5e5b7848e3885e49b2c385f0694985d0e38966242dc4a5fe3fea4b37d46b65ceced5dcf59438dd840bab22269f0ba7febdb9fcf74602a35666b2a32915sha3_512r!  N)r   r   r   rd  rL  s   &   r   test_sha3_512_nist#RFCTestCaseMixin.test_sha3_512_nist  s     eBi 53 eBi 53 eCj!53$
Ci0 )2  1$
r   r   N)r   r   r   r   r   r   r  r  r  r  r  r  rM  rU  r]  re  r   r,   rI   s   @r   r   r     sL     4B<B??@@un,28 r   r   c                   R   a a ] tR tRt o]V 3R l4       t]V 3R l4       tRtVtV ;t	# )PurePythonInitHMACi  c                  < \         SV `  4        R Fk  p\        V P                  P                  V4      p\
        P                  P                  V P                  P                  VRVR7      pV P                  V4       Km  	  R# )_init_openssl_hmacTautospecwrapsN)rj  _init_builtin_hmac)	r$   r%   r   r   r]   mockpatchobjectenterClassContext)r'   methfncmr(   s   &   r   r%   PurePythonInitHMAC.setUpClass  s`    @D-B""388==$R"PB!!"% Ar   c                   < V P                   P                  P                  P                  4        V P                   P                  P                  P                  4        \
        SV `  4        R # rm   )r   r]   rj  assert_not_calledrn  r$   tearDownClassr&   s   &r   ry   PurePythonInitHMAC.tearDownClass  sD    ((::<((::< 	r   r   )
r   r   r   r   r+   r%   ry  r   r,   r-   r.   s   @@r   rh  rh    s0     & &      r   rh  c                       ] tR tRtRtRtR# )PyRFCOpenSSLTestCasei  zPython implementation of HMAC using hmac.HMAC().

The underlying hash functions are OpenSSL-based but
_init_old() is used instead of _init_openssl_hmac().
r   Nr   r   r   r   r   r   r   r   r   r|  r|        r   r|  c                       ] tR tRtRtRtR# )PyRFCBuiltinTestCasei  zPython implementation of HMAC using hmac.HMAC().

The underlying hash functions are HACL*-based but
_init_old() is used instead of _init_builtin_hmac().
r   Nr}  r   r   r   r  r    r~  r   r  c                       ] tR tRtRtRtR# )PyDotNewOpenSSLRFCTestCasei  zPython implementation of HMAC using hmac.new().

The underlying hash functions are OpenSSL-based but
_init_old() is used instead of _init_openssl_hmac().
r   Nr}  r   r   r   r  r    r~  r   r  c                       ] tR tRtRtRtR# )PyDotNewBuiltinRFCTestCasei  zPython implementation of HMAC using hmac.new().

The underlying hash functions are HACL-based but
_init_old() is used instead of _init_openssl_hmac().
r   Nr}  r   r   r   r  r    r~  r   r  c                       ] tR tRtRtRtR# )OpenSSLRFCTestCasei  zWOpenSSL implementation of HMAC.

The underlying hash functions are also OpenSSL-based.
r   Nr}  r   r   r   r  r    s    r   r  c                   *   a  ] tR tRt o RtR tRtV tR# )BuiltinRFCTestCasei(  z\Built-in HACL* implementation of HMAC.

The underlying hash functions are also HACL*-based.
c           	        V P                  WVR 7      ;_uu_ 4        \        V P                  RV 24      pV P                  \	        V4      4       V P                  WW6V4       RRR4       R#   + '       g   i     R# ; i))r;   r<   r   compute_N)r   r   r   
assertTruecallabler   )	r:   r;   r<   r~   r=   r   r   r   funcs	   &&&&&&&& r   r   *BuiltinRFCTestCase.assert_hmac_extra_cases1  s_     \\cX\>>499
&;<DOOHTN+%%c	M ?>>>s   AA--A>	r   N)r   r   r   r   r   r   r   r,   rI   s   @r   r  r  (  s     
N Nr   r  c                   j   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tRR
 ltR tR tR tRtV tR# )DigestModTestCaseMixini;  zETests for the 'digestmod' parameter for hmac_new() and hmac_digest().c                .    V P                  \        R4      # )z>A context manager catching errors when a digestmod is missing.z [M|m]issing.*required.*digestmod)assertRaisesRegex	TypeErrorr  s   &r   assert_raises_missing_digestmod6DigestModTestCaseMixin.assert_raises_missing_digestmod>  s    %%i&HJ 	Jr   c                .    V P                  \        R4      # )z>A context manager catching errors when a digestmod is unknown.z[Uu]nsupported.*)r  
ValueErrorr  s   &r   assert_raises_unknown_digestmod6DigestModTestCaseMixin.assert_raises_unknown_digestmodC  s    %%j2DEEr   c                @    V P                   pV P                  V4       R # rm   )r  %do_test_constructor_missing_digestmodr:   catchers   & r   "test_constructor_missing_digestmod9DigestModTestCaseMixin.test_constructor_missing_digestmodG      66227;r   c                @    V P                   pV P                  V4       R # rm   )r  %do_test_constructor_unknown_digestmodr  s   & r   "test_constructor_unknown_digestmod9DigestModTestCaseMixin.test_constructor_unknown_digestmodK  r  r   c           
        V P                  4        FI  w  r#pV P                  W4R 7      ;_uu_ 4        V! 4       ;_uu_ 4        V! V/ VB  RRR4       RRR4       KK  	  R#   + '       g   i     L; i  + '       g   i     Ks  ; i)r   kwdsN)&cases_missing_digestmod_in_constructorr   r:   r  r  r   r  s   &&   r   r  <DigestModTestCaseMixin.do_test_constructor_missing_digestmodO  Z     $ K K MD433WYYd#d# 6?33 !N5>Y333#   A3	A 
A3 A0+A33Bc           
        V P                  4        FI  w  r#pV P                  W4R 7      ;_uu_ 4        V! 4       ;_uu_ 4        V! V/ VB  RRR4       RRR4       KK  	  R#   + '       g   i     L; i  + '       g   i     Ks  ; ir  )&cases_unknown_digestmod_in_constructorr   r  s   &&   r   r  <DigestModTestCaseMixin.do_test_constructor_unknown_digestmodT  r  r  c                    \         hrm   r7   r  s   &r   r  =DigestModTestCaseMixin.cases_missing_digestmod_in_constructorY      !!r   c                >    RRrC\         .VOpV P                  WWE4      # )zGenerate cases for missing digestmod tests.

Only the Python implementation should consider "falsey" 'digestmod'
values as being equivalent to a missing one.

   unused key
   unused msg)rH   _invalid_digestmod_cases)r:   r  missing_liker;   r<   r   s   &&&   r   make_missing_digestmod_cases3DigestModTestCaseMixin.make_missing_digestmod_cases\  s+     !-S%55,,TEEr   c                    \         hrm   r7   r  s   &r   r  =DigestModTestCaseMixin.cases_unknown_digestmod_in_constructorf  r  r   c                ,    RRrCV P                  WWB4      # )z+Generate cases for unknown digestmod tests.r  r  )r  )r:   r  bad_digestmodsr;   r<   s   &&&  r   make_unknown_digestmod_cases3DigestModTestCaseMixin.make_unknown_digestmod_casesi  s     -S,,TLLr   c                    . pV FM  pR V/pVP                  W3V34       VP                  WV3V34       VP                  W3VRV/,          34       KO  	  V# )r=   r<   )append)r:   r  r;   r<   r   casesr=   kwargss   &&&&&   r   r  /DigestModTestCaseMixin._invalid_digestmod_casesn  sf     I!9-FLL$/0LL$c
F34LL$%(=>?	 !
 r   r   N)r   )r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r   r,   rI   s   @r   r  r  ;  sH     OJ
F<<$
$
"F"M
 r   r  c                      a  ] tR tRt o RtRtRtRtR tR t	R t
]P                  ! R	4      R
 4       t]P                  ! R	4      R 4       tRtV tR# )ConstructorTestCaseMixinix  z/HMAC constructor tests based on HMAC-SHA-2/256.   keys
   hash this!@6c845b47f52b3b47f6590c502db7825aad757bf4fadc8fa972f7cd2e76a5bdebc                J    V P                  V4       V P                  V4       R # rm   )!do_test_constructor_invalid_types#do_test_constructor_supported_typesr:   hmac_on_key_and_msgs   &&r   do_test_constructor,ConstructorTestCaseMixin.do_test_constructor  s     ../BC001DEr   c                    V P                  \        V^4       V P                  \        VR4       V P                  \        VR^4       V P                  \        VRR4       R# )   r;   r  r<   N)assertRaisesr  r  s   &&r   r  :ConstructorTestCaseMixin.do_test_constructor_invalid_types  sR    )%8!<)%8%@)%8&!D)%8&%Hr   c           
        \         \        3 F  p\         \        \        3 F  pV P                  W#R 7      ;_uu_ 4        V! V! V P                  4      V! V P
                  4      4      pV P                  VP                  R4       V P                  VP                  4       V P                  4       RRR4       K  	  K  	  R#   + '       g   i     K  ; i))tp_keytp_msghmac-sha256N)
r   	bytearray
memoryviewr   r;   r<   r   r   r~   res)r:   r  r  r  r}   s   &&   r   r  <ConstructorTestCaseMixin.do_test_constructor_supported_types  s    i(F )Z8\\\??+F488,<fTXX>NOA$$QVV];$$Q[[]DHH= @? 9 )???s   A0C 	 Cr  c                F    V P                  V P                  R 4      4       R# r  )r  rF   r  s   &r   test_constructor)ConstructorTestCaseMixin.test_constructor  s      !3!3H!=>r   c                    V P                  V P                  V P                  R 4      pV P                  V\        P
                  ! V P                  4      4       R# r  )rM   r;   r<   r   r   r   r  r:   rW   s   & r   test_digest$ConstructorTestCaseMixin.test_digest  s=    !!$((DHHh?!3!3DHH!=>r   r   N)r   r   r   r   r   r;   r<   r  r  r  r  hashlib_helperrequires_hashdigestr  r  r   r,   rI   s   @r   r  r  x  sf     9
C
C
LCFI> ''1? 2? ''1? 2?r   r  c                   `   a  ] tR tRt o R tR t]! 4       R 4       t]! 4       R 4       tRt	V t
R# )PyConstructorBaseMixini  c                B    V P                   . ROr!V P                  W4      # ) )r  NF)r>   r  r:   r  r   s   &  r   r  =PyConstructorBaseMixin.cases_missing_digestmod_in_constructor  s    '8g00??r   c                @    V P                   R .r!V P                  W4      # )unknownr>   r  r  s   &  r   r  =PyConstructorBaseMixin.cases_unknown_digestmod_in_constructor  s     	{g00??r   c                b    V P                  V P                  \        P                  4      4       R # rm   )r  rF   r   r  r  s   &r   test_constructor_with_module3PyConstructorBaseMixin.test_constructor_with_module  s      !3!3DKK!@Ar   c                    V P                  V P                  V P                  \        P                  4      pV P                  V\        P                  ! V P                  4      4       R # rm   )	rM   r;   r<   r   r  r   r   r   r  r  s   & r   test_digest_with_module.PyConstructorBaseMixin.test_digest_with_module  sA    !!$((DHHdkkB!3!3DHH!=>r   r   N)r   r   r   r   r  r  r   r  r  r   r,   rI   s   @r   r  r    sA     @@ B B ? ?r   r  c                       ] tR tRtRtRtR# )PyConstructorTestCasei  z-Test the hmac.HMAC() pure Python constructor.r   Nr}  r   r   r   r  r    s    7r   r  c                   *   a  ] tR tRt o RtR tRtV tR# )PyModuleConstructorTestCasei  z0Test the hmac.new() and hmac.digest() functions.c                F   V P                   pR  pV P                  \        R4      ;_uu_ 4        V! RRV4       RRR4       V P                  \        R4      ;_uu_ 4        V! RRR4       RRR4       V P                  \        R4      ;_uu_ 4        V! RRR4       RRR4       V P                  \        R4      ;_uu_ 4        V! RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     Li; i  + '       g   i     R# ; i)	c                      \        R 4      h)custom exception)RuntimeErrorr   r   r   raiserPPyModuleConstructorTestCase.test_hmac_digest_digestmod_parameter.<locals>.raiser  s    122r   r  r     msgNz	hash typer  rf     )rM   r  r  r  AttributeError)r:   r  r  s   &  r   $test_hmac_digest_digestmod_parameter@PyModuleConstructorTestCase.test_hmac_digest_digestmod_parameter  s    	3 ##L2DEE( F ##J<<+ = ##NE::& ;##NE::& ;: FE =< ;::::s/   CC)C<DC&	)C9	<D	D 	r   N)r   r   r   r   r   r  r   r,   rI   s   @r   r  r    s     :' 'r   r  c                   X   a  ] tR tRt o ]R 4       t]R 4       tR tR tR t	R t
RtV tR	# )
!ExtensionConstructorTestCaseMixini  c                    \         h)z*The underlying (non-instantiable) C class.r7   r  s   &r   obj_type*ExtensionConstructorTestCaseMixin.obj_type  
     "!r   c                    \         h)zAThe exact exception class raised upon invalid 'digestmod' values.r7   r  s   &r   exc_type*ExtensionConstructorTestCaseMixin.exc_type  r	  r   c                    \        W P                  4       V P                  \        R 4      ;_uu_ 4        RV P                  n        RRR4       R#   + '       g   i     R# ; i)zimmutable typeN)r   r  r  r  valuer  s   &r   test_internal_types5ExtensionConstructorTestCaseMixin.test_internal_types  s>    $T==9##I/?@@"&DMM A@@@s   AA!	c                x    V P                  V P                  \        4       V P                  V P                  4      # rm   )assertIsSubclassr  r  r  r  s   &r   r  AExtensionConstructorTestCaseMixin.assert_raises_unknown_digestmod  s+    dmmZ8  //r   c                8    V P                  V P                  4      # rm   )r  r>   r  s   &r   r  HExtensionConstructorTestCaseMixin.cases_missing_digestmod_in_constructor  s    00??r   c                B    V P                   R R.r!V P                  W4      # )r  r   r  r  s   &  r   r  HExtensionConstructorTestCaseMixin.cases_unknown_digestmod_in_constructor  s#    	4'8g00??r   r   N)r   r   r   r   propertyr  r  r  r  r  r  r   r,   rI   s   @r   r  r    sI      " " " "'0@@ @r   r  c                   F   a  ] tR tRt o ]R 4       t]R 4       tR tRtV t	R# )OpenSSLConstructorTestCasei  c                "    \         P                  # rm   )r   r]   r  s   &r   r  #OpenSSLConstructorTestCase.obj_type  s    }}r   c                "    \         P                  # rm   )r   UnsupportedDigestmodErrorr  s   &r   r  #OpenSSLConstructorTestCase.exc_type  s    111r   c           
     $   \         R RR3 FZ  pV P                  VR7      ;_uu_ 4        V P                  4       ;_uu_ 4        V P                  RRV4       RRR4       RRR4       K\  	  R#   + '       g   i     L; i  + '       g   i     K  ; ir  r   N)r  r  r  rq  r   r  rM   r:   r  s   & r   r  ?OpenSSLConstructorTestCase.test_hmac_digest_digestmod_parameter  i    it4E5))4466  7 7 *) 5 76 *))#   A>A+A>+A;6A>>Br   N
r   r   r   r   r  r  r  r  r   r,   rI   s   @r   r  r    s7        2 28 8r   r  c                   F   a  ] tR tRt o ]R 4       t]R 4       tR tRtV t	R# )BuiltinConstructorTestCasei  c                .    V P                   P                  # rm   r   r]   r  s   &r   r  #BuiltinConstructorTestCase.obj_type  s    yy~~r   c                .    V P                   P                  # rm   )r   UnknownHashErrorr  s   &r   r  #BuiltinConstructorTestCase.exc_type	  s    yy)))r   c           
     $   \         R RR3 FZ  pV P                  VR7      ;_uu_ 4        V P                  4       ;_uu_ 4        V P                  RRV4       RRR4       RRR4       K\  	  R#   + '       g   i     L; i  + '       g   i     K  ; ir!  r"  r#  s   & r   r  ?BuiltinConstructorTestCase.test_hmac_digest_digestmod_parameter  r%  r&  r   Nr'  rI   s   @r   r)  r)    s7        * *8 8r   r)  c                   B   a  ] tR tRt o RtR tR tR tV 3R ltRt	V t
R# )	SanityTestCaseMixini  zSanity checks for HMAC objects and their object interface.

The tests here use a common digestname and do not check all supported
hash functions.
c                   V P                  R V P                  R7      pV P                  WP                  4       V P	                  VP                  R4      4       V P                  VP                  4       \        4       V P                  VP                  4       \        4       V P                  VP                  4       V P                  4       R# )   my secret keyrB   s   compute the hash of this text!N)r>   
digestnamer   
hmac_classassertIsNoner   rW   r   r~   r   r   r:   r}   s   & r   test_methods SanityTestCaseMixin.test_methods%  s    MM*dooMFa1!((#DEFahhj%0akkmS1affh8r   c                *   V P                  R V P                  R7      pV P                  VP                  RV P                   24       V P                  VP                  V P                  4       V P                  VP
                  V P
                  4       R# )r5  rB   r   N)r>   r6  r   r   r   r   r9  s   & r   test_properties#SanityTestCaseMixin.test_properties-  sk    MM*dooMF5(9!:;(8(89t7r   c                    \         hrm   r7   r  s   &r   	test_reprSanityTestCaseMixin.test_repr3      !!r   c                J   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   # )   r7  r6  r   r   )typer   int)formatr/   s   "r   __annotate__ SanityTestCaseMixin.__annotate__  s7        O    O r   r   N)r   r   r   r   r   r:  r=  r@  __annotate_func__r   r,   rI   s   @r   r3  r3    s      98";  r   r3  r  c                   B   a a ] tR tRt o]V 3R l4       tR tRtVtV ;t	# )PySanityTestCasei8  c                   < \         SV `  4        V P                  P                  V n        R V n        ^ V n        ^@V n        R# r  r$   r%   r   r]   r7  r6  r   r   r&   s   &r   r%   PySanityTestCase.setUpClass<  2    !r   c                v    V P                  R V P                  R7      pV P                  \        V4      R4       R# )r5  rB   z<hmac.HMAC object atNr>   r6  assertStartsWithreprr9  s   & r   r@  PySanityTestCase.test_reprD  s.    MM*dooMFd1g'=>r   r   
r   r   r   r   r+   r%   r@  r   r,   r-   r.   s   @@r   rL  rL  8  s#       ? ?r   rL  c                   B   a a ] tR tRt o]V 3R l4       tR tRtVtV ;t	# )OpenSSLSanityTestCaseiI  c                x   < \         SV `  4        \        P                  V n        R V n        ^ V n        ^@V n        R# r  )r$   r%   r   r]   r7  r6  r   r   r&   s   &r   r%    OpenSSLSanityTestCase.setUpClassM  s.    !!r   c                    V P                  R V P                  R7      pV P                  \        V4      RV P                   R24       R# r5  rB   <z HMAC object @NrR  r9  s   & r   r@  OpenSSLSanityTestCase.test_reprU  ;    MM*dooMFd1g4??*;>'JKr   r   rV  r.   s   @@r   rX  rX  I  s%       L Lr   rX  c                   B   a a ] tR tRt o]V 3R l4       tR tRtVtV ;t	# )BuiltinSanityTestCaseiZ  c                   < \         SV `  4        V P                  P                  V n        R V n        ^ V n        ^@V n        R# r  rN  r&   s   &r   r%    BuiltinSanityTestCase.setUpClass]  rP  r   c                    V P                  R V P                  R7      pV P                  \        V4      RV P                   R24       R# r\  rR  r9  s   & r   r@  BuiltinSanityTestCase.test_repre  r_  r   r   rV  r.   s   @@r   ra  ra  Z  s%       L Lr   ra  c                   V   a  ] tR tRt o RtRR lt]R 4       tR tR t	R t
R	 tR
tV tR# )UpdateTestCaseMixinij  z/Tests for the update() method (streaming HMAC).Nc                    \         h)zCreate a HMAC object.r7   r:   r;   r<   s   &&&r   r]   UpdateTestCaseMixin.HMACm  rB  r   c                    \         h)z4Get the maximal input length for the GIL to be held.r7   r  s   &r   gil_minsizeUpdateTestCaseMixin.gil_minsizeq  r	  r   c                n   \        V4      pR P                  V4      pV P                  W4      pV P                  V4      pV F  pVP                  V4       K  	  V P	                  VP                  4       VP                  4       4       V P	                  VP                  4       VP                  4       4       R# )r   N)listjoinr]   r   r   rW   r~   )r:   r;   chunksr<   r   r   chunks   &&&    r   check_update UpdateTestCaseMixin.check_updatev  s    fhhvYYs YYs^EIIe  	biik28r   c                    \         P                  ! ^4      \         P                  ! ^4      r!V P                  WR7      ;_uu_ 4        V P                  W.4       RRR4       R#   + '       g   i     R# ; i)   )r;   r<   N)random	randbytesr   rs  ri  s   &  r   test_updateUpdateTestCaseMixin.test_update  sO    ##B')9)9")=S\\c\++c5) ,+++s   A##A4	c                    V P                   p\        P                  ! ^4      p\        P                  ! V^,           4      p\        P                  ! V^,           4      pV P                  W#V.4       R# )rv  N)rl  rw  rx  rs  )r:   rl  r;   topbots   &    r   test_update_large%UpdateTestCaseMixin.test_update_large  sW    &&r"{Q/{Q/#Sz*r   c                    V P                  R 4      pR^{R. 3 FG  pV P                  VR7      ;_uu_ 4        V P                  \        VP                  V4       RRR4       KI  	  R#   + '       g   i     K^  ; i)r  zinvalid msg)r<   Nr   )r]   r   r  r  r   )r:   r}   r<   s   &  r   test_update_exceptions*UpdateTestCaseMixin.test_update_exceptions  s\    IIf!3B/C#&&!!)QXXs; '& 0&&&s   "A%%A6r   rm   )r   r   r   r   r   r]   r  rl  rs  ry  r~  r  r   r,   rI   s   @r   rg  rg  j  s:     9" " "
9*
+< <r   rg  c                   :   a  ] tR tRt o RR lt]R 4       tRtV tR# )PyUpdateTestCasei  Nc                <    V P                   P                  WR R7      # r  rB   r+  ri  s   &&&r   r]   PyUpdateTestCase.HMAC  s    yy~~c(~;;r   c                "    \         P                  # rm   )r   _GIL_MINSIZEr  s   &r   rl  PyUpdateTestCase.gil_minsize  s       r   r   rm   	r   r   r   r   r]   r  rl  r   r,   rI   s   @r   r  r    s     < ! !r   r  c                   :   a  ] tR tRt o RR lt]R 4       tRtV tR# )OpenSSLUpdateTestCasei  Nc                2    \         P                  ! WR R7      # r  )r   r>   ri  s   &&&r   r]   OpenSSLUpdateTestCase.HMAC  s      X>>r   c                "    \         P                  # rm   )r   r  r  s   &r   rl  !OpenSSLUpdateTestCase.gil_minsize  s    $$$r   r   rm   r  rI   s   @r   r  r    s     ? % %r   r  c                   :   a  ] tR tRt o RR lt]R 4       tRtV tR# )BuiltinUpdateTestCasei  Nc                <    V P                   P                  WR R7      # r  )r   rf   ri  s   &&&r   r]   BuiltinUpdateTestCase.HMAC  s     yy}}S}::r   c                .    V P                   P                  # rm   )r   r  r  s   &r   rl  !BuiltinUpdateTestCase.gil_minsize  s    yy%%%r   r   rm   r  rI   s   @r   r  r    s     ;
 & &r   r  c                   ,   a  ] tR tRt o R tR tRtV tR# )CopyBaseTestCasei  c                    \         hrm   r7   r  s   &r   test_attributes CopyBaseTestCase.test_attributes  r  r   c                    \         hrm   r7   r  s   &r   test_realcopyCopyBaseTestCase.test_realcopy  r  r   r   N)r   r   r   r   r  r  r   r,   rI   s   @r   r  r    s     "" "r   r  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )PythonCopyTestCasei  c                   \         P                  P                  \         P                  4      pVP                  R RRR7       V P	                  VP
                  4       V P                  VP                  4       V P                  VP                  4       VP                  4       pV P	                  VP
                  4       V P                  VP                  4       V P                  VP                  4       V P                  \        VP                  4      \        VP                  4      4       V P                  \        VP                  4      \        VP                  4      4       R# r  r  r  rB   N)r   r]   r   r   r8  r    assertIsNotNone_inner_outerr   r   rE  r:   r   r   s   &  r   r  "PythonCopyTestCase.test_attributes  s    YYtyy)
VVx8"((#RYY'RYY'WWY"((#RYY'RYY'bii$ryy/:bii$ryy/:r   c                   \         P                  P                  \         P                  4      pVP                  R RRR7       VP	                  4       pV P                  \        V4      \        V4      4       V P                  \        VP                  4      \        VP                  4      4       V P                  \        VP                  4      \        VP                  4      4       R# r  )	r   r]   r   r   r   assertNotEqualidr  r  r  s   &  r   r   PythonCopyTestCase.test_realcopy  s    YYtyy)
VVx8WWYBrFBrF+BryyM2bii=9BryyM2bii=9r   c                0   \         P                  ! R RR7      pVP                  R4       VP                  4       pV P	                  VP                  4       VP                  4       4       V P	                  VP                  4       VP                  4       4       R# r  r  rB   s   some random textN)r   r]   r   r   r   rW   r~   r  s   &  r   test_equality PythonCopyTestCase.test_equality  sb    YYv2
		%&WWYbiik28r   c                x   \         P                  ! R RR7      pVP                  R4       VP                  4       pV P	                  \        V4      \        V4      4       V P                  VP                  4       VP                  4       4       V P                  VP                  4       VP                  4       4       R# r  )	r   rf   r   r   r  r  r   rW   r~   r  s   &  r   test_equality_new$PythonCopyTestCase.test_equality_new  sz    XXf1
		%&WWYBrFBrF+biik28r   r   N)
r   r   r   r   r  r  r  r  r   r,   rI   s   @r   r  r    s     ;:99 9r   r  c                   2   a  ] tR tRt o R tR tR tRtV tR# )ExtensionCopyTestCasei  c                    \         h)z(Call the dedicate init() method to test.r7   r9  s   &&r   initExtensionCopyTestCase.init  rB  r   c                   \         P                  P                  \         P                  4      pV P                  V4       V P	                  VP
                  4       V P                  VP                  4       V P                  VP                  4       VP                  4       pV P	                  VP
                  4       V P                  VP                  4       V P                  VP                  4       R # rm   )
r   r]   r   r  r  r    r8  r  r  r   r  s   &  r   r  %ExtensionCopyTestCase.test_attributes  s    YYtyy)		"RXX&"))$"))$WWYRXX&"))$"))$r   c                   \         P                  P                  \         P                  4      pV P                  V4       VP	                  4       pV P                  \        VP                  4      \        VP                  4      4       R # rm   )r   r]   r   r  r   r  r  r    r  s   &  r   r  #ExtensionCopyTestCase.test_realcopy  sP    YYtyy)		"WWYBrxxL"RXX,7r   r   N)	r   r   r   r   r  r  r  r   r,   rI   s   @r   r  r    s     "%8 8r   r  c                   &   a  ] tR tRt o R tRtV tR# )OpenSSLCopyTestCasei  c                .    VP                  R RRR7       R# r  )rj  r9  s   &&r   r  OpenSSLCopyTestCase.init  s    	VVx@r   r   Nr   r   r   r   r  r   r,   rI   s   @r   r  r    s     A Ar   r  c                   &   a  ] tR tRt o R tRtV tR# )BuiltinCopyTestCasei  c                .    VP                  R RRR7       R# r  )rn  r9  s   &&r   r  BuiltinCopyTestCase.init  s     	
VVx@r   r   Nr  rI   s   @r   r  r    s     A Ar   r  c                   f   a  ] tR tRt o ]R 4       tR tR tR tR t	R t
R tR	 tR
 tR tRtV tR# )CompareDigestMixini  c                    \         h)z#Implementation of 'a == b' to test.r7   abs   &&r   r
   !CompareDigestMixin.compare_digest  r	  r   c                `   V P                  WR 7      ;_uu_ 4        V P                  V P                  W4      4       RRR4       V P                  W!R 7      ;_uu_ 4        V P                  V P                  W!4      4       RRR4       R#   + '       g   i     LU; i  + '       g   i     R# ; ir  N)r   r  r
   r:   r  r  s   &&&r   assert_digest_equal&CompareDigestMixin.assert_digest_equal#  sr    \\A\##OOD//56 $\\A\##OOD//56 $# $####   !B	!B	B	B-	c                `   V P                  WR 7      ;_uu_ 4        V P                  V P                  W4      4       RRR4       V P                  W!R 7      ;_uu_ 4        V P                  V P                  W!4      4       RRR4       R#   + '       g   i     LU; i  + '       g   i     R# ; ir  )r   assertFalser
   r  s   &&&r   assert_digest_not_equal*CompareDigestMixin.assert_digest_not_equal)  sv    \\A\##T0067 $\\A\##T0067 $# $####r  c                    R FG  w  rV P                  \        V P                  W4       V P                  \        V P                  W!4       KI  	  R# )d   N))r     )r     foobar)foobarr  )   fooär  )r  r  r
   r  s   &  r   test_exceptions"CompareDigestMixin.test_exceptions/  sB    
DA i)<)<aCi)<)<aC
r   c                    R Rr!V P                  W4       RRr!V P                  W4       R Rr!V P                  W4       RRr!V P                  W4       R R r!V P                  W4       RRr!V P                  W4       R# )r     foos   ޭs   ޭ   foobazs   N)r  r  r  s   &  r   
test_bytesCompareDigestMixin.test_bytes9  s    &1$$Q*"K1$$Q* )1$$Q*"$71$$Q* )1  &"$71  &r   c                    \        R 4      \        R 4      r!V P                  W4       \        R 4      \        R4      r!V P                  W4       \        R 4      \        R4      r!V P                  W4       R# r  r  r  Nr  r  r  r  s   &  r   test_bytearray!CompareDigestMixin.test_bytearrayL  sc    #Yy%91  & #Yv%61$$Q* #Yy%91$$Q*r   c                    \        R 4      R r!V P                  W4       \        R 4      Rr!V P                  W4       \        R 4      Rr!V P                  W4       R# r  r  r  s   &  r   test_mixed_types#CompareDigestMixin.test_mixed_typesY  sT    #Y1  & #V1$$Q* #Y1$$Q*r   c                ~    R R r!V P                  W4       RR r!V P                  W4       R Rr!V P                  W4       R# )r  foofoobazN)r  r  r  s   &  r   test_stringCompareDigestMixin.test_stringf  sE    1  & h1$$Q* 1$$Q*r   c                     ! R  R\         4      pV! R4      V! R4      r2V P                  W#4       V! R4      Rr2V P                  W#4       V! R4      V! R4      r2V P                  W#4       R# )c                   &   a  ] tR tRt o R tRtV tR# )2CompareDigestMixin.test_string_subclass.<locals>.Sit  c                    \        R 4      hzshould not be calledr  r:   others   &&r   __eq__9CompareDigestMixin.test_string_subclass.<locals>.S.__eq__u       !788r   r   Nr   r   r   r   r  r   r,   rI   s   @r   Sr  t       9 9r   r  r  r  N)r   r  r  )r:   r  r  r  s   &   r   test_string_subclass'CompareDigestMixin.test_string_subclasss  sc    	9 	9 {AhK1  &{H1  &{AhK1$$Q*r   c                     ! R  R\         4      pV! R4      V! R4      r2V P                  W#4       V! R4      Rr2V P                  W#4       V! R4      V! R4      r2V P                  W#4       R# )c                   &   a  ] tR tRt o R tRtV tR# )1CompareDigestMixin.test_bytes_subclass.<locals>.Bi  c                    \        R 4      hr  r  r  s   &&r   r  8CompareDigestMixin.test_bytes_subclass.<locals>.B.__eq__  r  r   r   Nr  rI   s   @r   Br    r  r   r  r  r  N)r   r  r  )r:   r  r  r  s   &   r   test_bytes_subclass&CompareDigestMixin.test_bytes_subclass  sc    	9 	9 |Qy\1  &|Y1  &|Qy\1$$Q*r   r   N)r   r   r   r   staticmethodr
   r  r  r  r  r  r  r  r  r  r   r,   rI   s   @r   r  r    sJ     " "78D'&+++
+
+ 
+r   r  c                   >   a  ] tR tRt o ]P
                  tR tRtV tR# )HMACCompareDigestTestCasei  c                    \         e#   V P                  V P                  \         4       R # V P                  V P                  \        4       R # rm   )openssl_compare_digestassertIsr
   operator_compare_digestr  s   &r   test_compare_digest_func2HMACCompareDigestTestCase.test_compare_digest_func  s2    !-MM$--/EFMM$--/FGr   r   N)	r   r   r   r   r   r
   r  r   r,   rI   s   @r   r  r    s     ((NH Hr   r  c                       ] tR tRt]tRtR# )OpenSSLCompareDigestTestCasei  r   N)r   r   r   r   r  r
   r   r   r   r   r  r    s    +Nr   r  c                       ] tR tRt]tRtR# )OperatorCompareDigestTestCasei  r   N)r   r   r   r   r  r
   r   r   r   r   r  r    s    ,Nr   r  c                      a  ] tR tRt o Rt]P                  ! 4       R 4       t]P                  ! R4      R 4       t	]P                  ! R4      R 4       t
]P                  ! R4      R 4       tRtV tR	# )
PyMiscellaneousTestsi  z4Miscellaneous tests for the pure Python HMAC module.c           
     p   \        R R.R7      pR pV! VP                  R4      ;_uu_ 4       pV! VP                  R4      ;_uu_ 4       pVP                  ! RRRR	7      pVP                  4        VP                  4        R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)r   r   r!   c           	      X    \         P                  P                  WR \        W4      R7      # )Trk  )ro  rp  rq  r   )r'   r   s   &&r   watch_methodMPyMiscellaneousTests.test_hmac_constructor_uses_builtin.<locals>.watch_method  s*    ::$$D0B %  r   rj  rn  r  r  r  rB   N)r   r]   rx  assert_called_once)r:   r   r  fg_s   &     r   "test_hmac_constructor_uses_builtin7PyMiscellaneousTests.test_hmac_constructor_uses_builtin  s     #6J<@	 $899Q$899Q		&&H=A!  "	 : :999 :99s#   B$	6B	?B$B!B$$B5	r  c                    \         P                  ! R RRR7      pV P                  VP                  R4       V P                  VP                  ^ 4       V P                  VP
                  ^@4       R# )r  r  r  rB   r  N)r   r]   r   r   r   r   r9  s   & r   test_hmac_delegated_properties3PyMiscellaneousTests.test_hmac_delegated_properties  sP    IIff9/+r*r   c           
     h    ! R  R\         4      p\        P                  ! 4       ;_uu_ 4        \        P                  ! R\        4       V P                  \        4      ;_uu_ 4        \        P                  ! RRVR7       V P                  R4       RRR4       ^Vn	        V P                  \        4      ;_uu_ 4        \        P                  ! RRVR7       V P                  R4       RRR4       RRR4       R#   + '       g   i     Lq; i  + '       g   i     L-; i  + '       g   i     R# ; i)	c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )KPyMiscellaneousTests.test_legacy_block_size_warnings.<locals>.MockCrazyHashi  z#Ain't no block_size attribute here.c                n    \         P                  ! V!  V n        V P                  P                  V n        R # rm   )hashlibr  _xr   )r:   r   s   &*r   __init__TPyMiscellaneousTests.test_legacy_block_size_warnings.<locals>.MockCrazyHash.__init__  s$    !..$/#'77#6#6 r   c                <    V P                   P                  V4       R # rm   )r*  r   )r:   vs   &&r   r   RPyMiscellaneousTests.test_legacy_block_size_warnings.<locals>.MockCrazyHash.update  s    q!r   c                6    V P                   P                  4       # rm   )r*  rW   r  s   &r   rW   RPyMiscellaneousTests.test_legacy_block_size_warnings.<locals>.MockCrazyHash.digest  s    ww~~''r   )r*  r   N)
r   r   r   r   r   r+  r   rW   r   r,   rI   s   @r   MockCrazyHashr'    s     57"( (r   r2  error   a   brB   z)Expected warning about missing block_sizeNz'Expected warning about small block_size)
rq  warningscatch_warningssimplefilterRuntimeWarningr  r   r]   failr   )r:   r2  s   & r   test_legacy_block_size_warnings4PyMiscellaneousTests.test_legacy_block_size_warnings  s    	(F 	( $$&&!!'>:"">22		$>		EF 3 ()M$"">22		$>		CD 3 '&22
 32 '&&s;   9D &+C:	,D =+D	(D :D
D DD  D1	c                   \        \        R 4      p \        P                  VR&   \        P                  ! RRR4      P                  4       pRpV P                  W#4       VP                  R4       R#   TP                  R4       i ; i)__builtin_constructor_cacher  r  s   message@6e9ef29b75fffc5b7abae527d58fdadb2fe42e7219011976917343065f58ed4aN)r   r)  r  r   rW   hexr   pop)r:   cacher~   expecteds   &   r   test_with_fallback'PyMiscellaneousTests.test_with_fallback  sj    !>?	">>E%LFJ>BBDI;HY1IIeEIIes   AA1 1Br   N)r   r   r   r   r   r  requires_builtin_hmacr   r  r#  r;  rD  r   r,   rI   s   @r   r  r    s     >))+# ,#$ ''1+ 2+ ''1E 2E, ''1	 2	r   r  c                   R   a a ] tR tRt oRt]V 3R l4       tR tR tR t	Rt
VtV ;t# )BuiltinMiscellaneousTestsi  a  HMAC-BLAKE2 is not standardized as BLAKE2 is a keyed hash function.

In particular, there is no official test vectors for HMAC-BLAKE2.
However, we can test that the HACL* interface is correctly used by
checking against the pure Python implementation output.
c                   < \         SV `  4        \        R 4      V n        V P                  P                  V n        V P                  P
                  V n        R# )_blake2N)r$   r%   r	   blake2blake2bblake2sr&   s   &r   r%   $BuiltinMiscellaneousTests.setUpClass  s<    "9-
jj((jj((r   c                    V P                  V\        4       \        P                  ! W#V4      pV P	                  W4       R # rm   )r   r   r   _compute_digest_fallbackr   )r:   rW   r;   r<   r   expects   &&&&& r   assert_hmac_blake_correctness7BuiltinMiscellaneousTests.assert_hmac_blake_correctness  s2    fe,..sB(r   c                    \         P                  ! ^4      \         P                  ! ^4      r!V P                  P                  W4      pV P	                  W1W P
                  4       R#    N)rw  rx  r   compute_blake2b_32rR  rL  r:   r;   r<   rW   s   &   r   test_compute_blake2b_321BuiltinMiscellaneousTests.test_compute_blake2b_32  G    ##A&(8(8(<S--c7**6\\Jr   c                    \         P                  ! ^4      \         P                  ! ^4      r!V P                  P                  W4      pV P	                  W1W P
                  4       R# rU  )rw  rx  r   compute_blake2s_32rR  rM  rX  s   &   r   test_compute_blake2s_321BuiltinMiscellaneousTests.test_compute_blake2s_32  r[  r   r   )r   r   r   r   r   r+   r%   rR  rY  r^  r   r,   r-   r.   s   @@r   rH  rH    s5      ) ))
K
K Kr   rH  __main__)^r   r   rC   r   r)  rw  test.supporttesttest.support.hashlib_helpersupportr  r   r   unittest.mockro  r6  	_operatorr   r  r   r   r   r   r   test.support.import_helperr   r	   r   r
   r  ImportError_sha2r   r   r   r   rF  r1   rq  rH   r5   rK   rU   rY   r[   rc   requires_hashlibrk   rr   ry   r   r   r   r   r   rh  TestCaser|  r  r  r  r  r  r  r  r  r  r  r  r  r)  r3  r  rL  requires_openssl_hashdigestrX  ra  rg  r  r  r  r  r  r  r  r  r  r  r  r  r  rH  r   mainr   r   r   <module>rn     s  $       4 4     @ 5  J"A

; 
NK 
N %%'0 0 (0 X E E H H 33NlK N 	HK{ 	H   "L\; L #LP/{ PC C*n;\;0B n;bK}n K
B2N 
B	2N 	w)> wt	 (:  ,
-+4+-#,,

-+4+-#,,

!6!1!:!1!3!)!2!2

!6!1!:!1!3!)!2!2
.2)!**N.0)!**N&:\; :z!?|[:L !?H?]35?,8.0F$--8
'"79O"*"3"3',@(>(@@>8!7!B!)!2!28*8!7!B!)!2!28*", "D ##H-?)=:M((? .?  ++H5L24G$--L 6L L24G$--L (< (<V !}&98;L;L ! ! ++H5%/1B1B % 6%
&./1B1B
&" " ##H-+9)8+<+< +9 .+9\8, 88 ++H5A/1B1B A 6A %%'A/1B1B A (Am+ m+`H 2H4E4E H   ",#5x7H7H , #,-$68I8I ->8,, >BK 2H4E4E K> zMMO i.  "H!"  Ds$   
R" "R4 "R10R14	S S