+
    :i7  c            
       s\   ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIt^ RIHt ^ RIHt ^ RIHt ^ R	IHtHtHt ^ R
IHtHt ^ RIHtHtHtHt ^ RIH t H!t! ^ RI"H#t# ^ RI$H%t% ^RI&H't' ]PP                  ! ])4      t* ! R R]PV                  4      t, ! R R],]PZ                  4      t.].].n/        RR/R lt0RR/R lt1 ! R R]Pd                  4      t3 ! R R]Ph                  4      t5RBR lt6]6! 4       R 4       t7]Pp                  ! RRR R!R"7      t9]Pp                  ! R#R$]Pd                  ! R%R&.RR'7      R%R R(]7R)7      t: ! R* R+]4      t;R, t<]6! 4       R- 4       t=RCR. lt>RDR/ R0 llt?RER1 lt@ ! R2 R3]A4      tBRFR4 R5 lltCR6 R7 ltDR8 R9 ltER: R; ltFRGR< R= lltGR> R? ltHR@ RA ltIR# )H    N)OrderedDict)MutableMapping)Enum)Sequencecast)x509)serialization)EllipticCurvePublicKey)	TRANSPORTApplicationNotAvailableError_timeout)	ApduErrorSmartCardConnection)KeyRefScp11KeyParamsScpKeyParamsScpKid)
CAPABILITY
DeviceInfoparse_b32_key)SecurityDomainSession)parse_certificatesc                   sN   a a ] tR t^5t oV 3R ltRV 3R lltV 3R ltRtVtV ;t	# )_YkmanCommandc                s   < VP                  R R4      pV'       d   \        V\        4      '       g   V.pW0n        \        SV `  ! V/ VB  R# )connectionsN)pop
isinstancelistr   super__init__)selfargskwargsr   	__class__s   &*, 4/usr/lib/python3.14/site-packages/ykman/_cli/util.pyr   Z_YkmanCommand.__init__6   sA    jj5z+t<<&-K&$)&)    c                s   < \         SV `  V4      pV^ ,          P                  4       VR,          P                  R4      ,           # )r       NN.)r   get_short_help_strlowerrstrip)r   ZlimitZhelp_strr"      && r#   r(   Z _YkmanCommand.get_short_help_str>   s9    7-e4{  "Xb\%8%8%===r$   c                s@   < \         SV `  V4      pVf   Q hRVn        V# )Nzshow this message and exit)r   get_help_optionhelp)r   ctxoptionr"   r+   r#   r,   Z_YkmanCommand.get_help_optionB   s*    (-!!!2r$   )r   )i-   )
__name__
__module____qualname____firstlineno__r   r(   r,   __static_attributes____classdictcell____classcell__r"   __classdict__   @@r#   r   r   5   s     *> r$   r   c                   s@   a a ] tR t^It o]tRV 3R lltR tRtVt	V ;t
# )_YkmanGroupc                s|   < \        V\        \        34      '       g   \        R V R24      h\        SV `  W4       R# )zCommand z3 does not inherit from _YkmanGroup or _YkmanCommandN)r   r:   r   
ValueErrorr   add_command)r   Zcmdnamer"      &&&r#   r<   Z_YkmanGroup.add_commandL   s>    #];<<3%RS  	C&r$   c                s:   a  \        S P                  V 3R  lR7      # )c                 s^   < \        SP                  V ,          \        P                  4      V 3# N)r   commandsclickGroup)cr   s   &r#   <lambda>Z+_YkmanGroup.list_commands.<locals>.<lambda>U   s    *T]]15Eu{{*SUV)Wr$   )key)Zsortedr@   )r   r.   s   f&r#   list_commandsZ_YkmanGroup.list_commandsS   s    MMW
 	
r$    r?   )r0   r1   r2   r3   r   Zcommand_classr<   rF   r4   r5   r6   r7   r9   r#   r:   r:   I   s     !M'
 
r$   r:   r   c                 >    \         P                  ! VR \        RV /VB # Zclsr   )rA   Zgroupr:   r   r    r!      $*,r#   click_grouprL   \   s2    ;;	   	 r$   c                 rH   rI   )rA   Zcommandr   rJ   rK   r#   click_commandrM   e   s2    ==	   	 r$   c                   sH   a a ] tR t^nt oRt. 3V 3R lltV 3R ltRtVtV ;t	# )
EnumChoicez
Use an enum's member names as the definition for a choice option.

