+
    :i  c                  s	  a  0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
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 ^ RIHt ^ R	IHt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)H*t*H+t+H,t,H-t-H.t.H/t/H0t0 ^RI1H2t2H3t3H4t4H5t5H6t6H7t7 ]Pp                  ! ]94      t:Rt;Rt<] ! R R]4      4       t=] ! R R]4      4       t>] ! R R]4      4       t?Rut@^stA^tB^tC^tD^tE^tF^tGRtH] ! R R]4      4       tI] ! R R]4      4       tJR R ltK ! R R]L4      tM] ! R R ]4      4       tN] ! R! R"4      4       tO] ! R# R$4      4       tP] ! R% R&]4      4       tQ] ! R' R(4      4       tR] ! R) R*4      4       tS] ! R+ R,]L]
4      4       tT] ! R- R.]4      4       tU] ! R/ R0]4      4       tV]]U]V3,          tW]]U]L3,          tX]]U]Y3,          tZ]P                  ]P                  ,          ]P                  ,          t^R1]_R2&   ]^]P                  ,          taR1]_R3&   ]P                  ]P                  ,          ]P                  ,          teR1]_R4&   ]P                  ]e,          tgR1]_R5&   ] ! R6 R7]P                  4      4       ti] ! R8 R9]4      4       tj] ! R: R;]4      4       tk] ! R< R=]i4      4       tl ! R> R?]*4      tm ! R@ RA]m]
4      tn] ! RB RC]4      4       to] ! RD RE]i4      4       tpRF RG ltqRH RI ltrRJ RK lts] ! RL RM4      4       tt] ! RN RO4      4       tu] ! RP RQ4      4       tv] ! RR RS]P                  4      4       tw] ! RT RU]w4      4       tx] ! RV RW]4      4       ty] ! RX RY]w4      4       tz] ! RZ R[]P                  4      4       t{] ! R\ R]]{4      4       t|] ! R^ R_]|4      4       t}] ! R` Ra]{4      4       t~Rb Rc ltRvRd Re lltRf Rg ltRh Ri lt]EP                  ]LEP	                  Rj4      ]EP
                  ]LEP	                  Rk4      ]EP                  ]LEP	                  Rl4      ]EP                  ]LEP	                  Rm4      ]EP                  ]LEP	                  Rn4      ]EP                  ]LEP	                  Ro4      ]EP                  ]LEP	                  Rp4      ]EP                  ]LEP	                  Rq4      /tRr t ! Rs Rt4      tR# )w    )annotationsN)	dataclass)EnumIntEnumIntFlagunique)ClassVarMappingSequenceSupportsBytes	TypeAlias)x509)default_backend)hashes)eced25519rsax25519)	Prehashedencode_dss_signature)EncodingNoEncryptionPrivateFormatPublicFormat)	InvalidPinErrorNotSupportedErrorOidTlvVersion_override_version	bytes2int	int2bytesrequire_version)AIDSW	ApduErrorScpKeyParamsSmartCardConnectionSmartCardProtocolZ123456Z12345678c                  s~    ] tR t^Ut^ t^t^t^t^t]	R R l4       t
R R lt]R R l4       t]R R l4       tR	 tR
tR# )UIFc                   V ^8  d   QhRR/# )   encodedbytes Zformat   "4/usr/lib/python3.14/site-packages/yubikit/openpgp.py__annotate__UIF.__annotate__^   s      E     c                	s     V ! V^ ,          4      # r    r-   clsr+      &&r0   parseZ	UIF.parse]   s    71:r3   c               r)   r*   returnr,   r-   r.   r/   r0   r1   r2   a   s     K K5 Kr3   c                	sN    \         P                  ! R V \        P                  4      # )z>BB)structpackGENERAL_FEATURE_MANAGEMENTBUTTONself   &r0   	__bytes__ZUIF.__bytes__a   s    {{5$(B(I(IJJr3   c               r)   r*   r:   boolr-   r.   r/   r0   r1   r2   e   s     5 5$ 5r3   c                	H    V \         P                  \         P                  39   # N)r(   FIXEDCACHED_FIXEDr?   rA   r0   is_fixedZUIF.is_fixedd   s    		3#3#3444r3   c               r)   rC   r-   r.   r/   r0   r1   r2   i   s     6 64 6r3   c                	rE   rF   )r(   CACHEDrH   r?   rA   r0   	is_cachedZUIF.is_cachedh   s    

C$4$4555r3   c                	s    V \         P                  8X  d   R # V \         P                  8X  d   R# V P                  ^ ,          V P                  R,          P	                  4       ,           # )z
On (fixed)zCached (fixed)   NN)r(   rG   rH   namelowerr?   rA   r0   __str__ZUIF.__str__l   sF    3993####yy|diim11333r3   r-   N)__name__
__module____qualname____firstlineno__OFFZONrG   rJ   rH   classmethodr8   rB   propertyrI   rK   rP   __static_attributes__r-   r3   r0   r(   r(   U   s`    
C	BEFL K 5 5 6 64r3   r(   c                  s$    ] tR t^tt^ t^tR tRtR# )
PIN_POLICYc                	st    V P                   ^ ,          V P                   R,          P                  4       ,           # )r    rL   )rN   rO   r?   rA   r0   rP   ZPIN_POLICY.__str__y   s&    yy|diim11333r3   r-   N)rQ   rR   rS   rT   ZALWAYSONCErP   rX   r-   r3   r0   rY   rY   t   s    FD4r3   rY   c                  sV    ] tR t^}t^ t^$t^,t^*t^Dt^Gt	^t
^t^t^t^t^t^t^t^t^tRtR# )INSr-   N)rQ   rR   rS   rT   VERIFY
CHANGE_PINRESET_RETRY_COUNTERPSOACTIVATEGENERATE_ASYMGET_CHALLENGEINTERNAL_AUTHENTICATESELECT_DATAGET_DATAPUT_DATAPUT_DATA_ODD	TERMINATEGET_VERSIONSET_PIN_RETRIESGET_ATTESTATIONrX   r-   r3   r0   r[   r[   }   sT    FJ
CHMM KHHLIKOOr3   r[   I  c                  s"    ] tR t^t^t^t^tRtR# )PWr-   N)rQ   rR   rS   rT   USERRESETADMINrX   r-   r3   r0   rm   rm      s    DEEr3   rm   c                  s    ] tR t^tRtRtRtRt^Ot^[t	^^t
RtRtRtRtR	tR
t^et^nt^t^t^t^t^t^t^t^t^t^t^t^t^t^t ^t!^t"^t#^t$^t%^t&^t'^t(^zt)Rt*^t+^t,^t-Rt.R# )DOi  i  i  i  i-  i5_  iP_  iR_  if  it  i!  r-   N)/rQ   rR   rS   rT   ZPRIVATE_USE_1ZPRIVATE_USE_2ZPRIVATE_USE_3ZPRIVATE_USE_4r"   NAMEZ
LOGIN_DATALANGUAGESEXZURLHISTORICAL_BYTESEXTENDED_LENGTH_INFOr=   CARDHOLDER_RELATED_DATAAPPLICATION_RELATED_DATAALGORITHM_ATTRIBUTES_SIGALGORITHM_ATTRIBUTES_DECALGORITHM_ATTRIBUTES_AUTALGORITHM_ATTRIBUTES_ATTPW_STATUS_BYTESZFINGERPRINT_SIGZFINGERPRINT_DECZFINGERPRINT_AUTZFINGERPRINT_ATTZCA_FINGERPRINT_1ZCA_FINGERPRINT_2ZCA_FINGERPRINT_3ZCA_FINGERPRINT_4ZGENERATION_TIME_SIGZGENERATION_TIME_DECZGENERATION_TIME_AUTZGENERATION_TIME_ATTRESETTING_CODEUIF_SIGUIF_DECUIF_AUTUIF_ATTSECURITY_SUPPORT_TEMPLATECARDHOLDER_CERTIFICATEKDFALGORITHM_INFORMATIONATT_CERTIFICATErX   r-   r3   r0   rq   rq      s    MMMM
CDJH
C
C!!'"#####OOOOONGGGG $#
C Or3   rq   c               s     V ^8  d   QhRRRR/# )r*   valueintr:   r-   r.   r/   r0   r1   r1      s     - - - -r3   c                s>    ^
V ^,	          ,          V ^,          ,           # )
   r-   r   rA   r0   _bcdr      s    !,,r3   c                  s\    ] tR t^tRt]R R l4       t]R R l4       t]R R l4       tRt	R	# )

OpenPgpAidzOpenPGP Application Identifier (AID)

The OpenPGP AID is a string of bytes identifying the OpenPGP application.
It also embeds some values which are accessible though properties.
c               r)   )r*   r:   ztuple[int, int]r-   r.   r/   r0   r1   OpenPgpAid.__annotate__   s     . . .r3   c                sJ    \        V ^,          4      \        V ^,          4      3# )zGOpenPGP version (tuple of 2 integers: main version, secondary version).r   r?   rA   r0   versionZOpenPgpAid.version   s     T!WtDG}--r3   c               r)   r*   r:   r   r-   r.   r/   r0   r1   r      s     % %c %r3   c                s&    \        V R,          4      # )zg16-bit integer value identifying the manufacturer of the device.

This should be 6 for Yubico devices.
:   r   N)r   r?   rA   r0   manufacturerZOpenPgpAid.manufacturer   s     d$$r3   c               r)   r   r-   r.   r/   r0   r1   r      s     8 8 8r3   c                s     \        V R,          P                  4       4      #   \         d*    \        P                  ! RT R,          4      ^ ,          ) u # i ; i)zThe serial number of the YubiKey.

NOTE: This value is encoded in BCD. In the event of an invalid value (hex A-F)
the entire 4 byte value will instead be decoded as an unsigned integer,
and negated.
:r   i   N>I)r   Zhex
ValueErrorr;   unpackr?   rA   r0   serialZOpenPgpAid.serial   sI    	8tE{()) 	8MM$U4Q777	8s   " 1AAr-   N)
rQ   rR   rS   rT   __doc__rW   r   r   r   rX   r-   r3   r0   r   r      sC     . . % % 8 8r3   r   c                  s6    ] tR t^t^t^t^t^t^t^ t	^@t
^tRtR# )EXTENDED_CAPABILITY_FLAGSr-   N)rQ   rR   rS   rT   r   ZPSO_DEC_ENC_AESALGORITHM_ATTRIBUTES_CHANGEABLEZPRIVATE_USEZPW_STATUS_CHANGEABLEZ
KEY_IMPORTrb   ZSECURE_MESSAGINGrX   r-   r3   r0   r   r      s-    
CO&,#K!JMr3   r   c                  sL    ] tR tRt$ R]R&   R]R&   R]R&   ]R R l4       tR	tR
# )CardholderRelatedDatai  r,   rN   Zlanguager   Zsexc               r)   )r*   r:   r   r-   r.   r/   r0   r1   Z"CardholderRelatedData.__annotate__  s     
 
4 
r3   c                	s   \         P                  ! \         P                  ! \        P                  V4      4      pV ! V\        P
                  ,          V\        P                  ,          V\        P                  ,          ^ ,          4      # r4   )r   
parse_dictr   rq   rw   rr   rs   rt   r6   r+   data   && r0   r8   ZCardholderRelatedData.parse  sT    ~~cjj)C)CWMNMLO
 	
