UART communication checksum - serial-port

I am trying to decode/understand a serial (UART) communication protocol between an air conditioner and wifi module. I have used Docklight to sniff communication, I have some results how to switch on the AC unit and switch off, change modes etc. But I do not understand how to calculate CRC. Here is an example:
18/08/2020 17:15:28.292 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 A9 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 04 4F 39
Communication log please see full log below:
Mobile APP ON
18/08/2020 17:15:06.001 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:15:06.651 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 18 F3
18/08/2020 17:15:15.917 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:15:16.589 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 18 F3
18/08/2020 17:15:25.928 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:15:26.605 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 18 F3
POWER ON FROM APP -
18/08/2020 17:15:28.292 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 A9 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 04 4F 39
18/08/2020 17:15:28.982 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 3D 6A
18/08/2020 17:15:35.928 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:15:36.653 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 8F 7B
18/08/2020 17:15:45.496 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 42 A9 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 05 83 05
18/08/2020 17:15:46.151 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 AA FE
18/08/2020 17:15:46.531 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:15:46.909 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 18 F3
18/08/2020 17:15:56.029 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:15:56.719 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 18 F3
18/08/2020 17:16:01.325 [Wifi to Ciat] - AA 1E AC B2 00 00 63 00 00 0D 01 01 01 69 03 A8 C0 00 00 00 01 01 00 00 00 00 00 00 00 00 3B AA 20
- AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:16:06.621 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 18 F3
18/08/2020 17:17:31.039 [Wifi to Ciat] - AA 1E AC B2 00 00 64 00 00 0D 01 01 01 69 03 A8 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 3C
- AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:18:02.095 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 00 A9 28 7F 7F 00 30 00 00 00 66 5F 00 00 00 00 00 00 00 00 00 9C C9 43
18/08/2020 17:18:02.220 [Wifi to Ciat] - AA 1E AC B2 00 00 65 00 00 0D 01 01 01 69 03 A8 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 3B
- AA 1E AC B2 00 00 66 00 00 0D 01 01 01 69 03 A8 C0 00 00 00 01 01 00 00 00 00 00 00 00 00 38
(...)
Eco on in cool mode -
- AA 23 AC 00 00 00 00 00 03 02 40 43 49 66 7F 7F 00 30 00 80 00 00 00 00 00 00 00 00 00 1E 00 00 00 1A EA 2A
18/08/2020 17:22:05.042 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 66 7F 7F 00 30 00 10 00 66 5F 00 00 00 00 00 00 00 00 00 00 85 35
18/08/2020 17:22:11.244 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:22:11.925 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 10 00 66 5F 00 00 00 00 00 00 00 00 00 9C 37 E6
18/08/2020 17:22:21.325 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:22:21.985 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 10 00 66 5F 00 00 00 00 00 00 00 00 00 9C 37 E6
Eco off in cool mode -
18/08/2020 17:22:22.025 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 66 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 1B A2 F1
18/08/2020 17:22:22.684 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 66 7F 7F 00 30 00 00 00 66 5F 00 00 00 00 00 00 00 00 00 00 77 53
18/08/2020 17:22:31.234 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:22:31.923 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 00 00 66 5F 00 00 00 00 00 00 00 00 00 9C C5 68
18/08/2020 17:22:41.272 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:22:41.901 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 00 00 66 5F 00 00 00 00 00 00 00 00 00 9C C5 68
18/08/2020 17:22:51.311 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:22:51.964 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 14 18
Fan auto cool mode -
18/08/2020 17:22:52.421 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 66 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 1C 21 71
18/08/2020 17:22:53.133 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 66 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 A6 23
18/08/2020 17:23:01.326 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:23:01.997 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 14 18
18/08/2020 17:23:11.373 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:23:12.108 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 66 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C 14 18
Fan high cool mode -
18/08/2020 17:23:15.540 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 50 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 1D 73 34
18/08/2020 17:23:16.272 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 50 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 0A D5
18/08/2020 17:23:21.383 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:23:22.061 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 50 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C B8 8A
18/08/2020 17:23:30.203 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 3C 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 1E 89 31
18/08/2020 17:23:30.881 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 3C 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 4B A8
18/08/2020 17:23:31.278 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:23:31.992 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 3C 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C F9 5D
18/08/2020 17:23:41.298 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:23:41.972 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 3C 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C F9 5D
18/08/2020 17:23:42.681 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 50 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 1F CF D6
18/08/2020 17:23:43.373 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 50 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 0A D5
Fan mid cool mode -
18/08/2020 17:23:51.277 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 3C 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 20 28 90
18/08/2020 17:23:51.931 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 3C 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 4B A8
18/08/2020 17:23:52.059 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:23:52.670 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 3C 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C F9 5D
18/08/2020 17:24:01.275 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:24:01.986 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 3C 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 9C F9 5D
18/08/2020 17:24:01.986 [Wifi to Ciat] - AA 1E AC B2 00 00 69 00 00 0D 01 01 01 69 03 A8 C0 00 00 00 01 01 00 00 00 00 00 00 00 00 35 AA 23
- AC 00 00 00 00 00 03 02 40 43 49 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 21 CB 00
18/08/2020 17:24:09.492 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 28 7F 7F 00 30 00 00 00 66 60 00 00 00 00 00 00 00 00 00 00 50 B7
18/08/2020 17:24:11.350 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:24:11.940 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C 8B E1
18/08/2020 17:24:13.682 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 3C 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 22 94 22
18/08/2020 17:24:14.351 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 3C 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 00 22 D3
...
Fan low in cool mode -
18/08/2020 17:24:17.570 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 49 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 23 77 52
18/08/2020 17:24:18.240 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 49 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 00 39 D0
18/08/2020 17:24:21.317 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:24:21.988 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C 8B E1
18/08/2020 17:24:31.399 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:24:32.046 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 49 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C 8B E1
20 st in cool mode -
18/08/2020 17:24:38.338 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 44 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 24 D1 FC
18/08/2020 17:24:39.031 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 44 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 00 4F BF
18/08/2020 17:24:41.429 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:24:42.098 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 44 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C FD 74
18/08/2020 17:24:51.308 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:24:51.978 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 44 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C FD 74
21 st in cool mode -
18/08/2020 17:24:55.134 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 45 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 25 18 B3
18/08/2020 17:24:55.799 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 45 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 00 A5 68
18/08/2020 17:25:01.468 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:25:02.113 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 45 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C 17 59
22 st in cool mode -
18/08/2020 17:25:09.362 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 46 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 26 5A 6F
18/08/2020 17:25:10.035 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 46 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 00 82 8A
18/08/2020 17:25:11.392 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:25:12.024 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 46 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C 30 3F
23 st in cool mode -
18/08/2020 17:25:20.731 [Wifi to Ciat] - AA 23 AC 00 00 00 00 00 03 02 40 43 47 28 7F 7F 00 30 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 27 93 34
18/08/2020 17:25:21.405 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 02 C0 01 47 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 00 68 A3
18/08/2020 17:25:21.452 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:25:22.119 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 47 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C DA 94
18/08/2020 17:25:31.572 [Wifi to Ciat] - AA 20 AC 00 00 00 00 00 00 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 CD 9C
18/08/2020 17:25:32.247 [CIAT to WIFI] - AA 22 AC 00 00 00 00 00 03 03 C0 01 47 28 7F 7F 00 30 00 00 00 65 5F 00 00 00 00 00 00 00 00 00 9C DA 94
Thanks,

