+
     h  c                  s    ^ RI Ht ^ RIt^ RIt^ RIt^ RIHtHtHtH	t	 ^ RI
Ht ^ RIHt ^RIHt ^RIHt ^RIHtHt ^R	IHtHt R
 tR tR tR tR t ! R R4      tR# )i    )annotationsN)AnyMappingSequencecast)
InvalidTag)AESGCM)cbor)sha256)Ctap2Info)PinProtocol_PinUvc                    \         P                  ! \         P                  ) R 7      pVP                  V 4      VP	                  4       ,           # )Zwbits)zlibZcompressobj	MAX_WBITSZcompressflushdataZo   & 5/usr/lib/python3.14/site-packages/fido2/ctap2/blob.py	_compressr   ,   s2    /A::daggi''    c                r   r   )r   Zdecompressobjr   Z
decompressr   r   r   r   _decompressr   1   s2    $..1A<<	))r   c                s>    R \         P                  ! RV 4      ,           # )s   blobz<Q)structpack)	orig_size   &r   _lb_adr   6   s    V[[y111r   c                s    \        V4      p\        P                  ! ^4      p\        V 4      pVP	                  V\        V4      \        V4      4      p^V^V^V/# )i   )lenosZurandomr   Zencryptr   r   )keyr   r   nonceaesgcm
ciphertext   &&    r   _lb_packr%   :   sW    D	IJJrNEC[Fyy8IJJ 	
:	5	9 r   c                s     V^,          pV^,          pV^,          p\        V 4      pVP                  W2\        V4      4      pWd3#   \        \        \
        3 d    \        R4      h\         d    \        R4      hi ; i)i   zInvalid entryz	Wrong key)r   Zdecryptr   	TypeErrorZ
IndexErrorZKeyError
ValueErrorr   )r    entryr#   r!   r   r"   
compresseds   &&     r   
_lb_unpackr*   H   s}    
&1X
a!H	^^Evi7HI
$$z8, *)) &%%&s   AA )A=0A=c                  s|    ] tR t^VtRt]R R l4       tRR R lltR R ltR	 R
 lt	R R lt
R R ltR R ltRtR# )
LargeBlobsa6  Implementation of the CTAP2.1 Large Blobs API.

Getting a largeBlobKey for a credential is done via the LargeBlobKey extension.

:param ctap: An instance of a CTAP2 object.
:param pin_uv_protocol: An instance of a PinUvAuthProtocol.
:param pin_uv_token: A valid PIN/UV Auth Token for the current CTAP session.
c                    V ^8  d   QhRRRR/# )   infor
   returnZbool Zformat   "r   __annotate__LargeBlobs.__annotate__a   s     6 64 6D 6r   c                	s<    V P                   P                  R 4      RJ # )Z