r3   r-   NrQ   rR   rS   rT   __annotations__rV   r8   rX   r-   r3   r0   r   r     s#    
KO	H
 
r3   r   c                  sB    ] tR tRt$ R]R&   R]R&   ]R R l4       tRtR# )	ExtendedLengthInfoi  r   Zrequest_max_bytesZresponse_max_bytesc               r)   )r*   r:   r   r-   r.   r/   r0   r1   ZExtendedLengthInfo.__annotate__  s     
 
1 
r3   c           
     	s    \         P                  ! V4      pV ! \        \         P                  ! ^V^ ,          4      4      \        \         P                  ! ^V^,          4      4      4      # )r*   )r   
parse_listr   r   r   r   r0   r8   ZExtendedLengthInfo.parse  sK    ~~g&cjjtAw/0cjjtAw/0
 	
r3   r-   Nr   r-   r3   r0   r   r     s     
 
r3   r   c                  s6    ] tR tRt^t^t^t^t^t^ t	^@t
^tRtR# )r=   i$  r-   N)rQ   rR   rS   rT   ZTOUCHSCREENZ
MICROPHONEZLOUDSPEAKERZLEDZKEYPADr>   Z	BIOMETRICZDISPLAYrX   r-   r3   r0   r=   r=   $  s*    KJK
CFFIGr3   r=   c                  st    ] tR tRt$ R]R&   R]R&   R]R&   R]R&   R]R&   R	]R
&   R	]R&   ]R R l4       tRtR# )ExtendedCapabilitiesi0  r   flagsr   Zsm_algorithmchallenge_max_lengthZcertificate_max_lengthZspecial_do_max_lengthrD   Zpin_block_2_formatZmse_commandc                    V ^8  d   QhRRRR/# )r*   r+   r,   r:   r   r-   r.   r/   r0   r1   Z!ExtendedCapabilities.__annotate__;  s     	
 	
E 	
&: 	
r3   c           
     	s    V ! \        V^ ,          4      V^,          \        VR,          4      \        VR,          4      \        VR,          4      V^,          ^8H  V^	,          ^8H  4      # )r    :r*      N:r      N:r   r   N)r   r   r5   r7   r0   r8   ZExtendedCapabilities.parse:  s\    %gaj1AJgcl#gcl#gcl#AJ!OAJ!O
 	
r3   r-   Nr   r-   r3   r0   r   r   0  s>    $$	
 	
r3   r   c                  s    ] tR tRt$ R]R&   R]R&   R]R&   R]R&   R]R&   R]R	&   R]R
&   R R ltR R lt]R R l4       tRt	R# )PwStatusiG  rY   Zpin_policy_userr   Zmax_len_userZmax_len_resetZmax_len_adminZattempts_userattempts_resetZattempts_adminc               r   r*   pwrm   r:   r   r-   r.   r/   r0   r1   PwStatus.__annotate__Q  s     ; ;b ;S ;r3   c                	P    \        V R VP                  P                  4        24      # )Zmax_len_getattrrN   rO   r@   r   r7   r0   get_max_lenZPwStatus.get_max_lenQ  s!    tx'89::r3   c               r   r   r-   r.   r/   r0   r1   r   T  s     < <r <c <r3   c                	r   )Z	attempts_r   r   r7   r0   get_attemptsZPwStatus.get_attemptsT  s!    ty(9:;;r3   c               r   )r*   r+   r,   r:   r   r-   r.   r/   r0   r1   r   X  s     
 
E 
h 
r3   c           
     	s     \        V^ ,          4      pV ! VV^,          V^,          V^,          V^,          V^,          V^,          4      #   \         d    \         P                  p LUi ; ir4   )rY   r   rZ   )r6   r+   Zpolicyr   r0   r8   ZPwStatus.parseW  sk    	%
+F AJAJAJAJAJAJ
 	
  	%__F	%s   A A*)A*r-   N)
rQ   rR   rS   rT   r   r   r   rV   r8   rX   r-   r3   r0   r   r   G  sJ    ;< 
 
r3   r   c                  sj    ] tR tRtRt]! ^4      t]! ^4      t]! ^4      t]! ^]! ^R4      4      t	Rt
R# )CRTih  z"Control Reference Template values.s   r-   N)rQ   rR   rS   rT   r   r   SIGDECAUTATTrX   r-   r3   r0   r   r   h  s3    ,
d)C
d)C
d)C
dCg&
'Cr3   r   c                  s    ] tR tRt^t^t^t^t]R R l4       t	]R R l4       t
]R R l4       t]R R	 l4       t]R
 R l4       tRtR# )KEY_REFir  c               r)   r*   r:   rq   r-   r.   r/   r0   r1   KEY_REF.__annotate__z  s     @ @ @r3   c                	<    \        \        R V P                   24      # )ZALGORITHM_ATTRIBUTES_r   rq   rN   r?   rA   r0   algorithm_attributes_doZKEY_REF.algorithm_attributes_doy  s    r2499+>??r3   c               r)   r   r-   r.   r/   r0   r1   r   ~  s     / / /r3   c                	r   )ZUIF_r   r?   rA   r0   uif_doZKEY_REF.uif_do}  s    rT$))-..r3   c               r)   r   r-   r.   r/   r0   r1   r     s     ; ;B ;r3   c                	r   )ZGENERATION_TIME_r   r?   rA   r0   generation_time_doZKEY_REF.generation_time_do  s    r-dii[9::r3   c               r)   r   r-   r.   r/   r0   r1   r     s     7 7 7r3   c                	r   )ZFINGERPRINT_r   r?   rA   r0   fingerprint_doZKEY_REF.fingerprint_do  s    r\$))566r3   c               r)   )r*   r:   r   r-   r.   r/   r0   r1   r     s     ' 'S 'r3   c                	s6    \        \        V P                  4      # rF   )r   r   rN   r?   rA   r0   crtZKEY_REF.crt  s    sDII&&r3   r-   N)rQ   rR   rS   rT   r   r   r   r   rW   r   r   r   r   r   rX   r-   r3   r0   r   r   r  sz    
C
C
C
C@ @ / / ; ; 7 7 ' 'r3   r   c                  s"    ] tR tRt^ t^t^tRtR# )
KEY_STATUSi  r-   N)rQ   rR   rS   rT   ZNONEZ	GENERATEDZIMPORTEDrX   r-   r3   r0   r   r     s    DIHr3   r   r   EcPublicKey	PublicKeyEcPrivateKey
PrivateKeyc                  s    ] tR tRt$ RtR]R&   R]R&   ]R R l4       t]P                  R	 R
 l4       t
]]P                  R R l4       4       tRtR# )AlgorithmAttributesi  z!OpenPGP key algorithm attributes.zClassVar[Sequence[int]]_supported_idsr   algorithm_idc               r   )r*   r+   r,   r:   r   r-   r.   r/   r0   r1    AlgorithmAttributes.__annotate__  s     5 5E 5&9 5r3   c                	s    V^ ,          pV P                  4        F-  pW#P                  9   g   K  VP                  W!R,          4      u # 	  \        R4      h)r    rL   zUnsupported algorithm ID)__subclasses__r   _parse_datar   )r6   r+   r   Zsub_cls   &&  r0   r8   ZAlgorithmAttributes.parse  sM    qz))+G555**<EE , 344r3   c               r)   r9   r-   r.   r/   r0   r1   r          $ $5 $r3   c                	    \        4       hrF   ZNotImplementedErrorr?   rA   r0   rB   ZAlgorithmAttributes.__bytes__      !##r3   c               $    V ^8  d   QhRRRRRR/# )r*   algr   r+   r,   r:   r   r-   r.   r/   r0   r1   r     s"     $ $c $E $6I $r3   c                	r   rF   r   )r6   r   r+      &&&r0   r   ZAlgorithmAttributes._parse_data       "##r3   r-   N)rQ   rR   rS   rT   r   r   rV   r8   abcabstractmethodrB   r   rX   r-   r3   r0   r   r     s_    +++5 5 	$ $ $  $r3   r   c                  s"    ] tR tRtRtRtRtRtR# )RSA_SIZEi     i   i   r-   N)rQ   rR   rS   rT   RSA2048RSA3072RSA4096rX   r-   r3   r0   r   r     s    GGGr3   r   c                  s&    ] tR tRt^ t^t^t^tRtR# )RSA_IMPORT_FORMATi  r-   N)	rQ   rR   rS   rT   STANDARDZSTANDARD_W_MODr   	CRT_W_MODrX   r-   r3   r0   r   r     s    HN
CIr3   r   c                  s    ] tR tRt$ ^.tR]R&   R]R&   R]R&   ]]P                  3R R ll4       t	]R	 R
 l4       t
R R ltRtR# )RsaAttributesi  r   n_lene_lenr   import_formatc               r   )r*   r   r   r   r   r:   r   r-   r.   r/   r0   r1   RsaAttributes.__annotate__  s(     3 33 )3 
	3r3   c                	s    V ! ^V^V4      # )rM   r-   )r6   r   r   r   r0   createZRsaAttributes.create  s     4M22r3   c               r)   )r*   r:   r   r-   r.   r/   r0   r1   r     s     4 4- 4r3   c                	s\    \         P                  ! R V4      w  r4pV ! WV\        V4      4      # )z>HHB)r;   r   r   )r6   r   r+   nef   &&&   r0   r   ZRsaAttributes._parse_data  s+    --0a31/233r3   c               r)   r9   r-   r.   r/   r0   r1   r     s     
 
5 
r3   c                	s    \         P                  ! R V P                  V P                  V P                  V P
                  4      # )z>BHHB)r;   r<   r   r   r   r   r?   rA   r0   rB   ZRsaAttributes.__bytes__  s2    {{T&&

DJJ@R@R
 	
r3   r-   N)rQ   rR   rS   rT   r   r   rV   r   r   r   r   rB   rX   r-   r3   r0   r   r     sT    VNJJ$$ ,=+E+E3 3 4 4
 
