+
      xi  c                  s    R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ]P                  ! R4      tR R ltR R	 ltR
 R lt ! R R4      tR# )al  Module that provides message authentication for PSKC values.

This module provides a MAC class that is used to store information about
how the MAC should be calculated (including the MAC key) and a ValueMAC
class that provides (H)MAC checking for PSKC key data.

The MAC key is generated specifically for each PSKC file and encrypted
with the PSKC encryption key.
)annotationsN)PSKC)EncryptedValuez!^(.*#)?hmac-(?P<hash>[a-z0-9-]+)$c               $    V ^8  d   QhRRRRRR/# )   	algorithm
str | Noneargsbytesreturnzhashlib._Hash Zformat   "-/usr/lib/python3.14/site-packages/pskc/mac.py__annotate__r   ,   s&     
G 
GZ 
G 
G- 
G    c                s   ^ RI Hp ^ RIHp \        P                  V! V 4      ;'       g    R4      pV'       d)    \        P                  ! VP                  R4      .VO5!  # V! RV ,          4      h  \         d     Li ; i)z#Return an instantiated hash object.normalise_algorithmDecryptionErrorZ ZhashzUnsupported MAC algorithm: %r)
pskc.algorithmsr   pskc.exceptionsr   _hmac_url_reZsearchhashlibnewZgroupZ
ValueError)r   r   r   r   Zmatchs   &*   r   _get_hash_objr   ,   sr    3/ 3I > D D"EE	;;u{{62:T:: 9IE
FF  		s   &A1 1A?>A?c               s(    V ^8  d   QhRRRRRRRR/# )r   r   r   keybytes | Nonevaluer   r	   r
   r   r   r   r   r   9   s.     @ @: @L @ @5 @r   c                sT   a  ^ RI pVP                  WV 3R l4      P                  4       # )z0Generate the MAC value over the specified value.Nc                 s   < \        S.V O5!  # N)r   )r   r   s   *r   Z<lambda>Zmac.<locals>.<lambda>?   s    mI55r   )hmacr   Zdigest)r   r   r   r   s   f&& r   macr   9   s%    88577=vx@r   c                    V ^8  d   QhRRRR/# )r   r   r   r	   intr
   r   r   r   r   r   B   s      j S r   c                sh    ^ RI Hp  \        \        V 4      P                  4      #   T d     ^# i ; i)>Recommended minimal key length in bytes for the set algorithm.r   )r   r   r!   r   Zdigest_size)r   r      & r   mac_key_lengthr$   B   s4     0=+7788 s   & 11c                  s    ] tR t^MtRtR R lt]R R l4       t]P                  R R l4       t]R R	 l4       t	]	P                  R
 R l4       t	]R R l4       t
R R ltRR R lltRtR# )MACa   Class describing the MAC algorithm to use and how to get the key.

Instances of this class provide the following attributes:

  algorithm: the name of the HMAC to use (currently only HMAC_SHA1)
  key: the binary value of the MAC key if it can be decrypted
c               r    )r   pskcr   r	   Noner
   r   r   r   r   MAC.__annotate__V   s     + +T +d +r   c                	s     Wn         R V n        R # r   )r&   
_algorithm)selfr&      &&r   __init__ZMAC.__init__V   s    	&*r   c                   V ^8  d   QhRR/# )r   r	   r   r
   r   r   r   r   r(   [   s     	, 	,\ 	,r   c                s    \        V RR4      p\        V\        4      '       d   VP                  V P                  4      # V'       d   V# V P                  P
                  P                  # )z8Provide access to the MAC key binary value if available._keyN)ZgetattrZ
isinstancer   Z	get_valuer&   Z
encryptionr   r*   r   r#   r   r   MAC.keyZ   sR     07tVT/Je^,,??499--L 99''+++r   c               r    )r   r   zbytes | EncryptedValue | Noner	   r'   r
   r   r   r   r   r(   g   s      6 4 r   c                	s    Wn         R # r   )r.   r/   r+   r   r   r0   f   s    	r   c               r-   )r   r	   r   r
   r   r   r   r   r(   k   s      : r   c                sB    V P                   '       d   V P                   # R# )zProvide the MAC algorithm used.N)r)   r*      &r   r   MAC.algorithmj   s     ?????"r   c               r    )r   r   r   r	   r'   r
   r   r   r   r   r(   r   s     5 5z 5d 5r   c                	s,    ^ RI Hp V! V4      V n        R# )i    r   N)r   r   r)   )r*   r   r   s   && r   r   r3   q   s    7-e4r   c               r-   )r   r	   r!   r
   r   r   r   r   r(   w   s     . .c .r   c                s,    \        V P                  4      # )r"   )r$   r   r1   r2   r   algorithm_key_lengthZMAC.algorithm_key_lengthv   s     dnn--r   c               s     V ^8  d   QhRRRR/# )r   r   r   r	   r
   r   r   r   r   r(   {   s     4 4% 4E 4r   c                sD    \        V P                  V P                  V4      # )z*Generate the MAC over the specified value.)r   r   r   r/   r+   r   generate_macZMAC.generate_mac{   s    4>>488U33r   Nc               r   )r   r   r   r   r   r	   r'   r
   r   r   r   r   r(      s!     = = = =t =r   c                s    V'       d   Wn         V'       d   W n        V P                  '       g   RV n        V P                   '       g(   \        P                  ! V P                  4      V n         R# R# )ae  Configure an encrypted MAC key.

None of the arguments are required. By default HMAC-SHA1 will be used
as a MAC algorithm. If no key is configured a random key will be
generated with the length of the output of the configured hash.

This function will automatically be called when the configured
encryption algorithm requires a message authentication code.
z	hmac-sha1N)r   r   osZurandomr4   )r*   r   r   s   &&&r   setupZ	MAC.setup   sH     H&N~~~(DNxxxzz$";";<DH r   )r)   r.   r   r   r&   )NN)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r,   Zpropertyr   Zsetterr   r4   r5   r7   Z__static_attributes__r
   r   r   r%   r%   M   s    + 	, 	, 	ZZ    5 5 . .4= =r   r%   )r8   Z
__future__r    r   r6   Zrer&   r   Zpskc.keyr   Zcompiler   r   r   r$   r%   r
   r   r   <module>r9      sL   * #  	 	  # zz>?
G@E= E=r   