+
    :i7c  c                   sh   ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	H
t
 ^ RIHtHtHtHtHt ^ RIHt ^RIHtHt ^RIHtHt ^R	IHtHtHtHtHtHtHtH t H!t!H"t" ] PF                  ! ]$4      t%RcR
 R llt&R R lt'R R lt(R t)R t*R t+]! 4       R 4       t,]! 4       R 4       t-]! 4       R 4       t.]! 4       R 4       t/]! 4       R 4       t0]! 4       R 4       t1]! 4       R 4       t2RdR lt3ReR lt4R t5R t6]Pn                  ! RRR ].R!7      t8]Pn                  ! R"R#R$R%R&]-R!7      t9]Pn                  ! R'R(R)R*R+7      t:]! ]
.R,7      ]Pv                  ]R- 4       4       4       t]Py                  4       ]Pv                  R. 4       4       t=]Py                  4       ]Pv                  ]R/ 4       4       4       t>]P                  4       R0 4       t@]@Py                  4       ]Pv                  R1 4       4       tA]@Py                  4       ]Pv                  ]P                  ! R24      ]8]9]:R3 4       4       4       4       4       4       tC]@Py                  R44      ]Pv                  ]P                  ! R24      ]P                  ! R5]P                  ! R64      R7R87      ]Pn                  ! R9R:R;R<7      ]8]9]:R= 4       4       4       4       4       4       4       4       tE]@Py                  4       ]Pv                  ]P                  ! R24      ]P                  ! R>]P                  ! R?4      R@R87      ]RA 4       4       4       4       4       tF]@Py                  4       ]Pv                  ]P                  ! R24      ]Pn                  ! RBRCRD]/R!7      ]Pn                  ! RERFRG]0R!7      ]Pn                  ! RHRIR)RJR+7      ]8]9]:RK 4       4       4       4       4       4       4       4       4       tG]@Py                  4       ]Pv                  ]P                  ! R24      ]Pn                  ! RLRMRNR<7      ]8]9]:RO 4       4       4       4       4       4       4       tH]@Py                  4       ]Pv                  ]P                  ! R24      ]9]RP 4       4       4       4       4       tI]@Py                  4       ]Pv                  ]P                  ! R24      ]Pn                  ! RRRQ].R!7      ]9]Pn                  ! RRRSRT].R!7      RU 4       4       4       4       4       4       tJ]P                  4       RV 4       tK]KPy                  R)RW7      ]Pv                  ]Pn                  ! R"R$RXR)],RY7      ]Pn                  ! RRRZR[],R!7      ]Pn                  ! RHRIR)R\R+7      R] 4       4       4       4       4       tL]KPy                  4       ]Pv                  ]Pn                  ! R"R#R%R^R)]-RY7      ]Pn                  ! RRR_R`Ra]-R!7      Rb 4       4       4       4       tMR# )fi    N)serialization)	TRANSPORT)SW	ApduErrorSmartCardConnection)	ALGORITHMCREDENTIAL_PASSWORD_LENMANAGEMENT_KEY_LENHsmAuthSessionInvalidPinError)
CAPABILITY)generate_random_management_keyget_hsmauth_info)InvalidPasswordErrorparse_private_key)
CliFailclick_callbackclick_force_optionclick_format_optionclick_groupclick_postpone_executionclick_promptget_scp_paramslog_or_echopretty_printc                s$    V ^8  d   QhR\         /# )   e)	Exceptionformat   "7/usr/lib/python3.14/site-packages/ykman/_cli/hsmauth.py__annotate__r    B   s     ) )I )    c                 s   \        V \        4      '       d5   V P                  pV'       d   \        R V RV R24      h\        V R24      h\        V \        4      '       d   V P
                  \        P                  8X  d   \        R4      hV P
                  \        P                  8X  d   \        R4      hV P
                  \        P                  8X  d   \        R4      hV P
                  \        P                  8X  d   \        R4      hV P
                  \        P                  8X  d   \        V R24      hM\        V \        4      '       d   h \        V4      h)	zWrong z, z attempts remaining.z is blocked.z4A credential with the provided label already exists.z:No space left on the YubiKey for YubiHSM Auth credentials.z1Credential with the provided label was not found.zThe device was not touched.z& does not meet complexity requirement.)Z