r3   r   c                  s:    ] tR tRtR R ltR R ltR R ltRtR	# )
CurveOidi  c               r)   r*   r:   strr-   r.   r/   r0   r1   CurveOid.__annotate__  s      3 r3   c                	sj    \          F(  pV P                  V4      '       g   K  VP                  u # 	  R # )zUnknown Curve)OIDZ
startswithrN   )r@   oid   & r0   	_get_nameZCurveOid._get_name  s)    Cs##xx  r3   c               r)   r   r-   r.   r/   r0   r1   r     s          r3   c                	s"    V P                  4       # rF   )r   r?   rA   r0   rP   ZCurveOid.__str__  s    ~~r3   c               r)   r   r-   r.   r/   r0   r1   r     s     ; ;# ;r3   c                	sB    V P                  4        R V P                   R2# )Z())r   Zdotted_stringr?   rA   r0   __repr__ZCurveOid.__repr__  s$    .."#1T%7%7$8::r3   r-   N)rQ   rR   rS   rT   r   rP   r   rX   r-   r3   r0   r   r     s     ; ;r3   r   c                  sv   ] tR tRt]P                  R4      t]P                  R4      t]P                  R4      t]P                  R4      t	]P                  R4      t
]P                  R4      t]P                  R4      t]P                  R	4      t]P                  R
4      t]R R l4       tR R ltR R ltRtR# )r   i  z1.2.840.10045.3.1.7z1.3.132.0.10z1.3.132.0.34z1.3.132.0.35z1.3.36.3.3.2.8.1.1.7z1.3.36.3.3.2.8.1.1.11z1.3.36.3.3.2.8.1.1.13z1.3.6.1.4.1.3029.1.5.1z1.3.6.1.4.1.11591.15.1c               r   )r*   private_keyr   r:   r   r-   r.   r/   r0   r1   OID.__annotate__  s     4 4L 4X 4r3   c                	s   \        V\        P                  4      '       d&   VP                  P                  P                  4       pME\        V\        P                  4      '       d   R pM"\        V\        P                  4      '       d   RpV  F&  pVP                  P                  4       X8X  g   K$  Vu # 	  \        R4      h)r   r   zUnsupported private key)
isinstancer   ZEllipticCurvePrivateKeycurverN   rO   r   Ed25519PrivateKeyr   X25519PrivateKeyr   )r6   r   rN   r   r   r0   	_from_keyZOID._from_key  s    k2#=#=>>$$))//1D+w'@'@AA K)@)@AACxx~~4'
  233r3   c               r)   r   r-   r.   r/   r0   r1   r     s        #  r3   c                	,    \        V P                  4      # rF   )Zreprr   r?   rA   r0   r   ZOID.__repr__  s    DJJr3   c               r)   r   r-   r.   r/   r0   r1   r     s       r3   c                	r   rF   )r   r   r?   rA   r0   rP   ZOID.__str__  s    4::r3   r-   N)rQ   rR   rS   rT   r   Zfrom_stringZ	SECP256R1Z	SECP256K1Z	SECP384R1Z	SECP521R1ZBrainpoolP256R1ZBrainpoolP384R1ZBrainpoolP512R1X25519Ed25519rV   r   r   rP   rX   r-   r3   r0   r   r     s    $$%:;I$$^4I$$^4I$$^4I**+ABO**+BCO**+BCO!!":;F""#;<G4 4  r3   r   c                  s    ] tR tRt^ t^tRtR# )EC_IMPORT_FORMATi  r-   N)rQ   rR   rS   rT   r   STANDARD_W_PUBKEYrX   r-   r3   r0   r   r     s    Hr3   r   c                  sl    ] tR tRt$ . ROtR]R&   R]R&   ]R R l4       t]R R	 l4       tR
 R lt	Rt
R# )EcAttributesi  r   r   r   r   c               r   )r*   key_refr   r   r   r:   r  r-   r.   r/   r0   r1   EcAttributes.__annotate__$  s!     8 8W 88 8 8r3   c                	s    V\         P                  8X  d   ^pMV\        P                  8X  d   ^pM^pV ! W2\        P
                  4      # )   )r   r   r   r   r   r   )r6   r  r   r      &&& r0   r   ZEcAttributes.create#  s=    #++C#CC3-6677r3   c               r)   )r*   r:   r  r-   r.   r/   r0   r1   r  .  s     * *, *r3   c                	s    VR,          ^8X  d   \         P                  pVRR pM\         P                  pTpV ! V\        V4      V4      # )rM   N)r   r  r   r   )r6   r   r+   r   r      &&&  r0   r   ZEcAttributes._parse_data-  sG    2;$ 22A#2,C ))AC3q))r3   c               r)   r9   r-   r.   r/   r0   r1   r  8  s      5 r3   c                	s    \         P                  ! R V P                  4      V P                  ,           pV P                  \
        P                  8X  d)   V\         P                  ! R V P                  4      ,          pV# )>B)r;   r<   r   r   r   r   r  )r@   bufr   r0   rB   ZEcAttributes.__bytes__8  sV    kk$ 1 12TXX=!1!C!CC6;;tT%7%788C
r3   r-   N)i   i   r  )rQ   rR   rS   rT   r   r   rV   r   r   rB   rX   r-   r3   r0   r  r    sB    'N	M##8 8 * * r3   r  c               r   )r*   r+   r,   r:   KeyInformationr-   r.   r/   r0   r1   r1   ?  s      E n r3   c           	     s    \        ^ \        V 4      ^4       Uu/ uF+  p\        W,          4      \        W^,           ,          4      bK-  	  up# u upi r4   )rangelenr   r   )r+   ir   r0   _parse_key_informationr  ?  sM     q#g,**A 	
ZA77*  s   1Ac               r   )r*   r+   r,   r:   Fingerprintsr-   r.   r/   r0   r1   r1   F  s       < r3   c           	     s    \        \        4      p\        \        ^ \	        V 4      ^4      4       UUu/ uF  w  r#W,          WV^,            bK  	  upp# u uppi r4   )listr   	enumerater  r  r+   slotsr  Zo   &   r0   _parse_fingerprintsr  F  sR    ME2;E!S\SU<V2W2W$!'a"f%%2W  s   Ac               r   )r*   r+   r,   r:   GenerationTimesr-   r.   r/   r0   r1   r1   M  s      u  r3   c                s    \        \        4      p\        \        ^ \	        V 4      ^4      4       UUu/ uF   w  r#W,          \        WV^,            4      bK"  	  upp# u uppi r4   )r  r   r  r  r  r   r  r  r0   _parse_timestampsr  M  s[    ME eAs7|Q788DA 	)GA.//8  s   &Ac                  s    ] tR tRt$ R]R&   R]R&   R]R&   R]R&   R]R	&   R
]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   ]R R l4       tR R ltR R ltRt	R# ) DiscretionaryDataObjectsiU  r   extended_capabilitiesr   Zattributes_sigZattributes_decZattributes_autzAlgorithmAttributes | NoneZattributes_attr   	pw_statusr  fingerprintsZca_fingerprintsr  generation_timesr  key_information
UIF | Noneuif_siguif_decuif_autZuif_attc               r   )r*   r+   r,   r:   r  r-   r.   r/   r0   r1   %DiscretionaryDataObjects.__annotate__g  s     
 
E 
&> 
r3   c                	s   \         P                  ! V4      pT ! \        P                  V\        ,          4      \
        P                  V\        P                  ,          4      \
        P                  V\        P                  ,          4      \
        P                  V\        P                  ,          4      \        P                  V9   d+   \
        P                  V\        P                  ,          4      MR \        P                  V\        P                  ,          4      \        V\        ,          4      \        V\        ,          4      \!        V\"        ,          4      \%        VP'                  \(        R4      4      \        P*                  V9   d+   \,        P                  V\        P*                  ,          4      MR \        P.                  V9   d+   \,        P                  V\        P.                  ,          4      MR \        P0                  V9   d+   \,        P                  V\        P0                  ,          4      MR \        P2                  V9   d/   \,        P                  V\        P2                  ,          4      4      # R 4      # )Nr3   )r   r   r   r8   TAG_EXTENDED_CAPABILITIESr   rq   ry   rz   r{   r|   r   r}   r  TAG_FINGERPRINTSTAG_CA_FINGERPRINTSr  TAG_GENERATION_TIMESr  getTAG_KEY_INFORMATIONr   r(   r   r   r   r   r   r0   r8   ZDiscretionaryDataObjects.parsef  s   ~~g& &&t,E'FG%%d2+F+F&GH%%d2+F+F&GH%%d2+F+F&GH ..$6 $))$r/J/J*KLNN4 2 234%5 67%8 9:d#789"488,?#EF,.JJ$,>SYYtBJJ'(D,.JJ$,>SYYtBJJ'(D,.JJ$,>SYYtBJJ'(D,.JJ$,>SYYtBJJ'(%
 	
$ EI%
 	
r3   c               r   r*   r  r   r:   r   r-   r.   r/   r0   r1   r#  ~  s     C C C<O Cr3   c                	r   )Zattributes_r   r@   r  r7   r0   get_algorithm_attributesZ1DiscretionaryDataObjects.get_algorithm_attributes~  s$    t{7<<+=+=+?*@ABBr3   c               r   )r*   r  r   r:   r  r-   r.   r/   r0   r1   r#    s     < <w <: <r3   c                	r   )Zuif_r   r+  r7   r0   get_uifZ DiscretionaryDataObjects.get_uif  s$    ttGLL$6$6$8#9:;;r3   r-   N)
rQ   rR   rS   rT   r   rV   r8   r,  r-  rX   r-   r3   r0   r  r  U  sx    //''''''..!!%%##
 
.C< <r3   r  c                  sd    ] tR tRt$ RtR]R&   R]R&   R]R&   R	]R
&   R]R&   ]R R l4       tRtR# )ApplicationRelatedDatai  zOpenPGP related data.r   aidr,   Z
historicalzExtendedLengthInfo | NoneZextended_length_infoz!GENERAL_FEATURE_MANAGEMENT | NoneZgeneral_feature_managementr  discretionaryc               r   )r*   r+   r,   r:   r.  r-   r.   r/   r0   r1   Z#ApplicationRelatedData.__annotate__  s     
 
E 
&< 
r3   c                	sf   \         P                  ! \        P                  V4      p\         P                  ! V4      pT ! \        V\        P                  ,          4      V\        P                  ,          \        P                  V9   d+   \        P                  V\        P                  ,          4      MR \        P                  V9   d=   \        \         P                  ! ^V\        P                  ,          4      ^ ,          4      MR \        P                  V\        ,          ;'       g    T4      4      # rF   )r   r   rq   rx   r   r   r"   ru   rv   r   r8   r=   r  TAG_DISCRETIONARY)r6   r+   Zouterr   r   r0   r8   ZApplicationRelatedData.parse  s    

266@~~e$tBFF|$$$% **d2 #((b.E.E)FG 00D8 +JJtT"*G*G%HI!L  %**40A+B+K+KeL!
 	
r3   r-   N)	rQ   rR   rS   rT   r   r   rV   r8   rX   r-   r3   r0   r.  r.    s4    	O33 AA++
 
r3   r.  c                  s8    ] tR tRt$ R]R&   ]R R l4       tRtR# )SecuritySupportTemplatei  r   signature_counterc               r   )r*   r+   r,   r:   r2  r-   r.   r/   r0   r1   Z$SecuritySupportTemplate.__annotate__  s     ; ;E ;&= ;r3   c                	s    \         P                  ! \         P                  ! \        P                  V4      4      pV ! \        V\        ,          4      4      # rF   )r   r   r   rq   r   r   TAG_SIGNATURE_COUNTERr   r   r0   r8   ZSecuritySupportTemplate.parse  s7    ~~cjj)E)EwOP9T"789::r3   r-   Nr   r-   r3   r0   r2  r2    s    ; ;r3   r2  c                  s    ] tR tRt$ R]R&   ]P                  R R l4       t]]P                  R R l4       4       t	]R R	 l4       t
]P                  R
 R l4       tRtR# )Kdfi  zClassVar[int]	algorithmc               r   )r*   r   rm   pinr   r:   r,   r-   r.   r/   r0   r1   Kdf.__annotate__  s!     , ," ,3 ,5 ,r3   c                s    R# )zRun the KDF on the input PIN.Nr-   r@   r   r7  r   r0   processZKdf.process  s    r3   c               r   )r*   r   Mapping[int, bytes]r:   r5  r-   r.   r/   r0   r1   r8    s     $ $2 $s $r3   c                	r   rF   r   r6   r   r7   r0   r   ZKdf._parse_data  r   r3   c               r   )r*   r+   r,   r:   r5  r-   r.   r/   r0   r1   r8    s     	 	E 	c 	r3   c                	s   \         P                  ! V4      p \        V^,          4      pV P                  4        F'  pVP                  V8X  g   K  VP                  V4      u # 	  \        4       #   \         d     \        4       # i ; i)   )r   r   r   r   r6  r   KeyErrorKdfNone)r6   r+   r   r6  Zsub   &&   r0   r8   Z	Kdf.parse  sw    ~~g&	!$t*-I))+==I-??400 ,
 y  	y	s   3A/ A/ #A/ /BBc               r)   r9   r-   r.   r/   r0   r1   r8    r   r3   c                	r   rF   r   r?   rA   r0   rB   ZKdf.__bytes__  r   r3   r-   N)rQ   rR   rS   rT   r   r   r   r:  rV   r   r8   rB   rX   r-   r3   r0   r5  r5    sp    , , $  $ 	 	 	$ $r3   r5  c                  s<    ] tR tRt^ t]R R l4       tR tR tRt	R# )r?  i  c               r)   )r*   r:   r?  r-   r.   r/   r0   r1   ZKdfNone.__annotate__  s      ' r3   c                	s    V ! 4       # rF   r-   r<  r7   r0   r   ZKdfNone._parse_data  s	    ur3   c                	s"    VP                  4       # rF   )encoder9  r   r0   r:  ZKdfNone.process  s    zz|r3   c                	sX    \        ^\        P                  ! RV P                  4      4      # )r=  r	  )r   r;   r<   r6  r?   rA   r0   rB   ZKdfNone.__bytes__  s    4T4>>:;;r3   r-   N)
