Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motorola Basic Privacy compatibility. #50

Closed
travisgoodspeed opened this issue Mar 26, 2016 · 69 comments
Closed

Motorola Basic Privacy compatibility. #50

travisgoodspeed opened this issue Mar 26, 2016 · 69 comments

Comments

@travisgoodspeed
Copy link
Owner

Motorola's Basic Privacy can be made compatible with the MD380 by hooking aes_cipher() to return a motorola keystream. Close this issue when we can make (poorly) encrypted calls between Motorola and Tytera radios.

@travisgoodspeed travisgoodspeed self-assigned this Mar 26, 2016
@travisgoodspeed
Copy link
Owner Author

Pushed the first AES hook in c18f6dd. This prints first the Enhanced Privacy key, and then the keystream. Only the first 59 bits of the keystream are used.

@bilbolodz
Copy link

Current patch produce during compile a lot of warnings.

src/menu.c:34:15: warning: assignment makes pointer from integer without a cast
menustruct=((int)menu + 2);
[...]
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: warning: /tmp/ccOA0K43.o uses 2-byte wchar_t yet the output is to use 4-byte wchar_t; use of wchar_t values across objects may fail

@travisgoodspeed
Copy link
Owner Author

The menu warnings are easy to clean up, but the wchar_t warnings are more complicated. We need to compile to use two-byte wchar_t values, as that's why Tytera uses in their firmware, but the default compiler toolchains for ARM seem to all use four bytes.

We're being warned because while our code uses 2-byte wchars, the toolchain's libc still expects 4-byte wchars. Rather than warn us when the functions cross, it expects us to rebuild the whole toolchain, but that would cause trouble between those of us who don't enjoy compiler toolchains from scratch and whatever sick bastards do enjoy it.

There's no good way to clean that up without requiring folks to rebuild their toolchain, so for now, we're sort of stuck with it. Sorry.

@travisgoodspeed
Copy link
Owner Author

Now that I have some Motorola radios, I'll finish this off. Expect updates in the next week or two.

@countryboy14057
Copy link

Any update if the MD380 will decode Basic Privacy ?

@travisgoodspeed
Copy link
Owner Author

It will, but only after I spend a weekend coding it. All hardware is available and all protocols are understood, just a matter of implementing the code.

@travisgoodspeed
Copy link
Owner Author

This is an SMS of the word "Test" from 3147092 to 99. The first recording is encrypted with Basic Privacy Key 1, while the second is cleartext. The encrypted data bytes are predictably the same for this key.

SMS header:  08 6a 82 9a 00 00 63 30 05 54 86 00 18 3a
SMS header:  08 62 4f 10 01 00 00 00 00 00 00 00 03 b5
Data:        08 7a 5a 00 1f 2e 41 37 1f 00 1e 11 77 a1
Data:        08 72 13 30 1a 54 fe 00 1f 63 10 a7 10 a7
Data:        08 7a 1f 1a 1d 6e 1f 10 bf 00 8b 04 12 00
Data:        08 7a 15 00 4b 00 7a 00 6c 00 6b 00 00 00
Data:        08 72 00 00 00 00 00 00 00 00 ee 70 d0 53

SMS header:  08 62 82 4a 00 00 63 30 05 54 85 00 fe fc
Data:        08 7a 45 00 00 2e 5e 38 00 00 01 11 68 a0
Data:        08 72 0c 30 05 54 e1 00 00 63 0f a7 0f a7
Data:        08 72 00 1a 01 6e 00 10 a0 00 95 04 0d 00
Data:        08 7a 0a 00 54 00 65 00 73 00 74 00 00 00 -- 54657374=Test
Data:        08 7a 00 00 00 00 00 00 00 00 ef c9 b6 00

Here is the same SMS encrypted with Basic Privacy Key 2. Note that the header is identical to Key 1, but that the body differs. Also note that the null bytes retain their places, and aren't scrambled like the test bytes.

