+
      xi"  c                  s    R t ^ RIHt ^ RIt^ RIt^ RIHtHtHt ^ RI	H
t
 ]'       d   ^ RIHt ^ RIHt  ! R R4      t ! R	 R
]4      t ! R R4      t ! R R4      t ! R R4      tR# )z.Module that handles keys stored in PSKC files.)annotationsN)AnyTYPE_CHECKINGcast)Policy)PSKC)Devicec                  sH    ] tR t^%tRtR R lt]R R l4       tR R ltRt	R	# )
EncryptedValuez#A container for an encrypted value.c               s(    V ^8  d   QhRRRRRRRR/# )	   cipher_valuebytes	mac_valuebytes | None	algorithmz
str | NonereturnNone Zformat   "-/usr/lib/python3.14/site-packages/pskc/key.py__annotate__EncryptedValue.__annotate__(   s*     # #U #| #PZ #_c #    c                	s*    Wn         W n        W0n        R # N)r	   r   r   )selfr	   r   r   s   &&&&r   __init__ZEncryptedValue.__init__(   s    (""r   c               $    V ^8  d   QhRRRRRR/# )r   pskcr   valuezbytes | bytearray | strr   r   r   r   r   r   r   r   .   s'     
G 
G$ 
G'> 
G> 
Gr   c                s   \        V\        \        34      '       g   VP                  4       pVP                  P                  \        \        V4      4      pRpVP                  P                  '       d   VP                  P                  V4      pVP                  P                  '       g   Q hV ! W4VP                  P                  4      # )4Construct an encrypted value from a plaintext value.N)

isinstancer
   Z	bytearrayZencode
encryptionZencrypt_valuer   macr   generate_mac)clsr   r   r	   r   s   &&&  r   createZEncryptedValue.create-   s     %%!344LLNE44T%5GH	88--l;I(((((<DOO,E,EFFr   c                    V ^8  d   QhRRRR/# )r   r   r   r   r
   r   r   r   r   r   r   :   s      d u r   c                sD   ^ RI Hp VP                  P                  V P                  V P
                  4      pV P                  '       dX   V P                  VP                  P                  V P                  4      VP                  P                  V4      39  d	   V! R4      hV# )zProvide the decrypted value.)DecryptionErrorzMAC value does not match)	Zpskc.exceptionsr%   r   Zdecrypt_valuer	   r   r   r    r!   )r   r   r%   Z	plaintexts   &&  r   	get_valueZEncryptedValue.get_value:   s~    3OO11$2C2CT^^T	 >>>dnn%%d&7&78%%i052 2 ""<==r   )r   r	   r   N)
__name__
__module____qualname____firstlineno____doc__r   classmethodr#   r&   __static_attributes__r   r   r   r   r   %   s*    -#
 
G 
G r   r   c                  sN   a  ] tR t^HtRt]R V 3R ll4       tR V 3R lltRtV ;t	# )EncryptedIntegerValuez.Class representing an encrypted integer value.c               r   )r   r   r   r   intr   r   r   r   r   r   r   "EncryptedIntegerValue.__annotate__L   s&     K K$ Ks K~ Kr   c                s   < RV,          p\        V4      p\        P                  ! VP                  WD^,          ,           4      4      p\        \
        V `  W4      # )r   z%x)ZlenbinasciiZ	unhexlifyZzfillsuperr.   r#   )r"   r   r   Z	str_valueZnZbytes_value	__class__s   &&&   r   r#   ZEncryptedIntegerValue.createK   sI     5L		N((!e)EF*C7JJr   c               r$   )r   r   r   r   r/   r   r   r   r   r   r0   S   s     
 
d 
s 
r   c                s   < \         \        V `  V4      pVP                  4       '       d   \	        V4      # ^ p\
        P
                  ! RV4       F  pV^,          V,           pK  	  V# )z$Provide the decrypted integer value.ZB)r2   r.   r&   Zisdigitr/   array)r   r   r   Zresultxr3   s   &&   r   r&   ZEncryptedIntegerValue.get_valueS   sW    +T<TB==??u:S%(AkQ&F )r   r   )
r'   r(   r)   r*   r+   r,   r#   r&   r-   Z__classcell__)r3   s   @r   r.   r.   H   s$    8K K
 
r   r.   c                  s>    ] tR t^`tRtR R ltR R ltR R ltRtR	# )
DataTypePropertyz?A data descriptor that delegates actions to DataType instances.c               s$    V ^8  d   QhRRRRRR/# )r   namestrdocr   r   r   r   r   r   r   DataTypeProperty.__annotate__c   s!      S s t r   c                	s    Wn         W n        R # r   )r7   r+   )r   r7   r9      &&&r   r   ZDataTypeProperty.__init__c   s    	r   c               r   r   objKeyobjtypeztype | Noner   r   r   r   r   r   r   r:   g   s!      3   r   c                	s    \        VR V P                  ,           R4      p\        V\        4      '       d&   VP	                  VP
                  P                  4      # V# Z_N)getattrr7   r   r   r&   devicer   )r   r=   r?   r   s   &&& r   __get__ZDataTypeProperty.__get__g   sA    S499_d3e^,,??3::??33Lr   c               r   r   r=   r>   valr   r   r   r   r   r   r   r   r:   n   s!     + +3 +S +T +r   c                	sB    \        VR V P                  ,           V4       R# r@   )setattrr7   r   r=   rE   r;   r   __set__ZDataTypeProperty.__set__n   s    S499_c*r   )r+   r7   N	r'   r(   r)   r*   r+   r   rC   rH   r-   r   r   r   r6   r6   `   s    I+ +r   r6   c                  s>    ] tR t^rtRtR R ltR R ltR R ltRtR	# )
DevicePropertyz@A data descriptor that delegates actions to the Device instance.c               r$   )r   r7   r8   r   r   r   r   r   r   r   DeviceProperty.__annotate__u   s      S T r   c                	s    Wn         R # r   r7   )r   r7      &&r   r   ZDeviceProperty.__init__u   s    	r   c               r   r<   r   r   r   r   r   rK   x   s!     . .3 . . .r   c                	sB    \        VP                  V P                  4      # r   )rA   rB   r7   )r   r=   r?   r;   r   rC   ZDeviceProperty.__get__x   s    szz499--r   c               r   rD   r   r   r   r   r   rK   {   s!     , ,3 ,S ,T ,r   c                	sH    \        VP                  V P                  V4       R # r   )rF   rB   r7   rG   r;   r   rH   ZDeviceProperty.__set__{   s    