rQ   rR   rS   rT   r6  rV   r   r:  rB   rX   r-   r3   r0   r?  r?    s#    I <r3   r?  c                  s$    ] tR tRt^t^
tR tRtR# )HASH_ALGORITHMi  c                	s~    \        \        V P                  4      p\        P                  ! V! 4       \	        4       4      # rF   )r   r   rN   Hashr   )r@   r6  r   r0   create_digestZHASH_ALGORITHM.create_digest  s(    FDII.	{{9;(9::r3   r-   N)rQ   rR   rS   rT   SHA256SHA512rD  rX   r-   r3   r0   rB  rB    s    FF;r3   rB  c                  s    ] tR tRt$ ^tR]R&   R]R&   R]R&   R]R	&   R]R
&   R]R&   R]R&   ]R 4       t]]	P                  R3R R ll4       t]R R l4       tR R ltR tR tRtR# )KdfIterSaltedS2ki  rB  hash_algorithmr   iteration_countr,   	salt_userbytes | None
salt_reset
salt_admininitial_hash_userinitial_hash_adminc                	s    \        V\        V4      4      w  r4V P                  4       p\        V4       F  pVP	                  V4       K  	  VP	                  VR V 4       VP                  4       # rF   )Zdivmodr  rD  r  updatefinalize)rH  rI  r   Z
data_countZtrailing_bytesZdigest_   &&&    r0   _do_processZKdfIterSaltedS2k._do_process  s`    
 &,OSY%G"
--/z"AMM$ #d?N+,  r3   i  x c               r   )r*   rH  rB  rI  r   r:   rG  r-   r.   r/   r0   r1   KdfIterSaltedS2k.__annotate__  s(     
 
&
 
 
	
r3   c                	sB   \         P                  ! ^4      p\         P                  ! ^4      pV ! VVV\         P                  ! ^4      VV P                  WV\        P	                  4       ,           4      V P                  WV\
        P	                  4       ,           4      4      # )r   )osZurandomrT  DEFAULT_USER_PINrA  DEFAULT_ADMIN_PIN)r6   rH  rI  rJ  rM  r  r0   r   ZKdfIterSaltedS2k.create  s     JJqM	ZZ]
JJqMOO=M=T=T=V1V OO>O>V>V>X1X
 	
r3   c               r)   )r*   r:   rG  r-   r.   r/   r0   r1   rU    s     	
 	
"2 	
r3   c                	s    V ! \        \        V^,          4      4      \        V^,          4      V^,          VP                  ^4      VP                  ^4      VP                  ^4      VP                  ^4      4      # i   )rB  r   r(  r<  r7   r0   r   ZKdfIterSaltedS2k._parse_data  s_    9T$Z01d4j!JHHTNHHTNHHTNHHTN
 	
r3   c               r   )r*   r   rm   r:   r,   r-   r.   r/   r0   r1   rU  #  s     8 82 8% 8r3   c                	r   )Zsalt_r   r   r7   r0   get_saltZKdfIterSaltedS2k.get_salt#  s!    tuRWW]]_$5677r3   c                	s    V P                  V4      ;'       g    V P                  pW2P                  4       ,           pV P                  V P                  V P
                  V4      # rF   )rZ  rJ  rA  rT  rH  rI  )r@   r   r7  Zsaltr   r  r0   r:  ZKdfIterSaltedS2k.process&  sK    }}R 22DNNjjl" 3 3T5I5I4PPr3   c                	s   \        ^\        P                  ! RV P                  4      4      \        ^\        P                  ! RV P                  4      4      ,           \        ^\        P                  ! RV P
                  4      4      ,           \        ^V P                  4      ,           V P                  '       d   \        ^V P                  4      MR,           V P                  '       d   \        ^V P                  4      MR,           V P                  '       d   \        ^V P                  4      MR,           V P                  '       d   \        ^V P                  4      ,           # R,           # )r=  r	  r   r3   )r   r;   r<   r6  rH  rI  rJ  rL  rM  rN  rO  r?   rA   r0   rB   ZKdfIterSaltedS2k.__bytes__+  s   fkk$78$D$*=*=>?@$D$*>*>?@A $'( .2___s4)#	G
 .2___s4)#G 594J4J4Js4//0PSU 6:5L5L5Ls4001W		
 SVW		
r3   r-   N)rQ   rR   rS   rT   r6  r   ZstaticmethodrT  rV   rB  rE  r   r   rZ  r:  rB   rX   r-   r3   r0   rG  rG    s    I""##$$	! 	!  *8)>)>'
 
* 	
 	
8Q


r3   rG  c                  s:    ] tR tRt$ R]R&   R R ltR R ltRtR	# )
PrivateKeyTemplatei9  r   r   c               r)   )r*   r:   z	list[Tlv]r-   r.   r/   r0   r1   PrivateKeyTemplate.__annotate__=  s     $ $y $r3   c                	r   rF   r   r?   rA   r0   _get_templateZ PrivateKeyTemplate._get_template=  s    !##r3   c               r)   r9   r-   r.   r/   r0   r1   r\  @  s     
 
5 
r3   c                	s    V P                  4       p\        ^MV P                  \        RRP                  R V 4       4      4      ,           \        RRP                  R V 4       4      4      ,           4      # )iM   iH  r3   c              3  s@   "   T F  qR VP                   )  x  K  	  R # 5irF   )length.0tlvr   r0   	<genexpr>/PrivateKeyTemplate.__bytes__.<locals>.<genexpr>E  s     "F#}#**#5s   iH_  c              3  s8   "   T F  qP                   x  K  	  R # 5irF   r   r_  r   r0   rb  rc  F  s     "=99   )r]  r   r   Zjoinr@   Ztlvsr   r0   rB   ZPrivateKeyTemplate.__bytes__@  sd    !!#HH&#(("F"FFGH&#(("="==>?
 	
r3   r-   N)rQ   rR   rS   rT   r   r]  rB   rX   r-   r3   r0   r[  r[  9  s    	H$
 
r3   r[  c                  s<    ] tR tRt$ R]R&   R]R&   R]R&   R tRtR# )	RsaKeyTemplateiJ  r,   r   pqc                	s    \        ^V P                  4      \        ^V P                  4      \        ^V P                  4      .# )i   )r   r   rg  rh  r?   rA   r0   r]  ZRsaKeyTemplate._get_templateP  s6    dffdffdff
 	
r3   r-   NrQ   rR   rS   rT   r   r]  rX   r-   r3   r0   rf  rf  J  s    HHH
r3   rf  c                  sR   a  ] tR tRt$ R]R&   R]R&   R]R&   R]R&   V 3R ltRtV ;t# )	RsaCrtKeyTemplateiX  r,   iqmpdmp1dmq1r   c                	s   < . \         SV `  4       O\        ^V P                  4      N\        ^V P                  4      N\        ^V P
                  4      N\        ^V P                  4      N# )i   )Zsuperr]  r   rk  rl  rm  r   )r@   	__class__s   &r0   r]  ZRsaCrtKeyTemplate._get_template_  so    
W"$
dii 
 dii 
 dii 	

 dff
 	
r3   r-   )rQ   rR   rS   rT   r   r]  rX   Z__classcell__)rn     @r0   rj  rj  X  s!    
K
K
KH
 