SMS header:  08 62 82 9a 00 00 63 30 05 54 86 00 18 3a
SMS header:  08 6a 4f 10 01 00 00 00 00 00 00 00 03 b5
Data:        08 72 a6 00 e3 2e 45 c2 e3 00 e2 11 c3 16
Data:        08 72 ef 30 e6 54 02 00 e3 63 ec a7 ec a7
Data:        08 72 e3 1a 19 6d e3 10 43 00 7f 04 ee 00
Data:        08 72 e9 00 b7 00 86 00 90 00 97 00 00 00
Data:        08 7a 00 00 00 00 00 00 00 00 1c 74 77 dc

Here is "Hello hello" encrypted with BP1 from 3147092 to 99. First clear, then encrypted. Note how "Hello" becomes "Wzssp" and "hello" becomes "wzssp".

SMS header:  08 62 82 48 00 00 63 30 05 54 86 00 6d c8
Data:        08 7a 45 00 00 3c 54 1d 00 00 01 11 72 ad
Data:        08 7a 0c 30 05 54 e1 00 00 63 0f a7 0f a7
Data:        08 7a 00 28 70 41 00 1e a0 00 9e 04 0d 00
Data:        08 7a 0a 00 48 00 65 00 6c 00 6c 00 6f 00 -- 48656c6c6f=Hello
Data:        08 72 20 00 68 00 65 00 6c 00 6c 00 6f 00 -- 68656c6c6f=hello
Data:        08 7a 00 00 00 00 00 00 00 00 62 63 5f bf

SMS header:  08 6a 82 98 00 00 63 30 05 54 87 00 ed 6c
SMS header:  08 6a 4f 10 01 00 00 00 00 00 00 00 03 b5
Data:        08 7a 5a 00 1f 3c 4b 1e 1f 00 1e 11 6d ac
Data:        08 72 13 30 1a 54 fe 00 1f 63 10 a7 10 a7
Data:        08 72 1f 28 70 41 1f 1e bf 00 80 04 12 00
Data:        08 72 15 00 57 00 7a 00 73 00 73 00 70 00 -- 577a737370=Wzssp
Data:        08 7a 3f 00 77 00 7a 00 73 00 73 00 70 00 -- 777a737370=wzssp
Data:        08 72 00 00 00 00 00 00 00 00 19 a5 08 09

@travisgoodspeed
Copy link
Owner Author

So text encryption for BP1 is XOR of the text with 0x1F, and encryption with BP2 is XOR with 0xE3. These bytes are conveniently exposed by XOR with a null byte on the third Data frame, so we don't need a lookup table to decrypt them.

@travisgoodspeed
Copy link
Owner Author

Given a key of 179 (0xB3), we get this pair for the "Hello hello" message:

SMS header:  08 62 82 48 00 00 63 30 05 54 86 00 6d c8
Data:        08 72 45 00 00 3c 7a 57 00 00 01 11 4c 73
Data:        08 7a 0c 30 05 54 e1 00 00 63 0f a7 0f a7
Data:        08 72 00 28 7d 41 00 1e a0 00 91 04 0d 00
Data:        08 7a 0a 00 48 00 65 00 6c 00 6c 00 6f 00
Data:        08 7a 20 00 68 00 65 00 6c 00 6c 00 6f 00
Data:        08 7a 00 00 00 00 00 00 00 00 86 ce 2d c2

SMS header:  08 6a 82 98 00 00 63 30 05 54 87 00 ed 6c
SMS header:  08 6a 4f 10 01 00 00 00 00 00 00 00 03 b5
Data:        08 72 99 b9 dc 85 a6 e1 dc b9 dd a8 90 cb
Data:        08 7a d0 89 d9 ed 3d b9 dc da d3 1e d3 1e
Data:        08 72 dc 91 a0 f8 dc a7 7c b9 4e bd d1 b9
Data:        08 72 d6 b9 94 b9 b9 b9 b0 b9 b0 b9 b3 b9
Data:        08 7a fc b9 b4 b9 b9 b9 b0 b9 b0 b9 b3 b9
Data:        08 72 00 00 00 00 00 00 00 00 1d 19 cd 95