Enum member names MUST be all uppercase. Options are not case sensitive.
Underscores in enum names are translated to dashes in the option choice.
c                s   < V Uu. uF'  q3V9  g   K  VP                   P                  R R4      NK)  	  upV n        \        SV `  V P                  RR7       W n        Wn        R# u upi )_-FZcase_sensitiveN)r=   replacechoices_namesr   r   hiddenchoices_enum)r   rU   rT   vr"   s   &&& r#   r   ZEnumChoice.__init__v   sg    .:
.:vo$AFFNN3$l
 	  	 	
 (
s
   A$ A$c                s  < \        WP                  4      '       d   V#  V P                  P                  P                  4        UUu. uF)  w  rEWPP                  9  g   K  VP                  R R4      NK+  	  uppV n        \        SV `!  WV4      P                  RR 4      pV P                  V n        V P                  V,          # u uppi   T P                  T n        i ; i)rO   rP   )
r   rU   Z__members__itemsrT   rR   choicesr   convertrS   )r   valueparamr.   krV   r=   r"   s   &&&&   r#   rY   ZEnumChoice.convert   s    e..//L		. !--99??AADAKK' $		#s#ADL
 7?55==c3GD--DL  &&  --DLs#   'C	 C C6)C	 C	 	C)rX   rU   rS   rT   )
r0   r1   r2   r3   Z__doc__r   rY   r4   r5   r6   r7   r9   r#   rN   rN   n   s      -/ 	)' 'r$   rN   c                   s*   a  ] tR t^t o RtR tRtV tR# )HexIntParamTypeZintegerc                sP   \        V\        4      '       d   V#  VP                  4       P                  R 4      '       d   \        VR,          ^4      # RV9   d   \        VP	                  RR4      ^4      # \        V4      #   \
         d    T P                  T: R2Y#4        R# i ; i)Z0x:   NN: z is not a valid integerN)r   intr)   Z
startswithrR   r;   fail)r   rZ   r[   r.   s   &&&&r#   rY   ZHexIntParamType.convert   s    eS!!L	G{{}''--59b))e|5==b1266u: 	GII	!895F	Gs"   $B  B  "B  5
B   !B%$B%rG   N)r0   r1   r2   r3   r=   rY   r4   r5   r8      @r#   r]   r]      s     D
G 
Gr$   r]   Fc                 s   a  V 3R  lpV# )c                 sJ   <a  \         P                  ! S 4      V V3R  l4       pV# )c           	      s   < S'       g   VP                   '       g   Vf   R #  S! WV4      #   \         d6   pT P                  RTP                   R\	        T4       24        R p?R # R p?ii ; i)NzInvalid value for "z": )Zrequiredr;   rb   r=   str)r.   r[   valZefinvoke_on_missings   &&& r#   innerZ+click_callback.<locals>.wrap.<locals>.inner   s_    $U^^^HS)) H.uzzl#c!fXFGGHs   , A,*A''A,	functoolsZwraps)rg   ri   rh   s   f r#   wrapZclick_callback.<locals>.wrap   s'    			H 
	H r$   rG   )rh   rl      f r#   click_callbackrn      s    
 Kr$   c                 s    VR 8X  d   \         P                  P                  # VR8X  d   \         P                  P                  # \	        V4      h)PEMDER)r   ZEncodingro   rp   r;   r.   r[   rf      &&&r#   click_parse_formatrs      s>    