r3   rj  c                  s2    ] tR tRt$ R]R&   R]R&   R tRtR# )	EcKeyTemplateii  r,   r   rK  
public_keyc                	s    \        ^V P                  4      .pV P                  '       d&   VP                  \        ^V P                  4      4       V# )i   )r   r   rq  appendre  r   r0   r]  ZEcKeyTemplate._get_templaten  s<    D$**+,???KKD$//23r3   r-   Nri  r-   r3   r0   rp  rp  i  s    r3   rp  c               (    V ^8  d   QhRRRRRRRR/# )	r*   r   r   r  r   r   r   r:   r   r-   r.   r/   r0   r1   r1   v  s2     D DD&-D8?DDr3   c                s   \        V \        P                  4      '       d   V P                  4       P                  P
                  R 8w  d   \        R4      h\        P                  \        V P                  4      ^ V^ ,          u;8  d   ^8  d   M M\        P                  4      # \        P                  4      # \        P                  V\        P!                  V 4      4      # )  z+RSA keys with e != 65537 are not supported!)r   r   RSAPrivateKeyWithSerializationprivate_numberspublic_numbersr   r   r   r   r   key_sizer   r   r   r  r   r   )r   r  r   r   r0   _get_key_attributesry  v  s     +sAABB&&(7799UBJKK##[))* wqz%A% "++
 	

 '//
 	
 wk(BCCr3   c               rs  )	r*   r   r   r  r   use_crtrD   r:   r[  r-   r.   r/   r0   r1   r1     s,     "- "-"-&-"-8<"-"-r3   c           
     sz   \        V \        P                  4      '       d   V P                  4       pV P                  ^,          ^,          pRp\        VP                  V4      p\        VP                  V4      pV'       g   \        VP                  WVV4      # \        VP                  V4      p\        VP                  V4      p	\        VP                  V4      p
\        VP                  P                  ^V,          4      p\        VP                  WVWzWV4      # \        V \         P"                  4      '       dO   V P                  4       pV P                  ^,          p\%        VP                  \        VP&                  V4      R4      # \        V \(        P*                  \,        P.                  34      '       d{   V P1                  \2        P4                  \6        P4                  \9        4       4      p\        V \,        P.                  4      '       d   VRRR1,          p\%        VP                  VR4      # \;        R4      h)r   s    NzUnsupported key typer  )r   r   ru  rv  rx  r    rg  rh  rf  r   rl  rm  rk  rw  r   rj  r   (EllipticCurvePrivateKeyWithSerializationrp  Zprivate_valuer   r   r   r   Zprivate_bytesr   Rawr   r   r   )r   r  rz  Zrsa_numberslnr   rg  rh  ZdpZdqZqinvr   Z
ec_numbersZpkbs   &&&           r0   _get_key_templater~    s    +sAABB!113""a'A-kmmR(kmmR(!'++qQ77;++R0B;++R0B[--r2D+4466B?A$W[[!KK	K!L!L	M	M 002
!!Q&W[[)J4L4Lb*QSWXX	K'";";V=T=T!U	V	V''m6G6GXk6#:#:;;dd)CKK
 	
 +
,,r3   c               r   )r*   r   r;  r:   rsa.RSAPublicKeyr-   r.   r/   r0   r1   r1     s     1 1, 11A 1r3   c                s    \         P                  ! \        V ^,          4      \        V ^,          4      4      pVP                  \	        4       4      # rY  )r   ZRSAPublicNumbersr   rq  r   )r   Znumbersr   r0   _parse_rsa_keyr    s:    ""9T$Z#8)DJ:OPGo/00r3   c               r   )r*   r   r   r   r;  r:   r   r-   r.   r/   r0   r1   r1     s'     M Mx M': M{ Mr3   c                sj   V^,          pV \         P                  8X  d    \        P                  P	                  V4      # V \         P
                  8X  d    \        P                  P	                  V4      # \        \        V P                  4       4      p\        P                  P                  V! 4       V4      # )i   )r   r   r   X25519PublicKeyZfrom_public_bytesr   r   Ed25519PublicKeyr   r   r   EllipticCurvePublicKeyZfrom_encoded_point)r   r   Z
pubkey_encr   r   r0   _parse_ec_keyr    s~    dJ
cjj%%77
CC
ckk''99*EEB(E$$77LLr3   Z$3020300C06082A864886F70D020505000410Z3021300906052B0E03021A05000414Z&302D300D06096086480165030402040500041CZ&3031300D060960864801650304020105000420Z&3041300D060960864801650304020205000430Z&3051300D060960864801650304020305000440Z&302D300D06096086480165030402050500041CZ&3031300D060960864801650304020605000420c                s   V P                   ^8X  d   V# \        V\        4      '       d   TpM@\        P                  ! V\        4       4      pVP                  V4       VP                  4       p\        V \        4      '       d   V# \        V \        4      '       d    \        \        V4      ,          V,           # \        RV  24      h  \         d    \        RT 24      hi ; i)r  z$Unsupported hash algorithm for RSA: z"Unsupported algorithm attributes: )r   r   r   r   rC  r   rP  rQ  r  r   _pkcs1v15_headerstyper>  r   )
attributesmessagerH  ZhashedZhr  r0   _pad_messager    s    $&.),,KK(9:	*l++	J	.	.	V$T.%9:VCC =j\JKK  	VCNCSTUU	Vs   C C!c                  s   ] tR tRtRtRfR R lltR R lt]R R	 l4       t]R
 R l4       t	]R R l4       t
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$ R% ltRgR& R' lltRhR( R) lltR* tR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltRfR5 R6 lltR7 R8 lt R9 R: lt!R; R< lt"R= R> lt#R? R@ lt$RA RB lt%RC RD lt&RE RF lt'RG RH lt(RI RJ lt)RK RL lt*RM RN lt+RO RP lt,RQ RR lt-RS RT lt.RU RV lt/RW RX lt0RY RZ lt1R[ R\ lt2R] R^ lt3R_ R` lt4Ra Rb lt5Rc Rd lt6Ret7R# )iOpenPgpSessioni  z'A session with the OpenPGP application.Nc               r   )r*   
connectionr&   scp_key_paramszScpKeyParams | Noner-   r.   r/   r0   r1   OpenPgpSession.__annotate__  s"     N N'N ,Nr3   c                	s
   \        V4      V n         V P                  P                  \        P                  4       T'       d   T P                  P                  T4       T P!                  4       T n        T P                  P%                  T P&                  4       T P)                  4       T n        \        P-                  RT P&                   R24       R#   \
         d   pTP                  \        P                  \        P                  39   dq   \        P                  R 4       T P                  P                  ^ \        P                  ^ ^ 4       T P                  P                  \        P                  4        Rp?ELAh Rp?ii ; i)z(Application not active, sending ACTIVATENz%OpenPGP session initialized (version=r   )r'   protocolZselectr"   ZOPENPGPr$   swr#   ZNO_INPUT_DATACONDITIONS_NOT_SATISFIEDloggerZwarning	send_apdur[   r`   Zinit_scp_read_version_versionZ	configurer   get_application_related_data	_app_datadebug)r@   r  r  r   r  r0   __init__ZOpenPgpSession.__init__  s   
 **5		MM  - MM"">2**,- ::<<T\\N!LM'  	tt(("*E*EFFIJ''3<<A>$$S[[11	s   )C FBE=<E==Fc               r)   r*   r:   r   r-   r.   r/   r0   r1   r    s     	 	w 	r3   c                	sX   \         P                  R 4        V P                  P                  ^ \        P
                  ^ ^ 4      p\        P                  ! \        R V 4       !  4      #   \         d8   pTP                  \        P                  8X  d   \        ^^ ^ 4      u Rp?# h Rp?ii ; i)zGetting version numberc              3  s8   "   T F  p\        V4      x  K  	  R # 5irF   r   )r`  Zxr   r0   rb  Z/OpenPgpSession._read_version.<locals>.<genexpr>  s     4JcT!WWcrd  N)r  r  r  r  r[   ri   r   Zpatchr   r$   r  r#   r  )r@   Zbcdr   s   &  r0   r  ZOpenPgpSession._read_version  s    -.	--))!S__aCC$**74Jc4J+KLL 	ttr222q!Q''		s$   AA' 'B)2+B$B)#B$$B)c               r)   )r*   r:   r   r-   r.   r/   r0   r1   r  
  s     " "Z "r3   c                s.    V P                   P                  # )z&Get the AID used to select the applet.)r  r/  r?   rA   r0   r/  ZOpenPgpSession.aid	  s     ~~!!!r3   c               r)   r  r-   r.   r/   r0   r1   r    s       r3   c                s    V P                   # )zVGet the firmware version of the key.

For YubiKey NEO this is the PGP applet version.
)r  r?   rA   r0   r   ZOpenPgpSession.version  s     }}r3   c               r)   )r*   r:   r   r-   r.   r/   r0   r1   r    s     B B'; Br3   c                sB    V P                   P                  P                  # )z/Get the Extended Capabilities from the YubiKey.)r  r0  r  r?   rA   r0   r  Z$OpenPgpSession.extended_capabilities  s     ~~++AAAr3   c               r   )r*   r^  r   r:   r,   r-   r.   r/   r0   r1   r    s     N NC NE Nr3   c                sH   V P                   p\        P                  VP                  9  d   \	        R4      h^ Tu;8  d   VP
                  8:  g   M \	        R4      h\        P                  RV R24       V P                  P                  ^ \        P                  ^ ^ VR7      # )zOGet random data from the YubiKey.

:param length: Length of the returned data.
zGET_CHALLENGE is not supportedzUnsupported challenge lengthzGetting z random bytes)Zle)r  r   rb   r   r   r   r  r  r  r  r[   )r@   r^  r   r   r0   get_challengeZOpenPgpSession.get_challenge  s    
 &&$22!''A#$DEE63Q333#$BCCxx}56}}&&q#*;*;Qf&MMr3   c               r   )r*   dorq   r:   r,   r-   r.   r/   r0   r1   r  )  s     L L2 L% Lr3   c                s    \         P                  RVP                   RVR R24       V P                  P	                  ^ \
        P                  V^,	          V^,          4      # )zHGet a Data Object from the YubiKey.

:param do: The Data Object to get.
zReading Data Object  (Xr   )r  r  rN   r  r  r[   re   )r@   r  r7   r0   get_dataZOpenPgpSession.get_data)  sM    
 	+BGG9Br!fA>?}}&&q#,,adKKr3   c               r   )r*   r  rq   r   zbytes | SupportsBytesr:   Noner-   r.   r/   r0   r1   r  1  s"     = =2 =%: =t =r3   c           	     s    V P                   P                  ^ \        P                  V^,	          V^,          \	        V4      4       \
        P                  RVP                   RVR R24       R# )zmWrite a Data Object to the YubiKey.

:param do: The Data Object to write to.
:param data: The data to write.
zWrote Data Object r  r  r   N)r  r  r[   rf   r,   r  inforN   )r@   r  r   r   r0   put_dataZOpenPgpSession.put_data1  sP     	3<<q"t)U4[Q(	Bq6;<r3   c               r)   )r*   r:   r   r-   r.   r/   r0   r1   r  :  s     A A Ar3   c                sf    \         P                  V P                  \        P                  4      4      # )zGet the current status of PINS.)r   r8   r  rq   r}   r?   rA   r0   get_pin_statusZOpenPgpSession.get_pin_status:  s     ~~dmmB,>,>?@@r3   c               r)   r   r-   r.   r/   r0   r1   r  >  s     # #s #r3   c                s~    \         P                  V P                  \        P                  4      4      pVP
                  # )z8Get the number of times the signature key has been used.)r2  r8   r  rq   r   r3  )r@   Zsr   r0   get_signature_counterZ$OpenPgpSession.get_signature_counter>  s-    #))$--8T8T*UV"""r3   c               r)   )r*   r:   r.  r-   r.   r/   r0   r1   r  C  s      .D r3   c                s   \         P                  V P                  \        P                  4      4      pVP
                  P                  R8  d   V P                  \        P                  4      VP                  n        V P                  \        P                  4      VP                  n        V P                  \        P                  4      VP                  n        V# )z"Read the Application Related Data.)   r    )r.  r8   r  rq   rx   r/  r   r-  r   r   r0  r   r   r!  r   r"  )r@   r   r   r0   r  Z+OpenPgpSession.get_application_related_dataC  s    %++DMM":U:U,VW88f$)-gkk)BD&)-gkk)BD&)-gkk)BD&r3   c               r   )r*   
pin_policyrY   r:   r  r-   r.   r/   r0   r1   r  M  s     
0 
0: 
0$ 
0r3   c                s    \         P                  RV 24       \        P                  ! RV4      pV P	                  \
        P                  V4       \         P                  R4       R# )z`Set signature PIN policy.

Requires Admin PIN verification.