The last two bytes are not a CRC of the message. They do not obey the linearity property of a CRC.

Related

Hex to datetime from a BLE custom service

I'm trying to decode a hex string to a datetime format from a BLE custom UUID. I don't have any information except the decoded value and datetime, that's why I put similar examples in milliseconds and minutes. It will be complicated to see the value of another year.
If you look closely, you will notice there are only 2 values repeated twice in each row (bold and italic). First starts with 0x01 (maybe a flag) and then 2 bytes and second 2 bytes too.
Similar minutes:
01 8E 6C 00 00 8E 6C 00 00 62 25 62 25 00 00 00 00 00 00 00 - 1669024172,5141 (Nov 21 2022 09:49:32,5387632)
01 9C 6C 00 00 9C 6C 00 00 62 49 62 49 00 00 00 00 00 00 00 - 1669024172,68598 (Nov 21 2022 09:49:32,7638451)
01 fd 6c 00 00 fd 6c 00 00 64 0f 64 0f 00 00 00 00 00 00 00 - 1669024174,23293 (Nov 21 2022 09:49:34,3170414)
01 0d 6d 00 00 0d 6d 00 00 6e 2f 6e 2f 00 00 00 00 00 00 00 - 1669024174,5767 (Nov 21 2022 09:49:34,5414078)
01 f0 6d 00 00 f0 6d 00 00 62 21 62 21 00 00 00 00 00 00 00 - 1669024178,01436 (Nov 21 2022 09:49:38,0746688)
01 00 6e 00 00 00 6e 00 00 67 81 67 81 00 00 00 00 00 00 00 - 1669024178,35812 (Nov 21 2022 09:49:38,2775026)
Similar milliseconds:
01 16 1d 00 00 16 1d 00 00 4d f4 4d f4 00 00 00 00 00 00 00 - 1669023854,70251 (Nov 21 2022 09:44:14,7728813)
01 1e 6e 00 00 1e 6e 00 00 67 c5 67 c5 00 00 00 00 00 00 00 - 1669024178,70189 (Nov 21 2022 09:49:38,7714679)
01 e2 6d 00 00 e2 6d 00 00 62 4d 62 4d 00 00 00 00 00 00 00 - 1669024177,84247 (2022-11-21 10:49:37,8263242)
01 5f dd 06 00 5f dd 06 00 cb 46 cb 46 00 00 00 00 00 00 00 - 1669110577,66758 (2022-11-22 10:49:37,8231004)
01 00 6e 00 00 00 6e 00 00 67 81 67 81 00 00 00 00 00 00 00 - 1669024178,35812 (2022-11-21 10:49:38,2775026)
01 7c dd 06 00 7c dd 06 00 c8 0c c8 0c 00 00 00 00 00 00 00 - 1669024178      (2022-11-22 10:49:38,2722736)
It's looks like:
It's not decoded in the unix epoch (JAN 1 1970)
The first value is increasing (0xXX6C, 0xXX6E, 0xXX6E), so maybe it's the int part.
I tried to decode like year, minutes, seconds but it seems it isn't.
Sometimes first value is bigger than 2 bytes (3 bytes):
01 DE 61 04 00 DE 61 04 00 4A C1 4A C1 00 00 00 00 00 00 00 - 1669104436 (Nov 22 2022 09:07:16,1902042)
I tried this solutions:
https://stackoverflow.com/questions/1389046/what-is-the-specification-of-hexadecimal-date-format-in-sql-server Error: System.ArgumentOutOfRangeException (trying one of my hex)
http://erbhavi.blogspot.com/search/label/Converting%20DateTime%20to%20Hex%20in%20C%23 DateTime yourDateTime = new DateTime( ticks1970 + gmt * 10000000L ); //Error CS0019: Operator '*' can't apply to types 'string' y 'long'
I'll update the question if I find more info.