isinstancer	   Zattempts_remainingr   r   swr   AUTH_METHOD_BLOCKEDZNO_SPACEFILE_NOT_FOUNDZ SECURITY_CONDITION_NOT_SATISFIEDCONDITIONS_NOT_SATISFIED
ValueError)r   default_exception_msgtargetZattempts   &&& r   handle_errorr*   B   s   !_%%''F6("XJ6JKLLVHL122	Ay	!	!442)))PQQTTR[[ VWWTTR&&&MNNTTR888788TTR000VH$JKLL 1	Az	"	"
'
((r!   c                0    V ^8  d   QhR\         R\        /# )r   touch_requiredreturn)Zboolstrr   r   r   r    r    Y   s      $ 3 r!   c                 s    V '       d   R # R# )ZOnZOff )r,      &r   _parse_touch_requiredr1   Y   s    r!   c                r+   )r   	algorithmr-   )r   r.   r   r   r   r    r    `   s      	 c r!   c                 s4    V \         P                  8X  d   R # R# )Z	SymmetricZ
Asymmetric)r   AES128_YUBICO_AUTHENTICATION)r2   r0   r   _parse_algorithmr4   `   s    I:::r!   c                 sj     \         P                  V 4      #   \         d   p\        T4      hR p?ii ; iN)bytesfromhexr   r&   )hexr      & r   
_parse_hexr:   g   s0    }}S!! ms    2-2c                 sn    \        V 4      p \        V 4      V8w  d   \        R V RV^,           R24      hV # )zmust be exactly z bytes long (z hexadecimal digits) long)r:   lenr&   )Zkeykey_lenZkey_type   &&&r   
_parse_keyr>   n   sG    
S/C
3x7wi}Wq[M B 
 	
 Jr!   c                 s    V P                  4       p\        V4      V8:  d   VP                  VR 4      # \        V4      V^,          8X  d   \        V 4      # \	        V R24      h)s    z must be at most 16 bytes)encoder;   Zljustr:   r&   )Zvaluer<   nameZencodedr)   r   _parse_passwordrA   y   sX    llnG
7|w}}We,,
7|w{"%  
v67
88r!   c                 $    \        V\        R 4      # )Management key)r>   r   ctxZparamZvalr=   r   click_parse_management_keyrF      s    c-/?@@r!   c                 rB   )Management password)rA   r   rD   r=   r   click_parse_management_passwordrH      s    3 24IJJr!   c                 rB   Credential password)rA   r   rD   r=   r   click_parse_credential_passwordrK      s    3 79NOOr!   c                 L    \        V\        P                  P                  R 4      # )ENC keyr>   r   r3   r<   rD   r=   r   click_parse_enc_keyrO          c9AAII9UUr!   c                 rL   )MAC keyrN   rD   r=   r   click_parse_mac_keyrR      rP   r!   c                     \        V4      # r5   r:   rD   r=   r   click_parse_card_cryptorU          c?r!   c                 rS   r5   rT   rD   r=   r   click_parse_contextrW      rV   r!   c                 sD    \        V R RRVR7      p\        V\        R4      # ) TF)default
hide_inputshow_defaultconfirmation_promptrG   )r   rA   r   )promptconfirmZmanagement_password   && r   _prompt_management_keyr`      s4    &# /1F r!   c                 s@    \        V R VR7      p\        V\        R4      # )TrZ   r\   rJ   )r   rA   r   )r]   r^   credential_passwordr_   r   _prompt_credential_passwordrc      s.    &# 46K r!   c                 sh    \        R V  24      p\        V\        P                  P                  V 4      # )zEnter )r   r>   r   r3   r<   )r@   Zsymmetric_keyr9   r   _prompt_symmetric_keyrd      s2     6$1My==EEt r!   c                 s    \        V R V 4      # )r@   )Zgetattr)Zfobjr0   r   _fnamere      s    4&&r!   z-cz--credential-passwordzpassword to protect credential)helpcallbackz-mz--management-passwordz--management-keymanagement_keyzthe management passwordz-tz--touchTz-require touch on YubiKey to access credential)Zis_flagrf   )Zconnectionsc                s   V P                   R,          pVP                  \        4      pV P                  VP                  4       \        V \        P                  V4      p\        W#4      V P                   R&    V'       gA   VP                  \        P                  8X  d"   V P                   R,          P                  4        T P                   R,          p\        P                  TP$                  9   ;'       d    \        P                  TP&                  9  T P                   R&   R#   \         d1   pTP                  \        P                   8X  d   \#        R4      hh Rp?ii ; i)z%
Manage the YubiHSM Auth application
Zdevicesessionz.Unable to manage HSMAuth over NFC without SCP.Ninfofips_unready)objZopen_connectionr   Zcall_on_closeZcloser   r
   HSMAUTHr   Z	transportr   ZNFCZget_management_key_retriesr   r"   r   r%   r   fips_capablefips_approved)rE   ZdevZconnZ