e|%%)))	%%)))or$   z-fz--forceTz$confirm the action without prompting)Zis_flagr-   z-Fz--formatro   rp   rQ   zencoding format)ZtypeZdefaultZshow_defaultr-   Zcallbackc                   sP   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	tV tR
# )YkmanContextObjectc                s2    \        4       V n        R V n        R# )FN)r   _objects	_resolvedr      &r#   r   ZYkmanContextObject.__init__   s    #r$   c                sT    V P                   '       d   V! 4       pW P                  V&   R # r?   )rv   ru   )r   rE   rg   rr   r#   add_resolverZYkmanContextObject.add_resolver   s    >>>Acr$   c                s    V P                   '       gO   R V n         V P                  P                  4       P                  4        F  w  rV! 4       V P                  V&   K  	  R# R# )TN)rv   ru   ZcopyrW   )r   r\   rg   s   &  r#   resolveZYkmanContextObject.resolve   sI    ~~~!DN**,224#$3a  5 r$   c                sH    V P                  4        V P                  V,          # r?   )rz   ru   r   rE      &&r#   __getitem__ZYkmanContextObject.__getitem__   s    }}S!!r$   c                s\    V P                   '       g   \        R 4      hW P                  V&   R# )z+BUG: Attempted to set item when unresolved.N)rv   r;   ru   )r   rE   rZ   rr   r#   __setitem__ZYkmanContextObject.__setitem__   s#    ~~~JKK"cr$   c                s     V P                   V R # r?   )ru   r{   r|   r#   __delitem__ZYkmanContextObject.__delitem__   s    MM#r$   c                ,    \        V P                  4      # r?   )lenru   rw   rx   r#   __len__ZYkmanContextObject.__len__   s    4==!!r$   c                r   r?   )Ziterru   rw   rx   r#   __iter__ZYkmanContextObject.__iter__   s    DMM""r$   )ru   rv   N)r0   r1   r2   r3   r   ry   rz   r}   r~   r   r   r   r4   r5   rc   rd   r#   rt   rt      s2     
'"#
"# #r$   rt   c                 sF   a  \         P                  ! S 4      V 3R  l4       pV# )c                  s   <a a \         P                  ! 4       P                  P                  \	        S4      V VV3R  l4       R# )c                  s   < S! S / SB # r?   rG   )r    rg   r!   s   r#   rD   Z9click_postpone_execution.<locals>.inner.<locals>.<lambda>   s    QEWPVEWr$   N)rA   Zget_current_contextobjry   re   )r    r!   rg   s   jlr#   ri   Z'click_postpone_execution.<locals>.inner   s'    !!#''44SV=WXr$   rj   )rg   ri   rm   r#   click_postpone_executionr      s'    __QY Y Lr$   c                 s    \        V4      # r?   r   rq   rr   r#   click_parse_b32_keyr      s    r$   c                s   \         P                  RV  R24       \        P                  P	                  4       '       gb   \         P                  R4       \        P                  P                  4       pV'       d   VP                  R4      # \         P                  R4       \         P                  R4       \        P                  ! V 3RV/VB # )zReplacement for click.prompt to better work when piping input to the command.

Note that we change the default of err to be True, since that's how we typically
use it.
zInput requested ()z(TTY detected, reading line from stdin...
zNo data available on stdinzUsing interactive prompt...err)	loggerdebugsysZstdinZisattyZreadliner*   rA   prompt)r   r   r!   Zlines   &&, r#   click_promptr      s     LL$VHA./99?@yy!!#;;t$$12 LL./<<2C2622r$   c                s(    V ^8  d   QhR\         RR/# )r^   r   returnN)re   Zformat   "r#   __annotate__r     s     ( (S (t (r$   c                 s    \         P                  R 4        \        P                  ! V RR7       R#   \         d'    \
        P                  P                  T  R24        R# i ; i)z"Prompting user to touch YubiKey...T)r   r   N)r   r   rA   echo	Exceptionr   ZstderrZwrite)r   rx   r#   prompt_for_touchr     sI    