largeBlobsT)Zoptionsget)r.   r   r   is_supportedZLargeBlobs.is_supported`   s    ||-55r   Nc               $    V ^8  d   QhRRRRRR/# )r-   ctapr	   pin_uv_protocolzPinProtocol | Nonepin_uv_tokenbytes | Noner0   r1   r2   r   r3   r4   d   s(     
 

 ,
 #	
r   c                	s   V P                  VP                  4      '       g   \        R 4      hWn        V P                  P                  P                  ^@,
          V n        V'       d   V'       d   \        W#4      V n        R# RV n        R# )z)Authenticator does not support LargeBlobsN)r6   r.   r'   r8   Zmax_msg_sizemax_fragment_lengthr   pin_uv)selfr8   r9   r:   s   &&&&r   __init__ZLargeBlobs.__init__d   si       ++HII	#'99>>#>#>#C  < ?1 	  	r   c               s    V ^8  d   QhRR/# )r-   r/   Sequence[Mapping[int, Any]]r0   r1   r2   r   r3   r4   u   s     D D!< Dr   c                s   ^ pRp V P                   P                  WP                  R7      ^,          pW#,          p\        V4      V P                  8  d   MWP                  ,          pKe  VRR VRR rTV\	        V4      RR 8w  d   . # \        \        \        \        \        3,          ,          \        P                  ! V4      4      # )zcGets the entire contents of the Large Blobs array.

:return: The CBOR decoded list of Large Blobs.
r   )r5   Ni)r8   large_blobsr<   r   r   r   r   r   Zintr   r   Zdecode)r>   offsetZbufZfragmentr   Zchecks   &     r   read_blob_arrayZLargeBlobs.read_blob_arrayu   s    
 yy,,V9Q9Q,RSTUHOC8}t777...F$3iSTeF4L#&&IHWS#X./T1BCCr   c               r,   )r-   
blob_arrayr@   r/   Noner0   r1   r2   r   r3   r4      s     & &+F &4 &r   c                s   \        V\        4      '       g   \        R4      h\        P                  ! V4      pV\        V4      R,          ,          p^ p\        V4      pW48  d   \        WC,
          V P                  4      pW#W5,            pV P                  '       d   R\        P                  ! RV4      ,           \        V4      ,           pV P                  P                  P                  pV P                  P                  P                  V P                  P                  V4      p	MRp	RpV P                   P#                  TTV^ 8X  d   TMRVV	R7       W5,          pK  R# )z_Writes the entire Large Blobs array.

:param blob_array: A list to write to the Authenticator.
zlarge-blob array must be a list:Ni   Nz<IN)ZsetZlengthr9   pin_uv_params"    )Z
isinstanceZlistr&   r   Zencoder   r   Zminr<   r=   r   r   ZprotocolZVERSIONZauthenticateZtokenr8   rA   )
r>   rD   r   rB   ZsizeZlnZ_setZmsgr9   rF   s
   &&        r   write_blob_arrayZLargeBlobs.write_blob_array   s)   
 *d++=>>{{:&tS!!4ymT]D$<$<=B-D{{{"kk$/0 Tl#  #'++"6"6">">#{{33@@ARARTWX#"&II!!%{t /) "  LF3 r   c               r,   )r-   large_blob_keybytesr/   r;   r0   r1   r2   r   r3   r4      s      u  r   c                s    V P                  4        F0  p \        W4      w  r4\        V4      p\        V4      V8X  d   Vu # K2  	  R#   \        \
        P                  3 d     KT  i ; i)zGets the Large Blob stored for a single credential.

:param large_blob_key: The largeBlobKey for the credential, or None.
:returns: The decrypted and deflated value stored for the credential.
N)rC   r*   r   r   r'   r   Zerror)r>   rH   r(   r)   r   Zdecompressedr$   r   get_blobZLargeBlobs.get_blob   sm     ))+E(2>(I%
*:6|$	1'' 2	 ,  

+ s   )AA&%A&c               r7   )r-   rH   rI   r   r;   r/   rE   r0   r1   r2   r   r3   r4      s!     + +u +L +T +r   c                s   VRJp. pV P                  4        F  p \        W4       RpK  	  Ve   VP                  \	        W4      4       V'       d   V P                  V4       R# R#   \         d    TP                  T4        Ko  i ; i)zStores a Large Blob for a single credential.

Any existing entries for the same credential will be replaced.

:param large_blob_key: The largeBlobKey for the credential.
:param data: The data to compress, encrypt and store.
NT)rC   r*   r'   Zappendr%   rG   )r>   rH   r   ZmodifiedZentriesr(   s   &&&   r   put_blobZLargeBlobs.put_blob   s     t#))+E&>1 , NN8N9:!!'*   &u%&s   A''BBc               r,   )r-   rH   rI   r/   rE   r0   r1   r2   r   r3   r4      s     , ,% ,D ,r   c                s*    V P                  VR4       R# )zwDeletes any Large Blob(s) stored for a single credential.

:param large_blob_key: The largeBlobKey for the credential.
N)rK   )r>   rH   s   &&r   delete_blobZLargeBlobs.delete_blob   s    
 	nd+r   )r8   r<   r=   )NN)Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__Zstaticmethodr6   r?   rC   rG   rJ   rK   rL   Z__static_attributes__r0   r   r   r+   r+   V   s@     6 6
"D&&P +0, ,r   r+   )Z
__future__r    r   r   r   Ztypingr   r   r   r   Zcryptography.exceptionsr   Z+cryptography.hazmat.primitives.ciphers.aeadr   Z r   Zutilsr   Zbaser	   r
   Zpinr   r   r   r   r   r%   r*   r+   r0   r   r   <module>rM      sP   8 # 	   / / . >    $(
*
2&G, G,r   