:param pin_policy: The PIN policy.
z Setting Signature PIN policy to r	  zSignature PIN policy setN)r  r  r;   r<   r  rq   r}   r  )r@   r  r   r   r0   set_signature_pin_policyZ'OpenPgpSession.set_signature_pin_policyM  sI     	7
|DE{{4,b(($/./r3   c               r)   )r*   r:   r  r-   r.   r/   r0   r1   r  Y  s     @ @t @r3   c           	     s   \        V P                  R4       \        P                  R4       V P	                  4       p\
        P                  \
        P                  3 Fy  p\        P                  RVP                   R24       \        VP                  V4      4       F5  p V P                  P                  ^ \        P                  ^ V\        4       K7  	  K{  	  \        P                  R4       V P                  P                  ^ \        P"                  ^ ^ 4       V P                  P                  ^ \        P$                  ^ ^ 4       \        P'                  R4       R#   \          d     K  i ; i)z}Perform a factory reset on the OpenPGP application.

WARNING: This will delete all stored keys, certificates and other data.
zPreparing OpenPGP resetzVerify z( PIN with invalid attempts until blockedz Sending TERMINATE, then ACTIVATEz(OpenPGP application data reset performedN)rM   r    r   )r!   r   r  r  r  rm   rn   rp   rN   r  r   r  r  r[   r\   _INVALID_PINr$   rh   r`   r  )r@   Zstatusr   rR  r  r0   resetZOpenPgpSession.resetY  s   
 	i0./ $$&77BHH%BLL7277)+STU6..r23MM++Aszz1b,O 4 & 	783==!Q73<<A6>? ! s    1EE,+E,c               s(    V ^8  d   QhRRRRRRRR/# )r*   user_attemptsr   reset_attemptsadmin_attemptsr:   r  r-   r.   r/   r0   r1   r  r  s,     ? ? ?25?GJ?	?r3   c           
     sx   V P                   ^ ,          ^8X  d   \        V P                   R4       M\        V P                   R4       WV3p\        P                  RV 24       V P                  P                  ^ \        P                  ^ ^ \        P                  ! R.VO5!  4       \        P                  R4       R# )a3  Set the number of PIN attempts to allow before blocking.

WARNING: On YubiKey NEO this will reset the PINs to their default values.

Requires Admin PIN verification.

:param user_attempts: The User PIN attempts.
:param reset_attempts: The Reset Code attempts.
:param admin_attempts: The Admin PIN attempts.
zSetting PIN attempts to z>BBBz'Number of PIN attempts has been changedN)rM   r    i   )r   r  rM   )r   r!   r  r  r  r  r[   rj   r;   r<   r  )r@   r  r  r  attemptss   &&&& r0   set_pin_attemptsZOpenPgpSession.set_pin_attemptsr  s     <<?aDLL)4DLL)4!>B/z:;KK**	
 	=>r3   c               r)   )r*   r:   r5  r-   r.   r/   r0   r1   r    s       r3   c                s(   \         P                  V P                  P                  9  d   \	        4       pM2\
        P                  V P                  \        P                  4      4      p\        P                  R\        V4      P                   24       V# )z,Get the Key Derivation Function data object.zUsing KDF: )r   r   r  r   r?  r5  r8   r  rq   r  r  r  rQ   )r@   kdfr   r0   get_kdfZOpenPgpSession.get_kdf  sa    $((0J0J0P0PPyC))DMM"&&12C{49#5#5"678
r3   c               r   )r*   r  r5  r:   r  r-   r.   r/   r0   r1   r    s     , ,3 ,4 ,r3   c                sH   V P                   P                  P                  p\        P                  VP
                  9  d   \        R4      h\        P                  RVP                   24       V P                  \        P                  V4       \        P                  R4       R# )aG  Set up a PIN Key Derivation Function.

This enables (or disables) the use of a KDF for PIN verification, as well
as resetting the User and Admin PINs to their default (initial) values.

If a Reset Code is present, it will be invalidated.

This command requires Admin PIN verification.

:param kdf: The key derivation function.
zKDF is not supportedzSetting PIN KDF to algorithm: zKDF settings changedN)r  r0  r  r   r   r   r   r  r  r6  r  rq   r  )r@   r  r   r   r0   set_kdfZOpenPgpSession.set_kdf  sn     NN((>>$((7#$:;;5cmm_EFbffc"*+r3   c               rs  )	r*   r  r5  r   rm   r7  r   r:   r,   r-   r.   r/   r0   r1   r    s(     	 	 	 	# 	% 	r3   c                	s&   VP                  W#4      p\        V4      pV\        P                  J d   ^M^pV P                  P
                  P                  P                  V4      pYeu;8:  d   V8:  g    M \        VP                   RV RV 24      hV# )r   z! PIN length must be in the range Z-)
r:  r  rm   rn   r  r0  r  r   r   rN   )r@   r  r   r7  Z	pin_bytesZpin_lenZmin_lenZmax_lens   &&&&    r0   _process_pinZOpenPgpSession._process_pin  s    KK(	i.RWW}!!....88DDRH-g-77)<WIQwiP  r3   c               rs  )	r*   r   rm   r7  r   moder   r:   r  r-   r.   r/   r0   r1   r    s(      " 3 c $ r3   c                	s,   V P                  V P                  4       W4      p V P                  P                  ^ \        P
                  ^ W,           V4       R#   \         d   pTP                  \        P                  8X  g*   TP                  ^,	          ^c8X  d<   T P                  R8  d+   T P                  4       P                  T4      p\        T4      hTP                  \        P                  8X  d   \        ^ TP                   R24      hThRp?ii ; i)r     PIN blockedNr   r    r    )r  r  r  r  r[   r\   r$   r  r#    SECURITY_CONDITION_NOT_SATISFIEDr  r  r   r   AUTH_METHOD_BLOCKEDrN   )r@   r   r7  r  Zpin_encr   r     &&&&   r0   _verifyZOpenPgpSession._verify  s    ##DLLNB<	MM##Aszz1biI 		ttr:::t#	(A..0==bA%h//ttr---%aBGG9L)ABBG		s   3A D"B,DDc               r)   )r*   extendedrD   r-   r.   r/   r0   r1   r    s     9 9 9r3   c                s    \         P                  RV'       d   RMR 24       T P                  \        P                  Y'       d	   ^4       R# ^ 4       R# )ao  Verify the User PIN.

This will unlock functionality that requires User PIN verification.
Note that with `extended=False` (default) only sign operations are allowed.
Inversely, with `extended=True` sign operations are NOT allowed.

:param pin: The User PIN.
:param extended: If `False` only sign operations are allowed,
    otherwise sign operations are NOT allowed.
zVerifying User PIN in mode Z82Z81N)r  r  r  rm   rn   )r@   r7  r  r   r0   
verify_pinZOpenPgpSession.verify_pin  s8     	2842NOPRWWc18a8r3   c                sp    \         P                  R4       V P                  \        P                  V4       R# )z~Verify the Admin PIN.

This will unlock functionality that requires Admin PIN verification.

:param admin_pin: The Admin PIN.
zVerifying Admin PINN)r  r  r  rm   rp   )r@   	admin_pinr7   r0   verify_adminZOpenPgpSession.verify_admin  s#     	*+RXXy)r3   c               r   )r*   r   rm   r:   r  r-   r.   r/   r0   r1   r    s     9 9r 9d 9r3   c                s    \        V P                  R4       \        P                  RVP                   R24       V P
                  P                  ^ \        P                  ^V4       R# )zEReset verification for PIN.

:param pw: The User, Admin or Reset PIN
zResetting verification for  PINN)   r   r    )	r!   r   r  r  rN   r  r  r[   r\   r   r7   r0   unverify_pinZOpenPgpSession.unverify_pin  sH    
 	i02277)4@A3::tR8r3   c               s(    V ^8  d   QhRRRRRRRR/# )r*   r   rm   r7  r   new_pinr:   r  r-   r.   r/   r0   r1   r    s(     . ." .3 . . .r3   c                	s   \         P                  R VP                   R24       V P                  4       p V P                  P                  ^ \        P                  ^ VV P                  WAV4      V P                  WAV4      ,           4       \         P'                  RTP                   R24       R#   \         d   pTP                  \        P                  8X  g1   TP                  \        P                  8X  d<   T P                  R8  d+   T P                  4       P!                  T4      p\#        T4      hTP                  \        P$                  8X  d   \#        ^ TP                   R24      hThRp?ii ; i)z	Changing r  r  NzNew z PIN setr  )r  r  rN   r  r  r  r[   r]   r  r$   r  r#   r  r  r  r  r   r   r  r  )r@   r   r7  r  r  r   r  r  r0   _changeZOpenPgpSession._change  s   y	./lln	MM##!!#3/$2C2CCW2UU$ 	d277)8,-  		ttr:::333	8Q..0==bA%h//ttr---%aBGG9L)ABBG		s   AB. .E19B3E,,E1c               $    V ^8  d   QhRRRRRR/# )r*   r7  r   r  r:   r  r-   r.   r/   r0   r1   r     s!     , ,c ,C ,D ,r3   c                F    V P                  \        P                  W4       R# )zZChange the User PIN.

:param pin: The current User PIN.
:param new_pin: The new User PIN.
N)r  rm   rn   )r@   r7  r  r   r0   
change_pinZOpenPgpSession.change_pin   s     	RWWc+r3   c               r  )r*   r  r   new_admin_pinr:   r  r-   r.   r/   r0   r1   r    s!     9 9c 9# 9$ 9r3   c                r  )ziChange the Admin PIN.

:param admin_pin: The current Admin PIN.
:param new_admin_pin: The new Admin PIN.
N)r  rm   rp   )r@   r  r  r   r0   change_adminZOpenPgpSession.change_admin  s     	RXXy8r3   c               r   )r*   
reset_coder   r:   r  r-   r.   r/   r0   r1   r    s     3 3 3 3r3   c                s    \         P                  R4       V P                  V P                  4       \        P
                  V4      pV P                  \        P                  V4       \         P                  R4       R# )zSet the Reset Code for User PIN.

The Reset Code can be used to set a new User PIN if it is lost or becomes
blocked, using the reset_pin method.

This command requires Admin PIN verification.

:param reset_code: The Reset Code for User PIN.
zSetting a new PIN Reset CodezNew Reset Code has been setN)
r  r  r  r  rm   ro   r  rq   r~   r  )r@   r  r   r   r0   set_reset_codeZOpenPgpSession.set_reset_code  sP     	34  :Fb''.12r3   c               r   )r*   r  r   r  z
str | Noner:   r  r-   r.   r/   r0   r1   r    s!     1 1 1* 1 1r3   c                s
   \         P                  R4       V P                  4       pV P                  V\        P
                  V4      pV'       dA   \         P                  R4       V P                  V\        P                  V4      V,           p^ pM^p V P                  P                  ^ \        P                  V\        P
                  V4       \         P)                  R4       R#   \         d   pT'       d   TP                  \        P                  8X  d+   T P                  4       P                   p\#        TRT R24      hTP                  \        P$                  \        P&                  39   d   \#        ^ R4      hThRp?ii ; i)zReset the User PIN to a new value.

This command requires Admin PIN verification, or the Reset Code.

:param new_pin: The new user PIN.
:param reset_code: The Reset Code.
zResetting User PINzUsing Reset CodezInvalid Reset Code, z
 remainingzReset Code blockedNzNew User PIN has been set)r  r  r  r  rm   rn   ro   r  r  r[   r^   r$   r  r#   r  r  r   r   r  ZINCORRECT_PARAMETERSr  )r@   r  r  r  r   Zp1r   r  s   &&&     r0   	reset_pinZOpenPgpSession.reset_pin  s,    	)*lln  bggw7LL+,$$S"((J?$FDBB	MM##As'>'>BGGTR 	/0  		442>>>#224CCH) $8
*"M  44B22B4K4KLL)!-ABBG		s   ;C$ $F/BE==Fc               r   r*  r-   r.   r/   r0   r1   r  ?  s     D D D<O Dr3   c                s    \         P                  RVP                   24       V P                  4       pVP                  P                  V4      # )zVGet the algorithm attributes for one of the key slots.

:param key_ref: The key slot.
z!Getting Algorithm Attributes for )r  r  rN   r  r0  r,  r@   r  r   r   r0   r,  Z'OpenPgpSession.get_algorithm_attributes?  sA    
 	8GH002!!::7CCr3   c               r)   )r*   r:   z/Mapping[KEY_REF, Sequence[AlgorithmAttributes]]r-   r.   r/   r0   r1   r  H  s     9 9	89r3   c                sr   \         P                  V P                  P                  9  d   \	        R4      hV P
                  R8  EdQ   V P
                  ^ ,          ^ 8  Ed8   \        P                  .p^ V P
                  ^ ,          u;8  d   ^8  d   M M\        P                  pMW\        P                  pV P
                  R,          R8w  d0   VP                  \        P                  \        P                  .4       \        P                  V Uu. uF  p\         P#                  W24      NK  	  up\        P$                  V Uu. uF  p\         P#                  W24      NK  	  up\        P&                  V Uu. uF  p\         P#                  W24      NK  	  up/# \(        P+                  R4       V P-                  \.        P0                  4      p \2        P4                  ! \.        P0                  V4      p\         Uu/ uF  qUP8                  VbK  	  pp/ p\2        P:                  ! V4       F[  pVP=                  V\/        VP>                  4      ,          . 4      PA                  \B        PE                  VPF                  4      4       K]  	  V P
                  R	8  EdJ   V P
                  ^ ,          ^ 8  Ed1   \I        ^\J        PL                  \N        P                  4      p	VPQ                  4        F  p
V
PS                  V	4       K  	  \I        ^\J        PL                  \N        P                  4      pW\        P$                  ,          9  d'   V\        P$                  ,          PA                  V4       \I        ^\J        PT                  \N        P                  4      pV\        P$                  ,          PS                  V4       V\        PV                  ,          PS                  V4       V# u upi u upi u upi   \6         d4    \2        P4                  ! \.        P0                  TR,           4      RR p EL?i ; iu upi )
zGet the list of supported algorithm attributes for each key.

The return value is a mapping of KEY_REF to a list of supported algorithm
attributes, which can be set using set_algorithm_attributes.
z-Writing Algorithm Attributes is not supported:Nr*   Nz'Getting supported Algorithm Informations     Nr  r*   r    )r   r   i)r  r   rM   ),r   r   r  r   r   r   r   r   r   r   r   Zextendr   r   r   r   r   r   r   r   r  r  r  rq   r   r   r   r   r   r   Z
setdefaultZtagrr  r   r8   r   r  r   r   r   valuesZremover   r   )r@   ZsizesZfmtZsizer
  Zslotr  r   ra  Zinvalid_x25519r  r   Zed25519_attrs   &            r0   get_algorithm_informationZ(OpenPgpSession.get_algorithm_informationH  s    &EE--334 $$STT<<)#Q!(;%%&E4<<?&Q&'11'00<<#v-LL("2"2H4D4D!EF%P%$m224=%P%P%$m224=%P%P%$m224=%P  	>?mmB445	K**R55s;C AHH--t3H9;>>#&COOE"SWW+.3::#))#))4 '
 <<)#Q!(; *$

<L<U<UVN++-n- (!$

4D4M4MNF'++..W[[!((0'ckk;K;T;TUL$$\2$$\2E QPP  	K**R55sW}EcrJC	K Is*   O$O)
5O.%O3 9P43:P10P1c               r   )r*   r  r   r  r   r:   r  r-   r.   r/   r0   r1   r    s$     > >>,?>	>r3   c                sN   \         P                  RVP                   24       V P                  4       pV P                  ^ ,          ^ 8  d*   W9  d   \        R4      hW#V,          9  d   \        R4      hV P                  VP                  V4       \         P                  R4       R# )a  Set the algorithm attributes for a key slot.

WARNING: This will delete any key already stored in the slot if the attributes
are changed!

This command requires Admin PIN verification.

:param key_ref: The key slot.
:param attributes: The algorithm attributes to set.
z!Setting Algorithm Attributes for zKey slot not supported"Algorithm attributes not supportedz&Algorithm Attributes have been changedN)	r  r  rN   r  r   r   r  r   r  )r@   r  r  Z	supportedr  r0   set_algorithm_attributesZ'OpenPgpSession.set_algorithm_attributes  s     	8GH224	<<?Q''(@AA7!33'(LMMg55zB<=r3   c               r   )r*   r  r   r:   r(   r-   r.   r/   r0   r1   r    s     	 	w 	3 	r3   c                s    V P                   R8  d/   \        P                  V P                  VP                  4      4      # \        P
                  # )z\Get the User Interaction Flag (touch requirement) for a key.

:param key_ref: The key slot.
r   r*   r    )r   r(   r8   r  r   rU   r+  r7   r0   r-  ZOpenPgpSession.get_uif  s7    
 <<9$99T]]7>>:;; wwr3   c               r   )r*   r  r   uifr(   r:   r  r-   r.   r/   r0   r1   r    s!     7 7w 7S 7T 7r3   c                s   \        V P                  R4       V\        P                  8X  d   \        V P                  R	R4       VP                  '       d   \        V P                  R	R4       \
        P                  RVP                   RVP                   24       V P                  V4      P                  '       d   \        R4      hV P                  VP                  V4       \
        P                  RVP                   24       R# )
zSet the User Interaction Flag (touch requirement) for a key.

Requires Admin PIN verification.

:param key_ref: The key slot.
:param uif: The User Interaction Flag.
z0Attestation key requires YubiKey 5.2.1 or later.z1Cached UIF values require YubiKey 5.2.1 or later.zSetting UIF for z to z$Cannot change UIF when set to FIXED.zUIF changed for Nr  )r  r*   rM   )r!   r   r   r   rK   r  r  rN   r-  rI   r   r  r   r  )r@   r  r  r   r0   set_uifZOpenPgpSession.set_uif  s     	i0gkk!B
 ===C 	'~T#((DE<< )))CDDgnnc*&w||n56r3   c               r)   )r*   r:   r  r-   r.   r/   r0   r1   r    s     Q Q^ Qr3   c                t    \         P                  R4       V P                  4       P                  P                  # )zGet the status of the keys.zGetting Key Information)r  r  r  r0  r  r?   rA   r0   get_key_informationZ"OpenPgpSession.get_key_information  s*    ./002@@PPPr3   c               r)   )r*   r:   r  r-   r.   r/   r0   r1   r    s     R Ro Rr3   c                r  )z,Get timestamps for when keys were generated.z!Getting key generation timestamps)r  r  r  r0  r  r?   rA   r0   get_generation_timesZ#OpenPgpSession.get_generation_times  s*    89002@@QQQr3   c               r   )r*   r  r   	timestampr   r:   r  r-   r.   r/   r0   r1   r    s&     
H 
H7 
Hs 
Ht 
Hr3   c                s    \         P                  RVP                   24       V P                  VP                  \
        P                  ! RV4      4       \         P                  RVP                   24       R# )zSet the generation timestamp for a key.

Requires Admin PIN verification.

:param key_ref: The key slot.
:param timestamp: The timestamp.
z%Setting key generation timestamp for r   z!Key generation timestamp set for N)r  r  rN   r  r   r;   r<   r  )r@   r  r  r   r0   set_generation_timeZ"OpenPgpSession.set_generation_time  sS     	<W\\NKLg00&++dI2NO7~FGr3   c               r)   )r*   r:   r  r-   r.   r/   r0   r1   r    s     N N, Nr3   c                r  )zGet key fingerprints.zGetting key fingerprints)r  r  r  r0  r  r?   rA   r0   get_fingerprintsZOpenPgpSession.get_fingerprints  s*    /0002@@MMMr3   c               r   )r*   r  r   fingerprintr,   r:   r  r-   r.   r/   r0   r1   r    s!     
> 
>w 
>U 
>t 
>r3   c                s    \         P                  RVP                   24       V P                  VP                  V4       \         P                  R4       R# )zSet the fingerprint for a key.

Requires Admin PIN verification.

:param key_ref: The key slot.
:param fingerprint: The fingerprint.
zSetting key fingerprint for z&Key fingerprint set for {key_ref.name}N)r  r  rN   r  r   r  )r@   r  r  r   r0   set_fingerprintZOpenPgpSession.set_fingerprint  s=     	3GLL>BCg,,k:<=r3   c               r   )r*   r  r   r:   r   r-   r.   r/   r0   r1   r    s     ( (g () (r3   c                s   \         P                  RVP                   24       V P                  P	                  ^ \
        P                  ^^ VP                  4      p\        P                  ! \        P                  ! \        V4      4      pV P                  V4      p\        V\        4      '       d   \        VP                   V4      # \#        V4      # )z?Get the public key from a slot.

:param key_ref: The key slot.
zGetting public key for )r  r  rN   r  r  r[   ra   r   r   r   r   TAG_PUBLIC_KEYr,  r   r  r  r   r  )r@   r  respr   r  r@  r0   get_public_keyZOpenPgpSession.get_public_key  s    
 	.w||n=>}}&&q#*;*;T4U~~cjj>?227;
j,// 66!$''r3   c               r   )r*   r  r   rx  r   r:   r  r-   r.   r/   r0   r1   r    s$     $ $$*2$	$r3   c                s    RV P                   u;8:  d   R8  d   M M\        R4      h\        P                  RVP                   24       \
        P                  V P                  P                  9   dk   ^ V P                   ^ ,          u;8  d   ^8  d   M M\        P                  M\        P                  p\        P                  W#4      pV P                  W4       M V\        P                   8w  d   \        R4      hV P"                  P%                  ^ \&        P(                  ^^ VP*                  4      p\,        P.                  ! \,        P0                  ! \2        V4      4      p\        P5                  RVP                   24       \7        V4      # )zGenerate an RSA key in the given slot.

Requires Admin PIN verification.

:param key_ref: The key slot.
:param key_size: The size of the RSA key.
z0RSA key generation not supported on this YubiKeyzGenerating RSA private key for r  zRSA key generated for r  )r   r  r  )r   r   r  r  rN   r   r   r  r   r   r   r   r   r   r  r   r   r  r  r[   ra   r   r   r   r   r  r  r  )r@   r  rx  r   r  r  r   rS  r0   generate_rsa_keyZOpenPgpSession.generate_rsa_key  s"    0y0#$VWW6w||nEF%EE))//0
 t||A** "++&// 
 '--hFJ))'>)))#$HII}}&&q#*;*;T4U~~cjj>?,W\\N;<d##r3   c               r   )r*   r  r   	curve_oidr   r:   r   r-   r.   r/   r0   r1   r    s!     . .w .8 . .r3   c                s   \        V P                  R4       V\        9  d   \        R4      h\        P                  RVP                   24       \        P                  W4      pV P                  W4       V P                  P                  ^ \        P                  ^^ VP                  4      p\        P                   ! \        P"                  ! \$        V4      4      p\        P'                  RVP                   24       \)        W%4      # )zGenerate an EC key in the given slot.

Requires Admin PIN verification.

:param key_ref: The key slot.
:param curve_oid: The curve OID.
zCurve OID is not recognizedzGenerating EC private key for zEC key generated for r  )r!   r   r   r   r  r  rN   r  r   r  r  r  r[   ra   r   r   r   r   r  r  r  )r@   r  r  r  r  r   r   r0   generate_ec_keyZOpenPgpSession.generate_ec_key  s     	i0C:;;5gll^DE!((<
%%g:}}&&q#*;*;T4U~~cjj>?+GLL>:;Y--r3   c               r   )r*   r  r   r   r   r:   r  r-   r.   r/   r0   r1   r  0  s&     @ @w @Z @D @r3   c           	     s~   \         P                  RVP                   24       \        W!V P                  4      p\
        P                  V P                  P                  9   d   V P                  W4       M@\        V\        4      '       d    VP                  \        P                  8X  g   \        R4      h\!        Y!^ V P                  ^ ,          u;8  ;'       d    ^8  Mu 4      pV P"                  P%                  ^ \&        P(                  ^?^\+        V4      4       \         P-                  RVP                   24       R# )zImport a private key into the given slot.

Requires Admin PIN verification.

:param key_ref: The key slot.
:param private_key: The private key to import.
zImporting a private key for z(This YubiKey only supports RSA 2048 keyszPrivate key imported for N)r  r  rN   ry  r   r   r   r  r   r  r   r   r   r   r   r   r~  r  r  r[   rg   r,   r  )r@   r  r   r  Ztemplater  r0   put_keyZOpenPgpSession.put_key0  s     	3GLL>BC(t||L
%EE))//0 ))'> :}55$$(8(88'(RSS$[1t||A;R;RQR;RS3#3#3T4xQ/~>?r3   c               r   r*   r  r   r:   r  r-   r.   r/   r0   r1   r  K  s      ' d r3   c           	     s   ^ V P                   ^ ,          u;8  d   ^8  d6   M M2V P                  V\        P                  ! RR\	        4       4      4       R# V P                  VP                  \        P                  \        P                  4      4       V P                  V\        P                  \        P                  4      4       R# )zdDelete the contents of a key slot.

Requires Admin PIN verification.

:param key_ref: The key slot.
rt  r   N)r   r  r   Zgenerate_private_keyr   r  r   r   r   r   r   r  r   r+  r7   r0   
delete_keyZOpenPgpSession.delete_keyK  s     t||A""LL11%?PQ
 MM//1E1EhFVFV1W ))--h.>.>?r3   c               r   r  r-   r.   r/   r0   r1   r  `  s      7 t r3   c           	     	s   \         P                  R VP                   24        \        V P                  R4       \        ^`\        ^\\        \        P                  4      4      4      pV P                  R8:  d
   RV,           pV P                  P                  ^ \        P                  ^V,
          ^V4       R#   \         d    T\        P                  8X  d    R# h i ; i)zSelecting certificate for key s   Nr  )r  r   r  )r  r  rN   r!   r   r   r    rq   r   r  r  r[   rd   r   r   r   r  r   r0   _select_certificateZ"OpenPgpSession._select_certificate`  s    5gll^DE	DLL)4dCi8Q8Q.R$STD||y(~MM##G ! 	'++%	s   BB7 7 CCc               r   r*   r  r   r:   x509.Certificater-   r.   r/   r0   r1   r  t  s     G Gw G3C Gr3   c                s   \         P                  RVP                   24       V\        P                  8X  d7   \        V P                  R4       V P                  \        P                  4      pM0V P                  V4       V P                  \        P                  4      pV'       g   \        R4      h\        P                  ! V\        4       4      # )z:Get a certificate from a slot.

:param key_ref: The slot.
zGetting certificate for key zNo certificate found!r  )r  r  rN   r   r   r!   r   r  rq   r   r  r   r   r   Zload_der_x509_certificater   r  r   r0   get_certificateZOpenPgpSession.get_certificatet  s    
 	3GLL>BCgkk!DLL)4==!3!34D$$W-==!:!:;D455--dO4EFFr3   c               r   )r*   r  r   certificater  r:   r  r-   r.   r/   r0   r1   r    s(     D Dw D=M DRV Dr3   c                s   VP                  \        P                  4      p\        P	                  RVP
                   24       V\        P                  8X  d8   \        V P                  R4       V P                  \        P                  V4       M1V P                  V4       V P                  \        P                  V4       \        P                  RVP
                   24       R# )zImport a certificate into a slot.

Requires Admin PIN verification.

:param key_ref: The slot.
:param certificate: The X.509 certificate to import.
zImporting certificate for key zCertificate imported for key Nr  )public_bytesr   ZDERr  r  rN   r   r   r!   r   r  rq   r   r  r   r  )r@   r  r  Z	cert_datar  r0   put_certificateZOpenPgpSession.put_certificate  s      ,,X\\:	5gll^DEgkk!DLL)4MM",,i8$$W-MM"33Y?3GLL>BCr3   c               r   r  r-   r.   r/   r0   r1   r    s     C C' Cd Cr3   c                s   \         P                  RVP                   24       V\        P                  8X  d8   \        V P                  R4       V P                  \        P                  R4       M1V P                  V4       V P                  \        P                  R4       \         P                  RVP                   24       R# )z]Delete a certificate in a slot.