LL56(

6t$ (

F82'(s   1 -A"!A"c                 s"    \        \        V 4      # r?   )r   r   )Ztimeoutrx   r#   prompt_timeoutr     s    $g..r$   c                   s6   a a ] tR tRt oRV 3R lltRtVtV ;t# )CliFaili  c                s2   < \         SV `  V4       W n        R # r?   )r   r   status)r   messager   r"   r>   r#   r   ZCliFail.__init__  s    !r$   )r   )r&   )r0   r1   r2   r3   r   r4   r5   r6   r7   r9   r#   r   r     s      r$   r   c                sF    V ^8  d   QhR\         R\        \        ,          /# )r^   levelr   )ra   r   re   r   r   r#   r   r   "  s     # #s #8C= #r$   c                sJ   RV,          p. p\        V \        4      '       d&   V  F  pVP                  \        WA4      4       K  	  V# \        V \        4      '       Edv   . p^ pV P                  4        F  w  rt\        V\        4      '       d    VP                  ;'       g    \        V4      p\        WA^,           4      p\        V4      ^8  ;'       g    \        V\        \        34      p	V	'       g   \        V\        V4      4      pVP                  WxV	34       K  	  V\        V4      ^,           ,          pV F  w  rxp	V V R2P                  V4      p
V	'       dF   VP                  V
4       VP                  V4       VR,          R8w  d   VP                  R4       Kg  Ki  VP                  V
 RV^ ,          P                  4        24       K  	  V# \        V \        4      '       d&   VP                  V V P                  4        24       V# VP                  V V  24       V# )z~Pretty-prints structured data, as that returned by get_diagnostics.

Returns a list of strings which can be printed as lines.
z  r_   r`   Z )r   r   Zextendpretty_printZdictrW   r   r=   re   r   ZmaxappendZljustZlstripbyteshex)rZ   r   ZindentZlinesrV   ZresZmlenr\   ZpZmlZk_lines   &&         r#   r   r   "  s   
 E\FE%ALLa/0 6 L3 
E4	 	 KKMDA!T""FF$$c!fQ	*AQ!::z!dD\:B4Q(JJbz" " 	FaHA"xs!_**40FV$Q9?LL$ # xq189  L	 
E5	!	!x		}-. L 	xw'(Lr$   c                s0    V ^8  d   QhR\         R\        /# )r^   infor   )r   Zboolr   r   r#   r   r   H  s     1 1j 1T 1r$   c                 sV    V P                   ^ ,          ^8H  ;'       d    V P                  # r    )ZversionZis_fips)r   rx   r#   is_yk4_fipsr   H  s!    <<?a00DLL0r$   c                s$    V ^8  d   QhR\         /# )r^   r   )ra   r   r   r#   r   r   L  s      # r$   c                 sJ     V P                  4       #   \         d    Ru # i ; i)r&   r   )Zfilenor   )rg   rx   r#   _filenor   L  s'    xxz 	s    ""c                sH    V ^8  d   QhR\         R\        P                  RR/# )r^   r   logr   N)re   loggingZLoggerr   r   r#   r   r   S  s%     " " "7>> "d "r$   c                 s  a \        \        P                  4      o\        ;QJ d    V3R  lV 4       F  '       g   K   RM	  RM! V3R  lV 4       4      '       d   VP	                  V 4       R# \
        P                  ! V  R24       R# )c              3   s@   <"   T F  p\        V4      S8H  x  K  	  R # 5ir?   )r   )Z.0rg   fnos   & r#   Z	<genexpr>Zlog_or_echo.<locals>.<genexpr>U  s     
,e71:es   TFr'   N)r   r   ZstdoutZanyr   rA   r   )r   r   Zfilesr   s   &&*@r#   log_or_echor   S  sP    
#**
C
s
,e
,sss
,e
,,,

gYa=!r$   c          
      sb    V ^8  d   QhR\         R\        R\        R\        R,          R\        /# )r^   
connectionkidkvncaNr   )r   ra   r   r   r   r   r#   r   r   [  s?     8F 8F#8F*-8F478F=BT\8F8Fr$   c                 s    \        V 4      pT'       d?   \        TR4      ^ ,          p TP                  P                  \        P                  4      pMRpRpT'       g   T'       d   TP                  P                  pTP                  RR7      P                  4        F,  w  rY8X  g   K  T'       d   TP                  T8X  g   K(  Tw  r M	  \        RTP                  4        24      hTP                  4       P!                  4        F"  pTP                  T8X  g   K  TP"                  p M	  \        RTR 24      h\%        Y4      p TP'                  T4      p
T
'       g   \        RT 24      hT'       dJ   \(        P+                  R4       TpT
 F  pTP-                  T4       TpK  	  \(        P/                  R	4       M\(        P/                  R
4       \1        \2        T
R,          P5                  4       4      p\7        Y4      #   \         d    \        R 4      hi ; i  \        P                   d    Rp ELi ; i  \8         d    \        RT R24      hi ; i)z)Security Domain application not availableNT)Zklccz%No CA identifier found matching SKI: z No SCP key found matching KID=0xZxz No certificate chain stored for z&Validating KLCC CA using supplied filezKLCC CA validatedz+No CA supplied, skipping KLCC CA validationz"Unable to get SCP key paramaters (r   r   )r   r
   r;   r   
extensionsget_extension_for_classr   ZSubjectKeyIdentifierZExtensionNotFoundrZ   ZdigestZget_supported_ca_identifiersrW   r   r   Zget_key_informationZkeysr   r   Zget_certificate_bundler   r   Zverify_directly_issued_byr   r   r   Z
public_keyr   r   )r   r   r   r   scpZroot_caZskiZca_skiZrefZca_checkZchainZparentZcertZpub_keys   &&&&          r#   find_scp11_paramsr   [  s   F#J/ 
$R.q1	$$<<T=V=VWC YY%%F!$!A!At!A!L!R!R!T%#''S.#&	 "U !#H!WXX**,113Cww#~gg 4
 ?AwGHH

CF**3/?uEFFLLABF..v6  KK+,KKEF-uRy/C/C/EFc++c ( FDEEF %% 	C	V  F=cU!DEEFs/   H )H .H= 7BH= HH:9H:=Ic          	      sj    V ^8  d   QhR\         P                  R\        R\        R\        R,          /# )r^   r.   
capabilityr   r   N)rA   ZContextr   r   r   r   r   r#   r   r     s5      	$.<ODr$   c                 s   V P                   P                  R 4      pV'       d	   V! V4      # V P                   R,          pVP                  \        P                  8X  dY   WP
                  9   dI   \        P                  R4        \        V\        P                  ^ 4      p\        P                  R4       V# R#   \         d    \        P                  R4        R# i ; i)r   r   zAttempt to find SCP11b keyz5SCP11b key found, using for FIPS capable applicationsz"No SCP11b key found, not using SCPN)r   ZgetZ	transportr	   ZNFCZfips_capabler   r   r   r   ZSCP11br   r;   )r.   r   r   rz   r   Zparamss   &&&   r#   get_scp_paramsr     s     ggkk% Gz"" 776?Dy}},?P?P1P12	?&z6==!DFKKOPM   	?LL=>	?s   1B8 8 CCc                s    V ^8  d   QhR\         \        P                  ,          R\        \        P                  R,          \         \        P                  ,          \        P                  R,          3,          /# )r^   certificatesr   N)r   r   ZCertificateZtupler   r   r#   r   r     sW     $ $4++,$
tXd&6&679I9ID9PP$r$   c                 s   V '       g   R . R 3# V ^ ,          .\        V R,          4      rV '       d   V  F  pVP                  V^ ,          P                  8X  d'   V P                  V4       VP	                  ^ V4        KU  VR,          P                  VP                  8X  g   Ko  V P                  V4       VP                  V4        K  	  \        R4      hR R rCV^ ,          pVP                  VP                  8X  d   VP                  ^ 4      pV'       d]   VR,          P                  P                  \        P                  4      pVP                  P                  '       d   VP                  4       pW1V3# )Nr%   z Incomplete chain of certificatesr   )r   ZsubjectZissuerZremoveZinsertr   r;   r   r   r   r   ZKeyUsagerZ   Zkey_agreement)r   ZorderedrC   r   ZleafZpeekZkues   &      r#   organize_scp11_certificatesr     s(   
 R~ *!_-tL4D/E\
AyyGAJ---##A&q!$r{""ahh.##A&q!  ?@@T 1:D{{dll"[[^ bk$$<<T]]K99""";;=Dr$   )F)T)zTouch your YubiKey...)g      ?r   r?   )Jrk   r   r   Zcollectionsr   Zcollections.abcr   Zenumr   Ztypingr   r   rA   Zcryptographyr   Zcryptography.hazmat.primitivesr   Z,cryptography.hazmat.primitives.asymmetric.ecr   Zyubikit.corer	   r
   r   Zyubikit.core.smartcardr   r   Zyubikit.core.smartcard.scpr   r   r   r   Zyubikit.managementr   r   Zyubikit.oathr   Zyubikit.securitydomainr   Zutilr   Z	getLoggerr0   r   ZCommandr   rB   r:   Zgroup_classrL   rM   ZChoicerN   Z	ParamTyper]   rn   rs   r/   Zclick_force_optionZclick_format_optionrt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rG   r$   r#   <module>r      s  8   
 # *  !   8 O J J A S S 5 & 8 %			8	$EMM (
- 
  & 4 T "' "'JGeoo G     \\)T(N 
 ll	uenU	;	  #  #F  3&(/i #L1"8Fv,$r$   