scp_paramsr   rj   s   &     r   hsmauthrp      s
    ''(
C23Ddjj!Z%7%7>J'9CGGIcmmy}}<GGI99; 776?Dd/// 	9 	9d&8&88 GGN  442...JKKs   8AD$ $E/+EEc                s>   V P                   R,          p\        V P                   R,          4      p\        P                  VP                  9   d!   \        P                  VP
                  9   VR&   \        P                  ! RP                  \        V4      4      4       R# )z9
Display general status of the YubiHSM Auth application.
rj   ri   zFIPS approved
N)
rl   r   r
   rm   rn   ro   clickechojoinr   )rE   rj   datas   &  r   rj   rj      sm     776?DCGGI./DT... * 2 2d6H6H H_	JJtyyd+,-r!   c                s   V'       g   \         P                  ! RRRR7       \         P                  ! R4       V P                  R,          P	                  4        \         P                  ! R4       \         P                  ! R4       R# )	z
Reset all YubiHSM Auth data.

This action will wipe all data and restore factory setting for
the YubiHSM Auth application on the YubiKey.
z\WARNING! This will delete all stored YubiHSM Auth data and restore factory setting. Proceed?TZabortZerrzResetting YubiHSM Auth data...ri   zHReset complete. All YubiHSM Auth data has been cleared from the YubiKey.z2Your YubiKey now has an empty Management password.N)rr   r^   rs   rl   reset)rE   forces   &&r   rw   rw     s`     (		
 
JJ/0GGI	JJR 
JJCDr!   c                     R# )z Manage YubiHSM Auth credentials.Nr/   r/   r!   r   credentialsrz   )      r!   c                s   V P                   R,          pVP                  4       p\        V4      ^ 8X  d   \        P                  ! R4       R# \        P                  ! R\        V4       R24       \        R V 4       4      p\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   ^
M^	pR	p\        P                  ! VP                  R
RRRVVR7      4       V Fh  p\        P                  ! VP                  VP                  \        VP                  4      \        VP                  4      VP                  VVR7      4       Kj  	  R# )zD
List all credentials.

List all credentials stored on the YubiKey.
ri   zNo items foundzFound z item(s)c              3   sL   "   T F  p\        VP                  4      x  K  	  R # 5ir5   )r;   label).0credr9   r   	<genexpr>list.<locals>.<genexpr>>  s     ?S__s   "$c              3   sZ   "   T F!  qP                   \        P                  8H  x  K#  	  R # 5ir5   )r2   r   ZEC_P256_YUBICO_AUTHENTICATION)r}   Zcr9   r   r   r   A  s!      PU1yFFFPUs   )+TFz.{0: <{label_width}}	{1: <{type_width}}	{2}	{3}ZLabelZTypeZTouchZRetries)Zlabel_widthZ
type_widthN)rl   Zlist_credentialsr;   rr   rs   ZmaxZanyr   r|   r4   r2   r1   r,   Zcounter)rE   ri   ZcredsZmax_size_labelZmax_size_typeZ
format_strr~   s   &      r   listr   .  s3    ggi G$$&E
5zQ

#$

VCJ<x01??? s PUsss PU     	 I


*(  		
 DJJ!!JJ$T^^4)$*=*=>LL ., " 	 r!   r|   c                sJ   V P                   R,          '       d   \        R4      hVf   \        4       pVf   \        4       pV P                   R,          p VP	                  W1W$4       \
        P                  ! R4       R#   \         d   p\        TRR7        Rp?R# Rp?ii ; i)zGenerate an asymmetric credential.

This will generate an asymmetric YubiHSM Auth credential
(private key) on the YubiKey.


LABEL label for the YubiHSM Auth credential
rk   GYubiKey FIPS must be in FIPS approved mode prior to adding credentials.Nri   z Asymmetric credential generated.z)Failed to generate asymmetric credential.r'   )	rl   r   r`   rc   Zgenerate_credential_asymmetricrr   rs   r   r*   )rE   r|   rb   rh   touchri   r   s   &&&&&  r   generater   a  s      ww~U
 	
 /1"9;ggi G