Requires Admin PIN verification.

:param key_ref: The slot.
zDeleting certificate for key r3   zCertificate deleted for key Nr  )r  r  rN   r   r   r!   r   r  rq   r   r  r   r  r+  r7   r0   delete_certificateZ!OpenPgpSession.delete_certificate  s     	4W\\NCDgkk!DLL)4MM",,c2$$W-MM"33S927<<.ABr3   c               r   r  r-   r.   r/   r0   r1   r    s     - -' -.> -r3   c                s0   \        V P                  R4       \        P                  RVP                   24       V P
                  P                  ^\        P                  V^ 4       \        P                  RVP                   24       V P                  V4      # )zCreate an attestation certificate for a key.

The certificate is written to the certificate slot for the key, and its
content is returned.

Requires User PIN verification.

:param key_ref: The key slot.
zAttesting key z$Attestation certificate created for r  )r!   r   r  r  rN   r  r  r[   rk   r  r  r+  r7   r0   
attest_keyZOpenPgpSession.attest_key  sp     	i0~gll^45c&9&97AF:7<<.IJ##G,,r3   c               $    V ^8  d   QhRRRRRR/# r*   r  r,   rH  zhashes.HashAlgorithmr:   r-   r.   r/   r0   r1   r    s"      E 3G E r3   c                s   V P                  \        P                  4      p\        W1V4      p\        P                  RV 24       V P                  P                  ^ \        P                  ^^V4      p\        P                  R4       VP                  ^8X  dL   \        V4      ^,          p\        \        P                  VRV R4      \        P                  WVR R4      4      # V# )zSign a message using the SIG key.

Requires User PIN verification.

:param message: The message to sign.
:param hash_algorithm: The pre-signature hash algorithm.
zSigning a message with zMessage signedNbig)r,  r   r   r  r  r  r  r  r[   r_   r  r   r  r   r   
from_bytesr@   r  rH  r  Zpaddedresponser}  rS  r0   signZOpenPgpSession.sign  s     227;;?
j>B.zl;<==**1cggtT6J$%""d*X!#B'x}e4x}e4  r3   c               r   )r*   r   zbytes | EcPublicKeyr:   r,   r-   r.   r/   r0   r1   r    s        0  U  r3   c           
     s@   V P                  \        P                  4      p\        P	                  RV 24       \        V\        P                  4      '       d0   VP                  \        P                  \        P                  4      pMs\        V\        P                  4      '       d0   VP                  \        P                  \        P                  4      pM$\        V\         4      '       d   TpM\#        R4      h\        V\$        4      '       d   RV,           pMB\        V\&        4      '       d"   \)        ^\)        R\)        ^V4      4      4      pM\#        R4      hV P*                  P-                  ^ \.        P0                  ^^V4      p\        P3                  R4       V# )a,  Decrypt a value using the DEC key.