Unlike B1 and B2, B179's XOR mask fills both bytes. The easiest place to find the mask is from the first line of Data, where 00 00 is XORed to become b9 dc.

@janipewter
Copy link

Any update on this?

@travisgoodspeed
Copy link
Owner Author

It's a low priority, but I'll get around to it soon enough.

@janipewter
Copy link

Great. It would actually be incredible!

@cryptonomicon
Copy link

IDK if this will help you make moto BP work with Tytera EP, but here are some of the outputs from Moto BP keys. Maybe you can see if you can match this to a Tytera:

Moto BP key# / 16 bit key/ First BP voice frame:

1/ 1F00 / e701b69f93e080
2/ E300 / 1b014a9f6fe000
3/ FC00 / 0401559f70e000
4/ 2503 / dd028c9ca9e380
5/ 3A03 / c202939cb6e380
6/ C603 / 3e026f9c4ae300
7/ D903 / 2102709c55e300
8/ 4A05 / b204e39ac6e580
9/ 5505 / ad04fc9ad9e580
10/ A905 / 5104009a25e500

@cryptonomicon
Copy link

11- b605
12- 6f06
13- 7006
14- 8c06
15- 9306
16- 2618
17- 3918
18- c518
19- da18
20- 031b
21- 1c1b
22- e018
23- ff1b
24- 6c1d
25- 731d
26- 8f1d
27- 901d
28- 491e
29- 561e
30- aa1e

No need to scan through all 255 privacy codes.
It's a very simple system that is a low level privacy scheme. I tested these above keys with the results of my XPR 6550 and confirm them.

Did they ever release the AMBE2 USB frame dump code for the 380? You might be able to test that way?
Not sure what's available on a hobby level but you have to look at the data or voice frames.

I took a look at the 380 a bit ago and as far as compatibility for this my results were mixed/below average on intelligibility.

@countryboy14057
Copy link

I'd be willing to offer a donation to get this working since some places around here are using it. Or even better I'd offer a donation to have someone add BP decryption into DSDPlus

@countryboy14057
Copy link

No but I am sure someone out there can add it in pretty quickly. I wish I had gone for CS instead of System Admin somedays.

@d235j
Copy link
Collaborator

d235j commented Jul 28, 2016

DSDPlus is a closed-source fork of DSD and only the maintainers of it can add functionality.

@countryboy14057
Copy link

is DSD open sourced tho ?

@d235j
Copy link
Collaborator

d235j commented Aug 1, 2016

DSD is open source, DSDPlus is not. I'm rather disappointed that DSDPlus took DSD and made it a closed-source proprietary product, but there's not much I can do about that.

@g738l
Copy link

g738l commented Sep 6, 2016

I would like to ask if anyone would put Moto BP key 77 in the format as "Cryptonomicon"
thank you very much

@g738l
Copy link

g738l commented Sep 6, 2016

Thanks for the answer, I'll have to buy a Motorola :-)

@SatSearching
Copy link

Any chance some work can be done on this please?

Not wanting a blatant hack solution, but just compatibility for BP on the md380 to Mototrbo BP would be a very cool feature.

@Moto117
Copy link

Moto117 commented Sep 9, 2016

Hey guys... .thought I would throw help you out a little with this, would be nice to see BP working in the 380.