..#6	
 	

56 
%P	
 	

s   (A? ?B"
BB"Zimportzprivate-keyZrbzPRIVATE-KEY)typeZmetavarz-pz
--passwordz(password used to decrypt the private key)rf   c                sb   V P                   R,          '       d   \        R4      hVf   \        4       pVf   \        4       pV P                   R,          pVP	                  4       p Ve   VP                  4       p \        W4      p  TP                  TTTTT4       \        P                  ! R4       R#   \         dJ    \        P                  RRR7       Tf   \        RR	RR
R7      p K  Rp\        P                  ! R4        K  i ; i  \         d   p	\        T	RR7        Rp	?	R# Rp	?	ii ; i)zImport an asymmetric credential.

This will import a private key as an asymmetric YubiHSM Auth credential
to the YubiKey.


LABEL        label for the YubiHSM Auth credential
PRIVATE-KEY  file containing the private key (use '-' to use stdin)
rk   r   Nri   TzError parsing key)Zexc_infozEnter password to decrypt keyrX   F)rY   rZ   r[   zWrong password.zAsymmetric credential imported.z'Failed to import asymmetric credential.r   )rl   r   r`   rc   Zreadr?   r   r   loggerZdebugr   rr   rs   Zput_credential_asymmetricr   r*   )
rE   r|   Zprivate_keyZpasswordrb   rh   r   ri   ru   r   s
   &&&&&&&   r   import_credentialr     s2   ( ww~U
 	
 /1"9;ggi GD
(H	+D;K 	
Y))	
 	

451 $ 	LL,tL<'3#!&	 

,-	2  YQ.WXXYs0   :B4 +D 45D,DDD.D))D.zpublic-key-outputZwbz
PUBLIC-KEYc                s   V P                   R,          p VP                  V4      pTpVP                  V\        P                  P
                  R7      pVP                  V4       \        RV R\        V4       2\        V4       R#   \         de   pTP                  \        P                  8X  d   \        R4      hTP                  \        P                  8X  d   \        R4      h\        R4      hRp?ii ; i)	a2  Export the public key corresponding to an asymmetric credential.

This will export the long-term public key corresponding to the
asymmetric YubiHSM Auth credential stored on the YubiKey.


LABEL      label for the YubiHSM Auth credential
PUBLIC-KEY file to write the public key to (use '-' to use stdout)
ri   )Zencodingr   zPublic key for z written to z*The entry is not an asymmetric credential.zCredential not found.zUnable to export public key.N)rl   Zget_public_keyZpublic_bytesr    ZPublicFormatZSubjectPublicKeyInfoZwriter   re   r   r   r"   r   r#   r   r$   )	rE   r|   Zpublic_key_outputr   ri   Z
public_keyZkey_encodingZpublic_key_encodedr   s	   &&&&     r   exportr     s      ggi G:++E2
'44! --BB 5 

 	 23eWL8I1J0KL	

  :442)))FGGTTR&&&122899:s   A/B C5AC00C5z-Ez	--enc-keyzthe ENC keyz-Mz	--mac-keyzthe MAC keyz-gz