DIIs+r   rL   NrI   r   r   r   rJ   rJ   r   s    J., ,r   rJ   c                  sf   ] tR t^t$ RtR R lt]! RR4      tR]R&   ]! RR4      t	R	]R&   ]! R
R4      t
R	]R
&   ]! RR4      tR	]R&   ]! RR4      tR	]R&   ]! R4      t]! R4      t]! R4      t]! R4      t]! R4      t]! R4      t]! R4      t]! R4      t]! R4      tR R lt]R R l4       tRtR# )r>   a?  Representation of a single key from a PSKC file.

Instances of this class provide the following properties:

  id: unique key identifier (should be constant between interchanges)
  algorithm: identifier of the PSKC algorithm profile (URI)
  secret: the secret key itself (binary form, automatically decrypted)
  counter: event counter for event-based OTP
  time_offset: time offset for time-based OTP algorithms (in intervals)
  time_interval: time interval for time-based OTP in seconds
  time_drift: device clock drift (negative means device is slow)
  issuer: party that issued the key
  key_profile: reference to pre-shared key profile information
  key_reference: reference to an external key
  friendly_name: human-readable name for the secret key
  key_userid: user distinguished name associated with the key
  algorithm_suite: additional algorithm characteristics (e.g. used hash)
  challenge_encoding: format of the challenge for CR devices
  challenge_min_length: minimum accepted challenge length by device
  challenge_max_length: maximum size challenge accepted by the device
  challenge_check: whether the device will check an embedded check digit
  response_encoding: format of the response the device will generate
  response_length: the length of the response of the device
  response_check: whether the device appends a Luhn check digit
  policy: reference to policy information (see Policy class)

This class also provides access to the manufacturer, serial, model,
issue_no, device_binding, start_date, expiry_date, device_userid and
crypto_module properties of the Device class.
c               r$   )r   rB   r   r   r   r   r   r   r   r   Key.__annotate__   s     # #v #$ #r   c                	s   Wn         R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n        R V n	        R V n
        R V n        R V n        R V n        R V n        R V n        \!        V 4      V n        R # r   )rB   idr   issuerkey_profilekey_referencefriendly_name
key_useridalgorithm_suitechallenge_encodingchallenge_min_lengthchallenge_max_lengthchallenge_checkresponse_encodingresponse_lengthresponse_checkr   policy)r   rB   rM   r   r   ZKey.__init__   s    "%)"&'+)-)-&*+/.204!04!,0-1+/+/Tlr   secretzThe secret key itself.r   counterz%An event counter for event-based OTP.z
int | Nonetime_offsetz7A time offset for time-based OTP (number of intervals).time_intervalzA time interval in seconds.
time_driftz4Device clock drift value (number of time intervals).manufacturerserialmodelissue_nodevice_binding
start_dateexpiry_datedevice_useridcrypto_modulec                   V ^8  d   QhRR/# )r   r   Zboolr   r   r   r   r   rN      s      t r   c                sZ   \         ;QJ dS    R V P                  V P                  V P                  V P                  V P
                  3 4       F  '       d   K   RMH	  RMD! R V P                  V P                  V P                  V P                  V P
                  3 4       4      '       d   R# Q h)zCheck if all MACs in the message are valid.

This will return `None` if there is no MAC to be checked. It will return
True if all the MACs match. If any MAC fails a
`DecryptionError` exception is raised.
c              3  s(   "   T F  qR Jx  K
  	  R# 5i)FNr   )Z.0r5   s   & r   Z	<genexpr>ZKey.check.<locals>.<genexpr>   s      6 (5!~ (5s   FT)Zallr^   r_   r`   ra   rb   r      &r   checkZ	Key.check   s     3 6T\\4+;+;""DOO(5 6333 6T\\4+;+;""DOO(5 6 6 6 ur   c               rl   )r   r   r8   r   r   r   r   r   rN      s     5 5 5r   c                sB    V P                   ;'       g    V P                  # )z2User identifier (either the key or device userid).)rT   rj   rm   rn   r   useridZ
Key.userid   s     44$"4"44r   )r   rU   rY   rV   rX   rW   rB   rS   rO   rP   rQ   rR   rT   r]   r\   rZ   r[   N)r'   r(   r)   r*   r+   r   r6   r^   Z__annotations__r_   r`   ra   rb   rJ   rc   rd   re   rf   rg   rh   ri   rj   rk   ro   Zpropertyrp   r-   r   r   r   r>   r>      s    >#4 ,*,FL ,*:<GZ <.ACK C !16!8M: 8-LNJ
 N ".1LH%F7#Ej)H#$45N-J /K"?3M"?3M 5 5r   r>   )r+   Z
__future__r    r4   r1   Ztypingr   r   r   Zpskc.policyr   r   r   Zpskc.devicer   r   r.   r6   rJ   r>   r   r   r   <module>rq      s^   * 5 "   + + "   FN 0+ +$
, 
,`5 `5r   