Why intermittent decryption errors on RSA Encrypted Block?

RSA Encryption/Decryption Error
I am having a problem with an RSA encryption algorithm. I have an app (APP1) on an embedded device. The device has
a proprietary (old) embedded OS. I have 1 RSA crypto function ("rsa_calc") that I am using. In APP1
it has the public key of an RSA Key Pair. My issue is periodically, some encryptions can't be decrypted
in the receiving application APP2 (modern application/os). I am using BP-TOOLS Crypto Calculator to verify
results. I have included the trace of 2 encryptions below. The first works, i.e. it can be decrypted using
BP-TOOLS Crypto Calculator. The Second cannot. The vast majority of encryptions verify, but every now and again
some do not.
The issue appears to be based on the input data to be encrypted. Taking my traces, I found a working value, and a
non-working value. And performed the encryptions. I get the same results. So basically encrypting some data works,
other not so much. Please see traces below.
This leads me to believe I am having some padding error. The RSA encrypt function does not document padding schemes.
I am not implementing any padding manually other than using a 128 byte buffer. On BP-TOOLS Crypto Calculator,
I am using "No Padding" on the decryption, it only seems to work when I select that.
If I select "PKCS1", I get padding errors when decrypting. There is no error decrypting the data on BP-TOOLS, I just
don't get clear text/original text.
I am not concerned about the strength of the encryption and not using padding etc. I am just trying to get this to
work consistently. Do I have to implement one of the padding schemes for RSA manually? Does padding make certain
RSA buffers impossible to decrypt (I wouldn't think so, I know it weakens the cipher, don't care)?
Can anyone see some other issue that may be causing my problem?
Thanks for the help
Function Documentation
rsa_calc()
Performs a public key RSA computation. It supports keys up to 2048 bits and exponent values of 2, 3, and 65537.
Prototype:
int rsa_calc(unsigned short * msg, unsigned short * mod, int wds, int exp, unsigned short * result);
Parameters:
msg - Array of unsigned 16-bit integers holding the input.
mod - Array of unsigned 16-bit integers holding the modulus. High bit must be set.
Typically an RSA modulus always has the most-significant bit set. This
implementation verifies and enforces that, because if the bit is not set, it
might cause unexpected behaviors. The high bit of the modulus is the MSB
of the first 16-bit integer of the array.
wds - Number of 16-bit unsigned shorts in msg and mod.
exp - Code for exponent: actual exponent is 2^exp+1. Acceptable values are 0, 1,
16 that correspond to exponents of 2,3, and 65537, respectively.
Return Values:
result Array of 16-bit integers holding the result on exit.
RSA Key Pair
MODULUS:
BEDB6B21E12D2B6EB590EC129FCC847EA4C00BE41CA530A5FA2CCDDE3B7DB3A0F50E6D3E348CD9258D7076973DD01FDC5B7E00F1F714F4E55C650DF88AAA293ED9376D2B0905F589108FB5C2835EA025D036F369891E5F5F3BA4F5E96CF25D164C1B26215B8D9627CDB95C22F00EBF50DF821A984E01309C1677B5D013E2BEEF
PUBLIC EXP(E):
010001
PRIVATE EXP(D):
A6898BC7FA5691C97EC1405D57F6FBBE0E404D9FF4A6E7F64C807FFAE4EA60AD9867C847394F95C340D1DB894934AC3879D54F39D3A203B78791DE48FBA65369B077BD6541AA8200392CA0BF56EEE2AA8478598852BFB537498095C087910176E1E90F92F8564F3012D7DC52B8D7145C40143F51229FE4416CEF50657511E2F1
TRACES
!!!! This Works !!!!
-------------------------
|*** RSAEncryptKey: rsa_calc :: ENTER
|MSG (256):
|0000 01 2A 9E 34 EA 19 63 07 F9 AD A8 9B 02 5B D6 6D - .*.4..c......[.m
|0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|rsa_calc: 0 ::
|rsa_calc result (256):
|0000 2D 0A F1 93 29 6A 47 D7 94 A6 16 32 E8 AD 2D 3B - -...)jG....2..-;
|0010 72 64 7B 23 55 79 1B 71 A1 34 AD E4 E5 E7 E6 FA - rd{#Uy.q.4......
|0020 6D 78 AA 6E 7F 32 D0 BF 26 87 3A 5F 8F B9 23 42 - mx.n2..&.:_..#B
|0030 C7 02 D6 8B 70 24 76 90 59 40 A3 42 D5 B5 2B 00 - ....p$v.Y#.B..+.
|0040 CB 08 A4 C3 07 E7 12 4D 02 C0 2D 3A 43 15 27 41 - .......M..-:C.'A
|0050 17 42 F7 B0 F8 B7 06 B1 25 D9 90 12 88 C1 05 16 - .B..............
|0060 75 64 8E 87 AA 68 82 96 1E 3E 23 F7 32 10 E5 8A - ud...h...>#.2...
|0070 17 D4 39 18 21 FC 5A C3 38 BB 7F CB DA B0 D2 85 - ..9.!.Z.8......
|0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|*** RSAEncryptKey: :: EXIT
!!!! DOES NOT DECRYPT !!!!
-------------------------------------
|*** RSAEncryptKey: rsa_calc :: ENTER
|MSG (256):
|0000 FA 68 E9 19 F5 D2 64 E0 F6 A8 FB 88 DC 67 35 C0 - .h....d......g5.
|0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|rsa_calc: 0 ::
|rsa_calc result (256):
|0000 36 B8 4D F2 76 DA 21 31 A3 8E C8 26 75 84 52 48 - 6.M.v.!1...&u.RH
|0010 3B CE 87 15 58 D9 F0 21 04 CE A0 83 9E 5E 58 31 - ;...X..!.....^X1
|0020 19 CF 82 70 00 BD A2 6D 2C E8 34 F4 27 D1 B2 4C - ...p...m,.4.'..L
|0030 1A F4 19 1D DA C4 B6 CD 10 C2 29 32 B6 85 E7 CB - ..........)2....
|0040 BD 4D 53 70 B3 27 47 B8 87 48 0C FD 86 B8 C0 4C - .MSp.'G..H.....L
|0050 B4 B8 23 4C 11 8C A7 93 41 2E AF E4 FF F1 EC 9A - ..#L....A.......
|0060 44 13 FF DB 9B ED B6 9E E2 2A 11 41 64 C5 2C E0 - D........*.Ad.,.
|0070 FE 4D 05 30 EE 49 9A 7A C5 46 BD 17 2F 87 72 D1 - .M.0.I.z.F../.r.
|0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|*** RSAEncryptKey: :: EXIT
Thank you President James K. Polk. Your comments resolved the issue. I wouldn't mind understanding better, so please comment if you can. It appears you are indicating that if I treat the first 16 bytes as a 16 byte integer, then the encryption block cannot be a larger integer than the Modulus, I don't really understand why. I don't really see the relationship between what I want to encrypt versus the key used to encrypt it.
However, shifting the 16 bytes in the encryption block (I shifted it 16 bytes). Every encryption/decryption appears to work (so far anyway).
Thank you for your help.