--generatez(generate a random encryption and mac keyc           
     sH   V P                   R,          '       d   \        R4      hVf   \        4       pVf   \        4       pV'       d"   V'       g	   V'       d   V P	                  R4       V'       d   \
        P                  ! \        P                  P                  4      p\
        P                  ! \        P                  P                  4      p\        P                  ! R4       \        P                  ! RP                  \        RVRV/4      4      4       V'       g   \        R	4      pV'       g   \        R
4      pV P                   R,          p VP                  VVVVVV4       \        P                  ! R4       R#   \          d   p	\#        T	RR7        Rp	?	R# Rp	?	ii ; i)zImport a symmetric credential.

This will import an encryption and mac key as a symmetric YubiHSM Auth credential on
the YubiKey.


LABEL  label for the YubiHSM Auth credential
rk   r   Nz:--enc-key and --mac-key cannot be combined with --generatezGenerated ENC and MAC keys:rq   zENC-KEYzMAC-KEYrM   rQ   ri   zSymmetric credential stored.&Failed to import symmetric credential.r   )rl   r   r`   rc   failosZurandomr   r3   r<   rr   rs   rt   r   rd   Zput_credential_symmetricr   r*   )
rE   r|   rb   rh   Zenc_keyZmac_keyr   r   ri   r   s
   &&&&&&&&  r   	symmetricr     s:   . ww~U
 	
 /1"9;WMN**YCCKKL**YCCKKL

01

499\9gy'*RSTU'	2'	2ggi GX((	
 	

12 XQ.VWWXs   ,E> >F!	FF!z-dz--derivation-passwordz)deriviation password for ENC and MAC keysc                sp   V P                   R,          '       d   \        R4      hVf   \        4       pVf   \        4       pVf   \	        RRRR7      pV P                   R,          p VP                  WAW#V4       \        P                  ! R4       R#   \         d   p\        TR	R
7        Rp?R# Rp?ii ; i)zImport a symmetric credential derived from a password.

This will import a symmetric YubiHSM Auth credential by deriving
ENC and MAC keys from a password.


LABEL  label for the YubiHSM Auth credential
rk   r   NzEnter derivation passwordTra   ri   z$Derived symmetric credential stored.r   r   )
rl   r   r`   rc   r   Zput_credential_derivedrr   rs   r   r*   )rE   r|   Zderivation_passwordrb   rh   r   ri   r   s   &&&&&&  r   deriver   :  s    & ww~U
 	
 /1"9;"*' $
 ggi GX&&#6U	
 	

9: XQ.VWWXs   ')B B5B00B5c                s.   Vf   \        4       pV'       g   \        P                  ! RV R2RRR7       V P                  R,          p VP	                  W!4       \        P
                  ! R4       R#   \         d   p\        TRR	7        Rp?R# Rp?ii ; i)
z
Delete a credential.

This will delete a YubiHSM Auth credential from the YubiKey.


LABEL a label to match a single credential (as shown in "list")
NzDelete credential: z ?Trv   ri   zCredential deleted.zFailed to delete credential.r   )r`   rr   r^   rl   Zdelete_credentialrs   r   r*   )rE   r|   rh   rx   ri   r      &&&&  r   deleter   j  s     /1!%+	
 ggi G
!!.8

() 
"@	
 	

s   'A1 1B<BBzcurrent credential passwordz-nz--new-credential-passwordz a new credential password to setc                s   V P                   R,          pV'       d   V'       d   V P                  R4       Vf   Vf   \        P                  ! R4       \        P                  ! R4       \        P                  ! R4       \	        R\        P
                  ! ^^.4      ^RR	7      pV^8X  d   \        R
4      pM
\        4       pVRJpVf   \        RRR7      p V'       d   VP                  WV4       MVP                  WV4       \        P                  ! R4       R#   \         d$   p\        TRT'       d   RMRR7        Rp?R# Rp?ii ; i)a1  
Change the password of a credential.

This will change the password of a YubiHSM Auth credential stored on the YubiKey.

Changing a password requires either the current password for the credential,
or the management password (not both).


LABEL a label to match a single credential (as shown in "list")
ri   zA--credential-password and --management-password can't be combinedNzChoose authentication method:z  [1] Current credential passwordz [2] Management passwordzEnter selectionF)r   rY   Zshow_choicesz!Enter current credential passwordz!Enter the new credential passwordTr^   zCredential password changed.z%Failed to change credential password.rG   rJ   r'   r(   )rl   r   rr   rs   r   ZChoicerc   r`   Z change_credential_password_adminZchange_credential_passwordr   r*   )	rE   r|   rb   rh   Znew_credential_passwordri   ZmethodZuse_management_keyr   s	   &&&&&    r   change_passwordr     s+   > ggi G~TU"5"=