For RSA the `value` should be an encrypted block.
For ECDH the `value` should be a peer public-key to perform the key exchange
with, and the result will be the derived shared secret.

Requires (extended) User PIN verification.

:param value: The value to decrypt.
zDecrypting a value with z#Value must be a bytes or public keys    rl   z Unsupported algorithm attributeszValue decrypted)r,  r   r   r  r  r   r   r  r  r   ZX962r   ZUncompressedPointr   r  r|  r,   r   r   r  r   r  r  r[   r_   r  )r@   r   r  r   r  r@  r0   decryptZOpenPgpSession.decrypt  s"    227;;?
/
|<=eR6677%%hmm\5S5STDv5566%%hllL4D4DEDu%%DBCCj-004<D
L11tST49:D?@@==**1cggtT4H%&r3   c               r  r  r-   r.   r/   r0   r1   r    s$      .B	r3   c                s   V P                  \        P                  4      p\        W1V4      p\        P                  RV 24       V P                  P                  ^ \        P                  ^ ^ V4      p\        P                  R4       VP                  ^8X  dL   \        V4      ^,          p\        \        P                  VRV R4      \        P                  WVR R4      4      # V# )zAuthenticate a message using the AUT key.

Requires User PIN verification.

:param message: The message to authenticate.
:param hash_algorithm: The pre-authentication hash algorithm.
zAuthenticating a message with zMessage authenticatedNr  )r,  r   r   r  r  r  r  r  r[   rc   r  r   r  r   r   r  r  rS  r0   authenticateZOpenPgpSession.authenticate  s     227;;?
j>B5j\BC==**s((#sF
 	+,""d*X!#B'x}e4x}e4  r3   )r  r  r  rF   r4   F)8rQ   rR   rS   rT   r   r  r  rW   r/  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r,  r  r  r-  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rX   r-   r3   r0   r  r    s@   1N:	 " "   B BNL=A#

0@2?<,(	9*9.0,931@D9v>0	7:Q
R

HN

>($B..@6*(G D$C - * D r3   r  s           r  )__conditional_annotations__Z
__future__r   r   ZloggingrV  r;   Zdataclassesr   Zenumr   r   r   r   Ztypingr   r   r	   r
   r   Zcryptographyr   Zcryptography.hazmat.backendsr   Zcryptography.hazmat.primitivesr   Z)cryptography.hazmat.primitives.asymmetricr   r   r   r   Z/cryptography.hazmat.primitives.asymmetric.utilsr   r   Z,cryptography.hazmat.primitives.serializationr   r   r   r   Zcorer   r   r   r   r   r   r   r    r!   Zcore.smartcardr"   r#   r$   r%   r&   r'   Z	getLoggerrQ   r  rW  rX  r(   rY   r[   r  r1  r$  r%  r&  r'  r4  r)  r  rm   rq   r   r,   r   r   r   r   r=   r   r   r   r   r   r  r  r   r  r  r  r  r   r   ZRSAPublicKeyr   r{  r   r   r   ru  r   ZABCr   r   r   r   r   r   r   r  r  r  r  r  r.  r2  r5  r?  rB  rG  r[  rf  rj  rp  ry  r~  r  r  ZMD5ZfromhexZSHA1ZSHA224rE  ZSHA384rF  Z
SHA512_224Z
SHA512_256r  r  r  )r  ro  r0   <module>r     s  8 # " 
  	  ! / /   8 1 N N 
 
 
  
		8	$   4' 4 4< 4 4 4 '  &              * * *Z- 8  8F    
 
 
 

 

 

    
 
 
, 
 
 
@ (% ( ( 'g ' '6    *,-w~&'3,' 8 886;Q;QQ Y  #S%5%55	9 5//  i 
 ::\I
I I $#'' $ $0 w      
' 
 
4;s ;(D @ w  
 &  D ,< ,< ,<^ 
 
 
B ; ; ; $#'' $ $: <c < < ;W ; ; K
s K
 K
^ 
 
 
  

' 

 

 
 
 
  	& 	 	D""-J1
M JJDE
KK?@
MM5==!IJ
MM5==!IJ
MM5==!IJ
MM5==!IJ
u}}%MN
u}}%MN	 L,f fr3   