Backwards compatibility with sqlite DB

In my application I'm using an amalgamated embeded version of SQLite v3.8.4. In the past I had compatibility issues with v3.7 regarding page_size > 32768. Now I'd like to keep backwards compatibility on database files with v3.6.20 (default on RHEL6), but when I try to open my DB file on my RHEL6 machine I see the error:
Error: file is encrypted or is not a database
I can dump the database to an SQL file and then again import it to v3.7. This seems to do the trick to be readable on v3.6.20 but my DB is 3 GB in size and is not feasible for me to wait 2 hours for each dump.
What options can I set on my v3.8 to generate v3.6 compatible databases?
Databases dump
$ hexdump -C works-on-3.6.20.sqlite | head -n 8
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
00000010 04 00 01 01 00 40 20 20 00 00 00 01 00 2d 8c 51 |.....# .....-.Q|
00000020 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 01 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |................|
00000060 00 2d e2 21 05 00 00 00 02 03 f6 00 00 22 fd 07 |.-.!........."..|
00000070 03 fb 03 f6 01 8f 02 38 00 7c 01 61 81 62 07 07 |.......8.|.a.b..|
$ hexdump -C fails-on-3.6.20.sqlite | head -n 8
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
00000010 80 00 02 02 00 40 20 20 00 00 00 04 00 00 00 2b |.....# .......+|
00000020 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 01 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 |................|
00000060 00 2d e6 04 0d 7f fc 00 18 75 a4 00 7f 36 7f c9 |.-.......u...6..|
00000070 7e 6b 7f 0b 7d 8f 7e 38 7c 7e 7d 62 7b ab 7c 47 |~k..}.~8|~}b{.|G|
The non-working database has enabled WAL mode, which was introduced in version 3.7.0. Disable it.

Comparing two mach-o files

I have two mach-o files and i need to find the difference(hexadecimal differed values) in them. is there any tool available for doing this.
i tried using "DiffMerge" but it doesn't have the supported encoding format it seems.
how about:
hexdump binary1 > dump1.txt
hexdump binary2 > dump2.txt
diff dump1.txt dump2.txt
This will give you a diff file and you can use the offset in the first column in hexfiend or whatever your choice of editor is to investigate further.
2c2
< 0000010 21 00 00 00 bc 0f 00 00 85 00 20 00 01 00 00 00
---
> 0000010 20 00 00 00 84 0f 00 00 85 00 20 00 01 00 00 00
248,254c248,250
< 0000f80 0c 00 00 00 38 00 00 00 18 00 00 00 02 00 00 00
< 0000f90 00 00 01 00 00 00 01 00 40 65 78 65 63 75 74 61
< 0000fa0 62 6c 65 5f 70 61 74 68 2f 69 6e 6a 65 63 74 2e
< 0000fb0 64 79 6c 69 62 00 00 00 26 00 00 00 10 00 00 00
< 0000fc0 58 76 18 00 a4 23 00 00 1d 00 00 00 10 00 00 00
< 0000fd0 e0 09 19 00 60 37 00 00 00 00 00 00 00 00 00 00
< 0000fe0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
---
> 0000f80 26 00 00 00 10 00 00 00 58 76 18 00 a4 23 00 00
> 0000f90 1d 00 00 00 10 00 00 00 e0 09 19 00 60 37 00 00
> 0000fa0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Detecting exe 32/64bit

How do I manually [without any extra scripts/programs] see if a Windows executable is 32/64 bit?
I have been looking around and found what should have been my answer.
At 60 bytes in, the numbers below is suppose to appear, as far as I understand.
I386 0x014c
IA64 0x0200
AMD64 0x8664
Edit
After jumping to the PE offset, I still did not see the machine type. I did a Find & did not see any matches [unless its near the bottom for some reason].
64 86 06 00 is not in the list above, so I dont know what I am doing wrong.
Notepad.exe (64bit)
4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00
B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 E8 00 00 00
0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68
69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F
74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 20
6D 6F 64 65 2E 0D 0D 0A 24 00 00 00 00 00 00 00
83 C2 32 29 C7 A3 5C 7A C7 A3 5C 7A C7 A3 5C 7A
CE DB D8 7A C6 A3 5C 7A CE DB C9 7A C5 A3 5C 7A
CE DB CF 7A DA A3 5C 7A C7 A3 5D 7A 33 A3 5C 7A
CE DB DF 7A D3 A3 5C 7A CE DB D5 7A CC A3 5C 7A
CE DB C8 7A C6 A3 5C 7A CE DB CD 7A C6 A3 5C 7A
52 69 63 68 C7 A3 5C 7A 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 50 45 00 00 64 86 06 00 <--
B3 C9 5B 4A 00 00 00 00 00 00 00 00 F0 00 22 00
0B 02 09 00 00 A8 00 00 00 58 02 00 00 00 00 00
70 35 00 00 00 10 00 00 00 00 00 00 01 00 00 00
00 10 00 00 00 02 00 00 06 00 01 00 06 00 01 00
06 00 01 00 00 00 00 00 00 50 03 00 00 06 00 00
49 E7 03 00 02 00 40 81 00 00 08 00 00 00 00 00
00 10 01 00 00 00 00 00 00 00 10 00 00 00 00 00
00 10 00 00 00 00 00 00 00 00 00 00 10 00 00 00
00 00 00 00 00 00 00 00 F8 CF 00 00 2C 01 00 00
00 40 01 00 60 F1 01 00 00 30 01 00 B4 06 00 00
00 00 00 00 00 00 00 00 00 40 03 00 B8 00 00 00
10 B7 00 00 38 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 E0 02 00 00 38 01 00 00
00 C0 00 00 F0 07 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2E 74 65 78 74 00 00 00 70 A7 00 00 00 10 00 00
00 A8 00 00 00 06 00 00 00 00 00 00 00 00 00 00
What appears 60 bytes in isn't the machine type but the offset of the PE header. (In this case, 0x00000100: 256 bytes.) The PE header begins: 'P', 'E', 00, 00. What comes after that is the machine type.
OMG Figured it out. The code listing AMD64 0x86 64 matches "64 86". I never realized it was flipped.

Resources