23

56

-.q!f%	
 Q;"=3# 45N't3&"=/#

44'> ..,C 	

12 
"I! )&	
 	

s   D ;D E
'EE
c                 ry   )z&Manage Management Key for YubiHSM AuthNr/   r/   r!   r   accessr     r{   r!   )Zhiddenzcurrent management key)rf   r[   rg   z--new-management-keyza new management key to setzJgenerate a random management key (can't be used with --new-management-key)c                s   Vf   \        R4      pV P                  R,          pV'       d   V'       d   V P                  R4       Vf   V'       d`   V P                  R,          P                  R8  d   \	        R4      h\        4       p\        P                  ! RVP                  4        24       M" \        P                  \        RR	R	R
7      4      p\        V4      \        8w  d   \	        R\        ,          4      h VP                  W4       \        P                  ! R4       R#   \         d    T P                  R4        Lri ; i  \         d   p\!        TRRR7        Rp?R# Rp?ii ; i)
Change the management key.

Allows you to change the management key which is required to add and delete
YubiHSM Auth credentials stored on the YubiKey.
Nz7Enter current management key [blank to use default key]ri   z?Invalid options: --new-management-key conflicts with --generaterj   zDGenerating a random management key is not supported on this YubiKey.zGenerated management key: zEnter the new management keyTra   z(New management key has the wrong format.z8Management key has the wrong length (expected %d bytes).zManagement key changed.z Failed to change management key.rC   r   )i   i   )r`   rl   r   Zversionr   r   rr   rs   r8   r6   r7   r   r   r;   r   put_management_keyr*   )rE   rh   new_management_keyr   ri   r   r   r   change_management_keyr     sM   : /E
 ggi G hRS!wwv&&&0  "@!AJJ34F4J4J4L3MNO	E%*]] 6#',0&" "44F !
 	


"">F

,-  ECDE  
"D#	
 	

s*   0!D% <'E %EEE+E&&E+zcurrent management passwordz--new-management-passwordr   z a new management password to setc                s
   Vf   \        R4      pVf   \        RRR7      pV P                  R,          p VP                  W4       \        P                  ! R4       R#   \
         d   p\        TRR	R
7        Rp?R# Rp?ii ; i)r   Nz&Enter your current management passwordzEnter a new management passwordTr   ri   zManagement password changed.z%Failed to change management password.rG   r   )r`   rl   r   rr   rs   r   r*   )rE   rh   r   ri   r   s   &&&  r   change_management_passwordr   0  s    2 /4
 !3-t
 ggi G
"">F

12 
"I(	
 	

s   'A B)A==BrI   )zEnter management passwordF)zEnter credential passwordF)NZloggingr   rr   Zcryptography.hazmat.primitivesr    Zyubikit.corer   Zyubikit.core.smartcardr   r   r   Zyubikit.hsmauthr   r   r   r   r	   Zyubikit.managementr
   rp   r   r   Zutilr   r   r   r   r   r   r   r   r   r   r   r   Z	getLoggerZ__name__r   r*   r1   r4   r:   r>   rA   rF   rH   rK   rO   rR   rU   rW   r`   rc   rd   re   ZoptionZ click_credential_password_optionZclick_management_key_optionZclick_touch_optionZpass_contextZcommandrj   rw   Zgrouprz   r   Zargumentr   ZFiler   r   r   r   r   r   r   r   r   r/   r!   r   <module>r      s  8  	  8 " E E  * ;   
		8	$).9 A A K K P P V V V V    
	' $)<<	),	$   $ll	",  \\)T(W 
 -./   06 	
.  
. 	E   E2 	+ + .  .b !
   "   
D XEJJt$4mLdL'QR!:Y   " S M   :Yz #%**T*:LQ":  R   
":J dKm>QRdKm>QR,+U "4X   " S S   4Xn 
!(S "$X   "   $XN 
     

@ 	&,	 	+,	;
     ;
| 	1 1 t	!' 	&'	 	U	6
  *6
r 	&, 	+,
  "
r!   