1 1F00
2 E300
3 FC00
4 2503
5 3A03
6 C603
7 D903
8 4A05
9 5505
10 A905
11 B605
12 6F06
13 7006
14 8C06
15 9306
16 2618
17 3918
18 C518
19 DA18
20 031B
21 1C1B
22 E01B
23 FF1B
24 6C1D
25 731D
26 8F1D
27 901D
28 491E
29 561E
30 AA1E
31 B51E
32 4B28
33 5428
34 A828
35 B728
36 6E2B
37 712B
38 8D2B
39 922B
40 012D
41 1E2D
42 E22D
43 FD2D
44 242E
45 3B2E
46 C72E
47 D82E
48 6D30
49 7230
50 8E30
51 9130
52 4833
53 5733
54 AB33
55 B433
56 2735
57 3835
58 C435
59 DB35
60 0236
61 1D36
62 E136
63 FE36
64 2B49
65 3449
66 C849
67 D749
68 0E4A
69 114A
70 ED4A
71 F24A
72 614C
73 AE4C
74 824C
75 9D4C
76 444F
77 5B4F
78 A74F
79 B84F
80 0D51
81 1251
82 EE51
83 F151
84 2852
85 3752
86 CB52
87 D452
88 4754
89 5854
90 A454
91 BB54
92 6257
93 7D57
94 8157
95 9E57
96 6061
97 7F61
98 8361
99 9C61
100 4562
101 5A62
102 A662
103 B962
104 2A64
105 3564
106 C964
107 D664
108 0F67
109 1067
110 EC67
111 F367
112 4679
113 5979
114 A579
115 BA79
116 637A
117 7C7A
118 807A
119 9F7A
120 0C7C
121 137C
122 EF7C
123 F07C
124 297F
125 367F
126 CA7F
127 D57F
128 4D89
129 5289
130 AE89
131 B189
132 688A
133 778A
134 8B8A
135 948A
136 078C
137 188C
138 E48C
139 FB8C
140 228F
141 3D8F
142 C18F
143 DE8F
144 6B91
145 7491
146 8891
147 9791
148 4E92
149 5192
150 AD92
151 B292
152 2194
153 3E94
154 C294
155 DD94
156 0497
157 1B97
158 E797
159 F897
160 06A1
161 19A1
162 E5A1
163 FAA1
164 23A2
165 3CA2
166 C0A2
167 DFA2
168 4CA4
169 53A4
170 AFA4
171 B0A4
172 69A7
173 76A7
174 8AA7
175 95A7
176 20B9
177 3FB9
178 C3B9
179 DCB9
180 05BA
181 1ABA
182 E6BA
183 F9BA
184 6ABC
185 75BC
186 89BC
187 96BC
188 4FBF
189 50BF
190 ACBF
191 B3BF
192 66C0
193 79C0
194 85C0
195 9AC0
196 43C3
197 5CC3
198 A0C3
199 BFC3
200 2CC5
201 33C5
202 CFC5
203 D0C5
204 09C6
205 16C6
206 EAC6
207 F5C6
208 84D0
209 85DF
210 8AD3
211 8BDC
212 B6D5
213 B7DA
214 B8D6
215 B9D9
216 D0DA
217 D1D5
218 DED9
219 DFD6
220 E2DF
221 E3D0
222 ECDC
223 EDD3
224 2DE8
225 32E8
226 CEE8
227 D1E8
228 08EB
229 17EB
230 EBEB
231 F4EB
232 67ED
233 78ED
234 84ED
235 9BED
236 42EE
237 5DEE
238 A1EE
239 BEEE
240 0BF0
241 14F0
242 E8F0
243 F7F0
244 2EF3
245 31F3
246 CDF3
247 D2F3
248 41F5
249 5EF5
250 A2F5
251 BDF5
252 64F6
253 7BF6
254 87F6
255 98F6

@ghost

This comment has been minimized.

@cryptonomicon
Copy link

DMR plaintext voice frame is:
F8 01 A9 9F 8C E0 80

Apply BP mask to pt and compare that to what the MD 380 EP outputs and look for a match.

@SatSearching
Copy link

Great that some have posted the 256 privacy codes to help, but is there any plans to work on compatibility of BP for MD380 please?

Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Repository owner deleted a comment Sep 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests