+
    :io&  c                   s	   ^ RI t ^ RIt ^ RIt^ RIHt ^ RIHt ^RIHtH	t	H
t
 ]P                  ! ]4      tRtRtRtRtR	tR
tRtRt ! R R] P,                  4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t] P:                  ! ]4      t] P:                  ! ]4      t] P:                  ! ]4      t ] P:                  ! ]4      t!] PD                  t#] PD                  t$] PJ                  t&] PN                  t(] PR                  t*] PV                  t,] PV                  t-] PV                  t.] PV                  t/] PV                  t0]/t1]/t2] P:                  ! ]4      t3] P:                  ! ]4      t4^t5Rt6^ t7^t8^ t9] Pt                  Pw                  ] Px                  P{                  R4      ;'       g    R4      t>] Pt                  Pw                  ] Px                  P{                  R4      ;'       g    R4      t?R]?P                  nA        ]] P:                  ! ] PD                  4      .]?P                  nB        ]]?P                  nA        ] PD                  ] P                  ] P                  .]?P                  nB        ]&]?P                  nA        ] .]?P                  nB        ]&]?P                  nA        ] P                  ]?P                  nA        ],]?P                  nA        ] .]?P                  nB        ]/.]>P                  nB        ]3]>P                  nA        ]!]..]>P                  nB        ]]>P                  nA        ]3.]>P                  nB        R]>P                  nA        ]3] .]>P                  nB        ]$]>P                  nA        ] P                  .]>P                  nB        ],]>P                  nA        ]2] P:                  ! ] P                  4      .]>P                  nB        ]4]>P                  nA        ]!]1.]>P                  nB        ],]>P                  nA        ]4] P                  .]>P                  nB        ] ]>P                  nA        ]4].]>P                  nB        ],]>P                  nA        ]4]-](] PD                  ](.]>P                  nB        ],]>P                  nA        ]4]-](] PD                  ] P:                  ! ](4      .]>P                  nB        ]1]>P                  nA        ]0]#.]>P                  nB         ! R R]4      tXR tYR  tZR! t[R# )"    N)OtpConnection)	LOG_LEVEL)	USAGE_OTP
YUBICO_VIDOtpYubiKeyDevices   VendorIDs	   ProductIDs   Products   PrimaryUsages   PrimaryUsagePages   MaxInputReportSizes   MaxOutputReportSizes   ReportIDc                   s    ] tR t^*tRtR# )_CFType N__name__
__module____qualname____firstlineno____static_attributes__r       4/usr/lib/python3.14/site-packages/ykman/hid/macos.pyr   r   *       r   r   c                   s    ] tR t^.tRtR# )	_CFStringr   Nr   r   r   r   r   r   .   r   r   r   c                   s    ] tR t^2tRtR# )_CFSetr   Nr   r   r   r   r   r   2   r   r   r   c                   s    ] tR t^6tRtR# )_IOHIDManagerr   Nr   r   r   r   r   r   6   r   r   r   c                   s    ] tR t^:tRtR# )_IOHIDDevicer   Nr   r   r   r   r   r   :   r   r   r   c                   s    ] tR t^>tRtR# )_CFAllocatorr   Nr   r   r   r   r   r   >   r   r   r   ZIOKitz0/System/Library/Frameworks/IOKit.framework/IOKitZCoreFoundationzB/System/Library/Frameworks/CoreFoundation.framework/CoreFoundationc                   s8   a  ] tR t^t o R tR tR tR tRtV t	R# )MacHidOtpConnectionc                s   \        V4      p\        P                  ! V4      p\        P	                  V4      p\        P                  \        V4      pV'       g   \        R V R24      h\        P                  \        V4      V n
        V P                  '       g   \        R4      h\        P                  V4       \        P                  V P                  ^ 4      pV\        8w  d   \        RV 24      hR# )z
Device ID z, does not match any HID device on the systemz2Failed to obtain device handle from registry entryz)Failed to open device for communication: N)Zintctypesc_uint64iokitIORegistryEntryIDMatchingIOServiceGetMatchingServiceK_IO_MASTER_PORT_DEFAULTOSErrorIOHIDDeviceCreateK_CF_ALLOCATOR_DEFAULThandleIOObjectReleaseZIOHIDDeviceOpenK_IO_RETURN_SUCCESS)selfZpath	device_identry_idZmatching_dictZdevice_entryresults   &&     r   __init__ZMacHidOtpConnection.__init__   s    I	??9-77A88$m
 YK'ST  --.DlS{{{NOOl+ &&t{{A6((EfXNOO )r   c                s|    V P                   '       d*   \        P                  V P                   ^ 4       RV n         R# R# )r    N)r    r   IOHIDDeviceClose)r#   s   &r   closeZMacHidOtpConnection.close   s+    ;;;""4;;2DK r   c           	     s   \         P                  ! ^4      p\        \         P                  ! V4      4      p\        P                  V P                  \        ^ V\         P                  ! V4      4      pV\        8w  d   \        RV 24      hVP                  R,          p\        P                  \        P                  RVP!                  4       4       V# )i   z#Failed to read report from device: :NNNzRECV: %s)r   Zcreate_string_bufferCF_INDEXZsizeofr   IOHIDDeviceGetReportr    K_IO_HID_REPORT_TYPE_FEATUREbyrefr"   r   Zrawloggerlogr   TRAFFIChex)r#   ZbufZ
report_lenr&   datas   &    r   receiveZMacHidOtpConnection.receive   s    ))!,fmmC01
++KK(LL$
 ((?xHIIwwqz

9$$j$((*=r   c           	     s    \         P                  \        P                  R VP	                  4       4       \
        P                  V P                  \        ^ V\        V4      4      pV\        8w  d   \        RV 24      hR# )zSEND: %sz"Failed to write report to device: N)r.   r/   r   r0   r1   r   IOHIDDeviceSetReportr    r,   Zlenr"   r   )r#   r2   r&   s   && r   sendZMacHidOtpConnection.send   sh    

9$$j$((*=++KK(I
 ((>vhGHH )r   )r    N)
r	   r
   r   r   r'   r)   r3   r5   r   Z__classdictcell__)Z__classdict__s   @r   r   r      s!     P.
(I Ir   r   c                s   \         P                  RV^ 4      p\        P                  W4      p\         P	                  V4       V'       g   R# \         P                  V4      \         P                  4       8w  d"   \        R\         P                  V4       24      h\        P                  ! 4       p\         P                  V\        \        P                  ! V4      4      pV'       g   R# VP                  # )z'Reads int property from the HID device.NzExpected number type, got )cfCFStringCreateWithCStringr   IOHIDDeviceGetProperty	CFReleaseCFGetTypeIDCFNumberGetTypeIDr   r   Zc_int32CFNumberGetValueK_CF_NUMBER_SINT32_TYPEr-   value)devZkeyZcf_keyZtype_refZoutZrets   &&    r   get_int_propertyr@      s    ))$Q7F++C8HLL	~~h2#7#7#9922>>(3K2LMNN
..
C


h(?cAR
SC99r   c                s    \         P                  V 4      p\        P                  ! 4       p\         P	                  V\        P
                  ! V4      4      pV\        8w  d   \        RV 24      hVP                  # )zObtains the unique IORegistry entry ID for the device.

Args:
device_handle: reference to the device

Returns:
A unique ID for the device, obtained from the IO Registry
z&Failed to obtain IORegistry entry ID: )	r   ZIOHIDDeviceGetServicer   r   !IORegistryEntryGetRegistryEntryIDr-   r"   r   r>   )Zdevice_handleZio_service_objr%   r&   s   &   r   get_device_idrB      sf     00?N H44X.F $$>vhGHH>>r   c                  s>   \         P                  R ^ 4      p V '       g   \        R4      h \         P                  V R 4       \         P	                  V 4      pV'       g   \        R4      h \         P                  V4      p\        V,          ! 4       p\         P                  W4       . pV F  p\        V\        4      pV\        8X  g   K   \        V\        4      p\        V\        4      \        V\        4      3p\        V4      p	V\        8X  g   Kh  VP!                  \#        \%        V	4      V\&        4      4       K  	  V\(        P+                  V4       \(        P+                  V 4       #   \(        P+                  T4       i ; i  \(        P+                  T 4       i ; i)Nz&Unable to obtain HID manager referencez)Failed to obtain devices from HID manager)r   IOHIDManagerCreater   IOHIDManagerSetDeviceMatchingIOHIDManagerCopyDevicesZCFSetGetCountIO_HID_DEVICE_REFCFSetGetValuesr@   HID_DEVICE_PROPERTY_VENDOR_IDr   HID_DEVICE_PROPERTY_PRODUCT_ID&HID_DEVICE_PROPERTY_PRIMARY_USAGE_PAGE!HID_DEVICE_PROPERTY_PRIMARY_USAGErB   r   Zappendr   Zstrr   r6   r9   )
Zhid_mgrZdevice_set_refZnumZdevicesZdevsr?   ZvidZpidZusager$   s
             r   list_devicesrL     sB   &&tQ/G>??++GT:66w?EFF	)%%n5C(3.1G  9 D&s,IJ*$*30NOC(.TU(.OPE !.c 2I	),S^SBUV  LL(
W LL(
Ws7   2F F *AE+ 
AE+ .E+  F +FF F)\r   Zctypes.utilZloggingZyubikit.core.otpr   Zyubikit.loggingr   Zbaser   r   r   Z	getLoggerr	   r.   rH   rI   ZHID_DEVICE_PROPERTY_PRODUCTrK   rJ   Z)HID_DEVICE_PROPERTY_MAX_INPUT_REPORT_SIZEZ*HID_DEVICE_PROPERTY_MAX_OUTPUT_REPORT_SIZEZHID_DEVICE_PROPERTY_REPORT_IDZ	Structurer   r   r   r   r   r   ZPOINTERZ
CF_SET_REFZCF_STRING_REFZCF_TYPE_REFZCF_ALLOCATOR_REFZc_void_pZCF_DICTIONARY_REFZCF_MUTABLE_DICTIONARY_REFZc_ulongZ
CF_TYPE_IDZc_longr*   Zc_doubleZCF_TIME_INTERVALZc_uintZ	IO_RETURNZIO_HID_REPORT_TYPEZIO_OPTION_BITSZIO_OBJECT_TZMACH_PORT_TZIO_SERVICE_TZIO_REGISTRY_ENTRY_TZIO_HID_MANAGER_REFrF   r=   r   r   r,   r"   ZcdllZLoadLibraryZutilZfind_libraryr   r6   rG   ZrestypeZargtypesr7   Zc_char_pZc_uint32r:   r;   Zc_intr<   r9   r!   rC   rE   rD   r   r   rA   r   r(   r8   r4   r+   r   r   r@   rB   rL   r   r   r   <module>rM      s  $    * % 9 9			8	$ !, !- ( $3 !)< &,A )-C * + 	f 		 		W 		G 		7 		7 	 ^^F#
y)nnW%>>,/ OO "OO ^^
==?? MM	]] mmmm! ^^M2 NN<0         	
KKW% : :9	 [[
KK-. L LK !   (&..*IJ   '4   $
OO
OO
OO)   %
 $ &- )   $ll     $ "-   #5    %5~$F   !(2   %*<)=   &.2 # # +0BK/P # # ,*C   ',2OO+<   (2; ' ' /
NN6??#4 ' ' 0
 #4   $4l#C    !*   #4foo"F   '2   $):M(J   %%.   "
OO'   # &/   "
OO
NN8'   # -9 ! ! ).9;L-M ! ! *=I- =I@&*#r   