-
Notifications
You must be signed in to change notification settings - Fork 16
/
module-emulator-powervu.c
3053 lines (2575 loc) · 78.5 KB
/
module-emulator-powervu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define MODULE_LOG_PREFIX "emu"
#include "globals.h"
#ifdef WITH_EMU
#include "cscrypt/des.h"
#include "module-streamrelay.h"
#include "module-emulator-nemu.h"
#include "module-emulator-powervu.h"
#include "ncam-string.h"
#include "ncam-time.h"
#ifdef WITH_LIBCURL
#include "ncam-files.h"
#include <curl/curl.h>
#define RECONNECT 5 // for invalid or expired keys, reconnect to the server side after these minutes
static uint8_t github(struct pvu_reader *pvu)
{
int8_t ret = 0;
time_t secs = RECONNECT * 60;
int32_t rdr = (uintptr_t)pvu->rdr / 16 % CS_CLIENT_HASHBUCKETS;
if(time(NULL) - pvu->startTime[rdr] < secs) { return 0; }
CURL *curl_handle;
struct MemoryStruct chunk;
chunk.memory = malloc(1); // will be grown as needed by the realloc above
chunk.size = 0; // no data at this point
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init(); // init the curl session
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); // send all data to this function
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk); // we pass our 'chunk' struct to the callback function
char url[90] = "https://raw.githubusercontent.com/";
cs_strncpy(url + cs_strlen(url), pvu->rdr->label + 7, sizeof(url));
if(curl(curl_handle, url))
{
int i;
unsigned int keyIndex, buf[7];
uint8_t ok[2];
memset(ok, 0, sizeof(ok));
cs_log("Find and download keys: %s", url);
//cs_log_dbg(D_ATR|D_READER,"Find and download keys: %s", url);
for(i = 0; i < (long)chunk.size; i++)
{
if((strncmp(chunk.memory + i, "P 00090066", 10) == 0) || (strncmp(chunk.memory + i, "P 0009FFFF", 10) == 0))
{
i += 11;
if(chunk.memory[i] == '0' && (chunk.memory[i + 1] == '0' || chunk.memory[i + 1] == '1') && (chunk.memory[i + 2] == ' ' || chunk.memory[i + 2] == ':'))
{
sscanf(chunk.memory + i, "%02X", &keyIndex);
i += 2;
if(sscanf(chunk.memory + i, "%02X%02X%02X%02X%02X%02X%02X",
&buf[0], &buf[1], &buf[2], &buf[3], &buf[4], &buf[5], &buf[6]) == 7)
{
i += 7;
ok[keyIndex] = 1;
ret = 1;
pvu->key[keyIndex][0] = buf[0];
pvu->key[keyIndex][1] = buf[1];
pvu->key[keyIndex][2] = buf[2];
pvu->key[keyIndex][3] = buf[3];
pvu->key[keyIndex][4] = buf[4];
pvu->key[keyIndex][5] = buf[5];
pvu->key[keyIndex][6] = buf[6];
//cs_log_dbg(D_ATR|D_READER, Found keys: P 0%d %02X%02X%02X%02X%02X%02X%02X", keyIndex, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
}
}
}
}
if(ret && ok[0] && ok[1])
{
for(i = 0; i < 2; i++)
{
cs_log("Key loaded: P 0%d %02X%02X%02X%02X%02X%02X%02X", i, pvu->key[i][0], pvu->key[i][1], pvu->key[i][2], pvu->key[i][3], pvu->key[i][4], pvu->key[i][5], pvu->key[i][6]);
//cs_log_dbg(D_ATR|D_READER, "Key loaded: P 0%d %02X%02X%02X%02X%02X%02X%02X", i, pvu->key[i][0], pvu->key[i][1], pvu->key[i][2], pvu->key[i][3], pvu->key[i][4], pvu->key[i][5], pvu->key[i][6]);
}
}
else { ret = 0; }
}
curl_easy_cleanup(curl_handle); // cleanup curl stuff
if(chunk.memory) { NULLFREE(chunk.memory); }
curl_global_cleanup(); // we're done with libcurl, so clean it up
pvu->startTime[rdr] = time(NULL);
return ret;
}
static uint8_t linuxsat(struct pvu_reader *pvu)
{
int8_t ret = 0;
time_t secs = RECONNECT * 60;
int32_t rdr = (uintptr_t)pvu->rdr / 16 % CS_CLIENT_HASHBUCKETS;
if(time(NULL) - pvu->startTime[rdr] < secs) { return 0; }
CURL *curl_handle;
struct MemoryStruct chunk;
chunk.memory = malloc(1); // will be grown as needed by the realloc above
chunk.size = 0; // no data at this point
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init(); // init the curl session
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); // send all data to this function
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk); // we pass our 'chunk' struct to the callback function
char url[80] = "https://www.linuxsat-support.com/thread/152939";
if(pvu->rdr->label[20] == ':')
{
snprintf(url + 40, sizeof(url) - 40, "%s", pvu->rdr->label + 21);
int e;
for(e = 40; e < (int)strlen(url); e++)
{
if(url[e] == '-')
{
url[e] = 0;
break;
}
}
}
size_t url_len = strlen(url);
if(curl(curl_handle, url))
{
int i;
int32_t page = 0;
for(i = 0; i < (long)chunk.size; i++)
{
if(strncmp(chunk.memory + i, "data-pages=""\"", 12) == 0)
{
page = atoi(chunk.memory + i + 12);
//cs_log_dbg(D_ATR|D_READER, "Page: %d", page);
break;
}
}
int32_t p;
unsigned int keyIndex, buf[7];
char ubuf[3][50];
uint8_t step = 0, ok[2];
memset(ok, 0, sizeof(ok));
for(p = 0; p <= 1; p++)
{
if(page != 0) { snprintf(url + url_len, 10 + 3, "/?pageNo=%d", page - p); }
if(p == 1) { p = -1; }
cs_log("Find and download keys: %s", url);
*chunk.memory = 0;
chunk.size = 0;
step++;
if(curl(curl_handle, url))
{
for(i = 0; i < (long)chunk.size; i++)
{
if(strncmp(chunk.memory + i, "title=""\"Posts by ", 16) == 0)
{
memcpy(ubuf[2],chunk.memory + i + 16, sizeof(ubuf[2]));
uint8_t u;
for(u = 0; u < sizeof(ubuf[2]); u++)
{
if(ubuf[2][u] == '"')
{
ubuf[2][u] = 0;
break;
}
}
}
if(strncmp(chunk.memory + i, "<div class=""\"messageText""\">", 25) == 0)
{
i += 25;
for(; i < (long)chunk.size; i++)
{
if(chunk.memory[i] == '0' && (chunk.memory[i + 1] == '0' || chunk.memory[i + 1] == '1') && (chunk.memory[i + 2] == ' ' || chunk.memory[i + 2] == ':'))
{
sscanf(chunk.memory + i, "%02X", &keyIndex);
i += 2;
for(; i < (long)chunk.size; i++)
{
if(sscanf(chunk.memory + i, "%02X%02X%02X%02X%02X%02X%02X",
&buf[0], &buf[1], &buf[2], &buf[3], &buf[4], &buf[5], &buf[6]) == 7)
{
i += 7;
ok[keyIndex] = 1;
ret = 1;
pvu->key[keyIndex][0] = buf[0];
pvu->key[keyIndex][1] = buf[1];
pvu->key[keyIndex][2] = buf[2];
pvu->key[keyIndex][3] = buf[3];
pvu->key[keyIndex][4] = buf[4];
pvu->key[keyIndex][5] = buf[5];
pvu->key[keyIndex][6] = buf[6];
cs_strncpy(ubuf[keyIndex], ubuf[2], sizeof(ubuf[2]));
//cs_log_dbg(D_ATR|D_READER, Found keys: P 0%d %02X%02X%02X%02X%02X%02X%02X ### Thanks to %s ###", keyIndex, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], ubuf[2]);
break;
}
if(strncmp(chunk.memory + i, "</div>", 5) == 0) { break; }
}
if(strncmp(chunk.memory + i, "</div>", 5) == 0) { break; }
}
if(strncmp(chunk.memory + i, "</div>", 5) == 0) { break; }
}
}
}
}
if(ret && ok[0] && ok[1])
{
for(i = 0; i < 2; i++) { cs_log("Key loaded: P 0%d %02X%02X%02X%02X%02X%02X%02X ### Thanks to %s ###", i, pvu->key[i][0], pvu->key[i][1], pvu->key[i][2], pvu->key[i][3], pvu->key[i][4], pvu->key[i][5], pvu->key[i][6], ubuf[i]); }
if(p == 0) { break; }
}
else if(page != 0) { ret = 0; }
if(page == 0 || step > 2) { break; }
}
}
curl_easy_cleanup(curl_handle); // cleanup curl stuff
if(chunk.memory) { NULLFREE(chunk.memory); }
curl_global_cleanup(); // we're done with libcurl, so clean it up
pvu->startTime[rdr] = time(NULL);
return ret;
}
static uint8_t search_keys(struct pvu_reader *pvu, uint16_t ecmSrvid)
{
int8_t ret = -1;
if((ecmSrvid >= 102 && ecmSrvid <= 109) || (ecmSrvid >= 120 && ecmSrvid <= 148) || // Eutelsat 9B at 9.0°E & SES 5 at 5.0°E & Galaxy 16 at 99.0°W
(ecmSrvid >= 203 && ecmSrvid <= 204) || // NSS 9 at 177.0°W
(ecmSrvid >= 302 && ecmSrvid <= 305) || // NSS 12 at 57.0°E & Intelsat 35e at 34.5°W & Intelsat 14 at 45.0°W
(ecmSrvid >= 1 && ecmSrvid <= 9)) // Koreasat 5A at 113.0°E
{ ret = 0; }
if(ret == -1) return 0;
if(strncmp(pvu->rdr->label, "linuxsat-support.com", 20) == 0) { ret = linuxsat(pvu); }
else if(strncmp(pvu->rdr->label, "github:", 7) == 0) { ret = github(pvu); }
else { ret = 0; }
return ret;
}
#endif
static inline uint8_t get_bit(uint8_t byte, uint8_t bitnb)
{
return ((byte & (1 << bitnb)) ? 1 : 0);
}
static inline uint8_t set_bit(uint8_t val, uint8_t bitnb, uint8_t biton)
{
return (biton ? (val | (1 << bitnb)) : (val & ~(1 << bitnb)));
}
static uint8_t crc8_calc(uint8_t *data, int len)
{
int i;
uint8_t crc = 0;
uint8_t crcTable[256] =
{
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
};
for (i = 0; i < len; i++)
{
crc = crcTable[data[i] ^ crc];
}
return crc;
}
static void pad_data(uint8_t *data, int len, uint8_t *dataPadded)
{
int i;
uint8_t pad[] =
{
0x01, 0x02, 0x22, 0x04, 0x20, 0x2A, 0x1F, 0x03,
0x04, 0x06, 0x02, 0x0C, 0x2B, 0x2B, 0x01, 0x7B
};
for (i = 0; i < len; i++)
{
dataPadded[i] = data[i];
}
dataPadded[len] = 0x01;
for (i = len + 1; i < 0x2F; i++)
{
dataPadded[i] = 0x00;
}
dataPadded[0x2F] = len;
for (i = 0; i < 16; i++)
{
dataPadded[0x30 + i] = pad[i];
}
}
static void hash_mode_01_custom_md5(uint8_t *data, uint8_t *hash)
{
int i, j, s;
uint32_t a, b, c, d, f = 0, g;
uint32_t T[] =
{
0x783E16F6, 0xC267AC13, 0xA2B17F12, 0x6B8A31A4,
0xF910654D, 0xB702DBCB, 0x266CEF60, 0x5145E47C,
0xB92E00D6, 0xE80A4A64, 0x8A07FA77, 0xBA7D89A9,
0xEBED8022, 0x653AAF2B, 0xF118B03B, 0x6CC16544,
0x96EB6583, 0xF4E27E35, 0x1ABB119E, 0x068D3EF2,
0xDAEAA8A5, 0x3C312A3D, 0x59538388, 0xA100772F,
0xAB0165CE, 0x979959E7, 0x5DD8F53D, 0x189662BA,
0xFD021A9C, 0x6BC2D338, 0x1EFF667E, 0x40C66888,
0x6E9F07FF, 0x0CEF442F, 0x82D20190, 0x4E8CAEAC,
0x0F7CB305, 0x2E73FBE7, 0x1CE884A2, 0x7A60BD52,
0xC348B30D, 0x081CE3AA, 0xA12220E7, 0x38C7EC79,
0xCBD8DD3A, 0x62B4FBA5, 0xAD2A63DB, 0xE4D0852E,
0x53DE980F, 0x9C8DDA59, 0xA6B4CEDE, 0xB48A7692,
0x0E2C46A4, 0xEB9367CB, 0x165D72EE, 0x75532B45,
0xB9CA8E97, 0x08C8837B, 0x966F917B, 0x527515B4,
0xF27A5E5D, 0xB71E6267, 0x7603D7E6, 0x9837DD69
}; // CUSTOM T
uint8_t r[] =
{
0x06, 0x0A, 0x0F, 0x15, 0x05, 0x09, 0x0E, 0x14,
0x04, 0x0B, 0x10, 0x17, 0x07, 0x0C, 0x11, 0x16
}; // STANDARD REORDERED
uint8_t tIdxInit[] = { 0, 1, 5, 0 }; // STANDARD
uint8_t tIdxIncr[] = { 1, 5, 3, 7 }; // STANDARD
uint32_t h[] = { 0xEAD81D2E, 0xCE4DC6E9, 0xF9B5C301, 0x10325476 }; // CUSTOM h0, h1, h2, STANDARD h3
uint32_t dataLongs[16];
for (i = 0; i < 16; i++)
{
dataLongs[i] = (data[4 * i + 0] << 0) + (data[4 * i + 1] << 8) +
(data[4 * i + 2] << 16) + (data[4 * i + 3] << 24);
}
a = h[0];
b = h[1];
c = h[2];
d = h[3];
for (i = 0; i < 4; i++)
{
g = tIdxInit[i];
for (j = 0; j < 16; j++)
{
if (i == 0)
{
f = (b & c) | (~b & d);
}
else if (i == 1)
{
f = (b & d) | (~d & c);
}
else if (i == 2)
{
f = (b ^ c ^ d);
}
else if (i == 3)
{
f = (~d | b) ^ c;
}
f = dataLongs[g] + a + T[16 * i + j] + f;
s = r[4 * i + (j & 3)];
f = (f << s) | (f >> (32 - s));
a = d;
d = c;
c = b;
b += f;
g = (g + tIdxIncr[i]) & 0xF;
}
}
h[0] += a;
h[1] += b;
h[2] += c;
h[3] += d;
for (i = 0; i < 4; i++)
{
hash[4 * i + 0] = h[i] >> 0;
hash[4 * i + 1] = h[i] >> 8;
hash[4 * i + 2] = h[i] >> 16;
hash[4 * i + 3] = h[i] >> 24;
}
}
static void hash_mode_02(uint8_t *data, uint8_t *hash)
{
int i;
uint32_t a, b, c, d, e, f = 0, tmp;
uint32_t h[] = { 0x81887F3A, 0x36CCA480, 0x99056FB1, 0x79705BAE };
uint32_t dataLongs[80];
for (i = 0; i < 16; i++)
{
dataLongs[i] = (data[4 * i + 0] << 24) + (data[4 * i + 1] << 16) +
(data[4 * i + 2] << 8) + (data[4 * i + 3] << 0);
}
for (i = 0; i < 64; i++)
{
dataLongs[16 + i] = dataLongs[16 + i - 2];
dataLongs[16 + i] ^= dataLongs[16 + i - 7];
dataLongs[16 + i] ^= dataLongs[16 + i - 13];
dataLongs[16 + i] ^= dataLongs[16 + i - 16];
}
a = dataLongs[0];
b = dataLongs[1];
c = dataLongs[2];
d = dataLongs[3];
e = dataLongs[4];
for (i = 0; i < 80; i++)
{
if (i < 0x15) f = (b & c) | (~b & d);
else if (i < 0x28) f = (b ^ c ^ d);
else if (i < 0x3D) f = (b & c) | (c & d) | (b & d);
else if (i < 0x50) f = (b ^ c ^ d);
tmp = a;
a = e + f + (a << 5) + (a >> 27) + h[i / 0x14] + dataLongs[i];
e = d;
d = c;
c = (b << 30) + (b >> 2);
b = tmp;
}
dataLongs[0] += a;
dataLongs[1] += b;
dataLongs[2] += c;
dataLongs[3] += d;
for (i = 0; i < 4; i++)
{
hash[4 * i + 0] = dataLongs[i] >> 24;
hash[4 * i + 1] = dataLongs[i] >> 16;
hash[4 * i + 2] = dataLongs[i] >> 8;
hash[4 * i + 3] = dataLongs[i] >> 0;
}
}
static void hash_mode_03(uint8_t *data, uint8_t *hash)
{
int i, j, k, s, s2, tmp;
uint32_t a, b, c, d, f = 0, g;
uint32_t a2, b2, c2, d2, f2 = 0, g2;
uint32_t T[] = { 0xC88F3F2E, 0x967506BA, 0xDA877A7B, 0x0DECCDFE };
uint32_t T2[] = { 0x01F42668, 0x39C7CDA5, 0xD490E2FE, 0x9965235D };
uint8_t r[] =
{
0x0B, 0x0E, 0x0F, 0x0C, 0x05, 0x08, 0x07, 0x09,
0x0B, 0x0D, 0x0E, 0x0F, 0x06, 0x07, 0x09, 0x08,
0x07, 0x06, 0x08, 0x0D, 0x0B, 0x09, 0x07, 0x0F,
0x07, 0x0C, 0x0F, 0x09, 0x0B, 0x07, 0x0D, 0x0C
};
uint8_t tIdxIncr[] =
{
0x07, 0x04, 0x0D, 0x01, 0x0A, 0x06, 0x0F, 0x03,
0x0C, 0x00, 0x09, 0x05, 0x02, 0x0E, 0x0B, 0x08,
0x05, 0x0D, 0x02, 0x00, 0x04, 0x09, 0x03, 0x08,
0x01, 0x0A, 0x07, 0x0B, 0x06, 0x0F, 0x0C, 0x0E
};
uint32_t h[] = { 0xC8616857, 0x9D3F5B8E, 0x4D7B8F76, 0x97BC8D80 };
uint32_t dataLongs[80];
uint32_t result[4];
for (i = 0; i < 16; i++)
{
dataLongs[i] = (data[4 * i + 0] << 24) + (data[4 * i + 1] << 16) +
(data[4 * i + 2] << 8) + (data[4 * i + 3] << 0);
}
a = h[0];
b = h[1];
c = h[2];
d = h[3];
a2 = h[3];
b2 = h[2];
c2 = h[1];
d2 = h[0];
for (i = 0; i < 4; i++)
{
for (j = 0; j < 16; j++)
{
tmp = j;
for (k = 0; k < i; k++)
{
tmp = tIdxIncr[tmp];
}
g = 0x0F - tmp;
g2 = tmp;
if (i == 0) f = (b & d) | (~d & c);
else if (i == 1) f = (~c | b) ^ d;
else if (i == 2) f = (~b & d) | (b & c);
else if (i == 3) f = (b ^ c ^ d);
if (i == 0) f2 = (b2 ^ c2 ^ d2);
else if (i == 1) f2 = (~b2 & d2) | (b2 & c2);
else if (i == 2) f2 = (~c2 | b2) ^ d2;
else if (i == 3) f2 = (b2 & d2) | (~d2 & c2);
f = dataLongs[g] + a + T[i] + f;
s = r[0x0F + (((i & 1) ^ 1) << 4) - j];
f = (f << s) | (f >> (32 - s));
f2 = dataLongs[g2] + a2 + T2[i] + f2;
s2 = r[((i & 1) << 4) + j];
f2 = (f2 << s2) | (f2 >> (32 - s2));
a = d;
d = (c << 10) | (c >> 22);
c = b;
b = f;
a2 = d2;
d2 = (c2 << 10) | (c2 >> 22);
c2 = b2;
b2 = f2;
}
}
result[0] = h[3] + b + a2;
result[1] = h[2] + c + b2;
result[2] = h[1] + d + c2;
result[3] = h[0] + a + d2;
for (i = 0; i < 4; i++)
{
hash[4 * i + 0] = result[i] >> 0;
hash[4 * i + 1] = result[i] >> 8;
hash[4 * i + 2] = result[i] >> 16;
hash[4 * i + 3] = result[i] >> 24;
}
}
static const uint8_t table04[] =
{
0x02, 0x03, 0x07, 0x0B, 0x0D, 0x08, 0x00, 0x01, 0x2B, 0x2D, 0x28, 0x20, 0x21, 0x0A, 0x0C, 0x0E,
0x22, 0x36, 0x23, 0x27, 0x29, 0x24, 0x25, 0x26, 0x2A, 0x3C, 0x3E, 0x3F, 0x0F, 0x2C, 0x2E, 0x2F,
0x12, 0x13, 0x17, 0x1B, 0x1C, 0x18, 0x10, 0x11, 0x19, 0x14, 0x15, 0x16, 0x1A, 0x09, 0x04, 0x05,
0x32, 0x33, 0x37, 0x3B, 0x06, 0x1C, 0x1E, 0x1F, 0x3D, 0x38, 0x30, 0x31, 0x39, 0x34, 0x35, 0x3A
};
static const uint8_t table05[] =
{
0x08, 0x09, 0x0A, 0x03, 0x04, 0x3F, 0x27, 0x28, 0x29, 0x2A, 0x05, 0x0B, 0x1B, 0x1C, 0x1C, 0x1E,
0x20, 0x0C, 0x0D, 0x22, 0x23, 0x24, 0x00, 0x01, 0x02, 0x06, 0x07, 0x25, 0x26, 0x0E, 0x0F, 0x21,
0x10, 0x11, 0x12, 0x2E, 0x2F, 0x13, 0x14, 0x15, 0x2B, 0x2C, 0x2D, 0x16, 0x17, 0x18, 0x19, 0x1A,
0x30, 0x31, 0x37, 0x3B, 0x3C, 0x3D, 0x3E, 0x1F, 0x38, 0x39, 0x32, 0x33, 0x34, 0x35, 0x36, 0x3A
};
static const uint8_t table06[] =
{
0x00, 0x01, 0x02, 0x06, 0x07, 0x08, 0x03, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x04, 0x05, 0x09, 0x0D,
0x20, 0x21, 0x22, 0x26, 0x27, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x10, 0x11, 0x12, 0x16, 0x17, 0x28,
0x18, 0x13, 0x14, 0x15, 0x19, 0x1C, 0x1A, 0x1B, 0x1C, 0x1E, 0x1F, 0x23, 0x24, 0x25, 0x29, 0x2D,
0x30, 0x31, 0x32, 0x36, 0x37, 0x38, 0x33, 0x34, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x35, 0x39, 0x3D
};
static const uint8_t table07[] =
{
0x10, 0x11, 0x12, 0x17, 0x1C, 0x1E, 0x0E, 0x38, 0x39, 0x3A, 0x13, 0x14, 0x29, 0x2A, 0x16, 0x1F,
0x00, 0x01, 0x02, 0x3C, 0x3D, 0x3E, 0x3F, 0x07, 0x08, 0x09, 0x03, 0x04, 0x05, 0x06, 0x3B, 0x0A,
0x20, 0x21, 0x22, 0x19, 0x1A, 0x1B, 0x1C, 0x0B, 0x0C, 0x15, 0x23, 0x24, 0x25, 0x26, 0x18, 0x0F,
0x30, 0x31, 0x2B, 0x33, 0x34, 0x35, 0x36, 0x37, 0x27, 0x28, 0x2C, 0x2D, 0x2E, 0x2F, 0x32, 0x0D
};
static const uint8_t table08[] =
{
0x10, 0x11, 0x1E, 0x17, 0x18, 0x19, 0x12, 0x13, 0x14, 0x1C, 0x1C, 0x15, 0x0D, 0x05, 0x06, 0x0A,
0x00, 0x01, 0x0E, 0x07, 0x08, 0x09, 0x02, 0x2D, 0x25, 0x26, 0x2A, 0x2B, 0x2F, 0x03, 0x04, 0x0C,
0x20, 0x21, 0x2E, 0x27, 0x28, 0x29, 0x30, 0x31, 0x3E, 0x37, 0x38, 0x39, 0x22, 0x23, 0x24, 0x2C,
0x32, 0x33, 0x34, 0x3C, 0x3D, 0x35, 0x36, 0x3A, 0x3B, 0x0B, 0x0F, 0x16, 0x1A, 0x1B, 0x1F, 0x3F
};
static const uint8_t table09[] =
{
0x20, 0x21, 0x24, 0x22, 0x23, 0x2A, 0x2B, 0x33, 0x35, 0x38, 0x39, 0x36, 0x2D, 0x2C, 0x2E, 0x2F,
0x00, 0x01, 0x04, 0x02, 0x25, 0x28, 0x08, 0x09, 0x06, 0x07, 0x0A, 0x0B, 0x0D, 0x0C, 0x0E, 0x0F,
0x10, 0x11, 0x14, 0x12, 0x13, 0x15, 0x19, 0x16, 0x29, 0x26, 0x03, 0x17, 0x1A, 0x1C, 0x1C, 0x1E,
0x30, 0x31, 0x34, 0x32, 0x37, 0x3A, 0x3B, 0x3D, 0x3C, 0x3E, 0x3F, 0x1B, 0x05, 0x18, 0x27, 0x1F
};
static const uint8_t table0A[] =
{
0x00, 0x04, 0x05, 0x0B, 0x0C, 0x06, 0x09, 0x0A, 0x0E, 0x0D, 0x0F, 0x25, 0x15, 0x1B, 0x1C, 0x16,
0x10, 0x11, 0x01, 0x02, 0x03, 0x07, 0x08, 0x12, 0x13, 0x17, 0x18, 0x14, 0x23, 0x27, 0x28, 0x24,
0x30, 0x31, 0x32, 0x33, 0x37, 0x38, 0x34, 0x35, 0x3B, 0x3C, 0x20, 0x21, 0x22, 0x2B, 0x2C, 0x26,
0x36, 0x39, 0x3A, 0x3E, 0x3D, 0x19, 0x1A, 0x1E, 0x1C, 0x1F, 0x3F, 0x29, 0x2A, 0x2E, 0x2D, 0x2F
};
static void hash_modes_04_to_0A_tables(uint8_t *data, uint8_t *hash, const uint8_t *table)
{
int i;
for (i = 0; i < 16; i++)
{
hash[i] = table[i];
hash[i] ^= data[table[i]];
hash[i] ^= table[16 + i];
hash[i] ^= data[table[16 + i]];
hash[i] ^= table[32 + i];
hash[i] ^= data[table[32 + i]];
hash[i] ^= table[48 + i];
hash[i] ^= data[table[48 + i]];
}
}
static const uint8_t table0F[] = { 0xC7, 0x45, 0x15, 0x71, 0x61, 0x07, 0x05, 0x47 };
static const uint8_t table10[] = { 0x0F, 0x47, 0x2B, 0x6C, 0xAD, 0x0F, 0xB3, 0xEA };
static const uint8_t table11[] = { 0xB1, 0x46, 0xD1, 0x66, 0x5D, 0x28, 0x59, 0xD2 };
static const uint8_t table12[] = { 0x0B, 0x4B, 0xD7, 0x68, 0x5F, 0xAD, 0x4B, 0xBB };
static const uint8_t table13[] = { 0x4F, 0x4E, 0xE1, 0x6A, 0x21, 0xD3, 0xF7, 0xA6 };
static const uint8_t table14[] = { 0xDD, 0x39, 0xB9, 0x65, 0x03, 0x91, 0xF1, 0xAC };
static const uint8_t table15[] = { 0x3F, 0x50, 0xB5, 0x6F, 0x37, 0xC9, 0x13, 0x5D };
static const uint8_t table16[] = { 0xF9, 0x5C, 0xFD, 0x72, 0x19, 0x42, 0x23, 0x6B };
static const uint8_t table17[] = { 0xDF, 0x60, 0x93, 0x64, 0x33, 0x16, 0xB3, 0x8A };
static const uint8_t table18[] = { 0x09, 0x64, 0x5F, 0x6B, 0xFB, 0x21, 0x19, 0xE4 };
static void hash_modes_0F_to_18_tables(uint8_t *data, uint8_t *hash, const uint8_t *table)
{
int i;
uint32_t t[4], tmp;
memset(hash, 0x00, 16);
t[0] = (table[1] << 8) + table[0];
t[1] = (table[3] << 8) + table[2];
t[2] = (table[5] << 8) + table[4];
t[3] = (table[7] << 8) + table[6];
for (i = 0; i < 60; i += 4)
{
t[0] = ((t[0] & 0xFFFF) * t[2]) + (t[0] >> 16);
t[1] = ((t[1] & 0xFFFF) * t[3]) + (t[1] >> 16);
tmp = t[0] + t[1];
hash[(i + 0) & 0x0F] = hash[(i + 0) & 0x0F] ^ data[i + 0] ^ (tmp >> 24);
hash[(i + 1) & 0x0F] = hash[(i + 1) & 0x0F] ^ data[i + 1] ^ (tmp >> 16);
hash[(i + 2) & 0x0F] = hash[(i + 2) & 0x0F] ^ data[i + 2] ^ (tmp >> 8);
hash[(i + 3) & 0x0F] = hash[(i + 3) & 0x0F] ^ data[i + 3] ^ (tmp >> 0);
}
}
static const uint8_t table19[] = { 0x02, 0x03, 0x05, 0x10 };
static const uint8_t table1A[] = { 0x01, 0x05, 0x08, 0x10 };
static const uint8_t table1B[] = { 0x03, 0x07, 0x08, 0x10 };
static const uint8_t table1C[] = { 0x03, 0x05, 0x0A, 0x10 };
static const uint8_t table1D[] = { 0x03, 0x07, 0x0A, 0x10 };
static const uint8_t table1E[] = { 0x01, 0x05, 0x0B, 0x10 };
static const uint8_t table1F[] = { 0x06, 0x07, 0x0B, 0x10 };
static const uint8_t table20[] = { 0x01, 0x08, 0x0B, 0x10 };
static const uint8_t table21[] = { 0x01, 0x07, 0x0C, 0x10 };
static const uint8_t table22[] = { 0x05, 0x0B, 0x0C, 0x10 };
static const uint8_t table23[] = { 0x0B, 0x0C, 0x0D, 0x10 };
static const uint8_t table24[] = { 0x07, 0x09, 0x0E, 0x10 };
static const uint8_t table25[] = { 0x01, 0x04, 0x0F, 0x10 };
static const uint8_t table26[] = { 0x07, 0x08, 0x0F, 0x10 };
static const uint8_t table27[] = { 0x02, 0x0B, 0x0F, 0x10 };
static void hash_modes_19_to_27_tables_3(uint8_t *data, uint8_t *hash, const uint8_t *table)
{
int i;
uint8_t val, it[4];
uint16_t seed = 0xFFFF, tmp;
memset(hash, 0x00, 16);
for (i = 0; i < 4; i++)
{
it[i] = 0x10 - table[i];
}
for (i = 0; i < 16; i++)
{
val = ((seed >> it[0]) ^ (seed >> it[1]) ^ (seed >> it[2]) ^ (seed >> it[3])) & 0x01;
if (val == 0x00)
{
seed = seed >> 1;
}
else
{
seed = (seed >> 1) | 0x8000;
}
tmp = seed + (data[i] << 8) + data[i + 32];
val = ((seed >> it[0]) ^ (seed >> it[1]) ^ (seed >> it[2]) ^ (seed >> it[3])) & 0x01;
if (val == 0x00)
{
seed = seed >> 1;
}
else
{
seed = (seed >> 1) | 0x8000;
}
tmp = tmp + seed + (data[i + 16] << 8) + data[i + 48];
hash[i & 0x0F] ^= tmp >> 8;
hash[(i + 1) & 0x0F] ^= tmp;
}
}
static void create_hash(uint8_t *data, int len, uint8_t *hash, int mode)
{
if ((mode > 0x27) || (mode == 0x0B) || (mode == 0x0C) ||
(mode == 0x0D) || (mode == 0x0E) || (mode == 0))
{
memset(hash, 0, 16);
return;
}
uint8_t dataPadded[64];
pad_data(data, len, dataPadded);
switch (mode)
{
case 1:
hash_mode_01_custom_md5(dataPadded, hash);
break;
case 2:
hash_mode_02(dataPadded, hash);
break;
case 3:
hash_mode_03(dataPadded, hash);
break;
case 4:
hash_modes_04_to_0A_tables(dataPadded, hash, table04);
break;
case 5:
hash_modes_04_to_0A_tables(dataPadded, hash, table05);
break;
case 6:
hash_modes_04_to_0A_tables(dataPadded, hash, table06);
break;
case 7:
hash_modes_04_to_0A_tables(dataPadded, hash, table07);
break;
case 8:
hash_modes_04_to_0A_tables(dataPadded, hash, table08);
break;
case 9:
hash_modes_04_to_0A_tables(dataPadded, hash, table09);
break;
case 10:
hash_modes_04_to_0A_tables(dataPadded, hash, table0A);
break;
case 15:
hash_modes_0F_to_18_tables(dataPadded, hash, table0F);
break;
case 16:
hash_modes_0F_to_18_tables(dataPadded, hash, table10);
break;
case 17:
hash_modes_0F_to_18_tables(dataPadded, hash, table11);
break;
case 18:
hash_modes_0F_to_18_tables(dataPadded, hash, table12);
break;
case 19:
hash_modes_0F_to_18_tables(dataPadded, hash, table13);
break;
case 20:
hash_modes_0F_to_18_tables(dataPadded, hash, table14);
break;
case 21:
hash_modes_0F_to_18_tables(dataPadded, hash, table15);
break;
case 22:
hash_modes_0F_to_18_tables(dataPadded, hash, table16);
break;
case 23:
hash_modes_0F_to_18_tables(dataPadded, hash, table17);
break;
case 24:
hash_modes_0F_to_18_tables(dataPadded, hash, table18);
break;
case 25:
hash_modes_19_to_27_tables_3(dataPadded, hash, table19);
break;
case 26:
hash_modes_19_to_27_tables_3(dataPadded, hash, table1A);
break;
case 27:
hash_modes_19_to_27_tables_3(dataPadded, hash, table1B);
break;
case 28:
hash_modes_19_to_27_tables_3(dataPadded, hash, table1C);
break;
case 29:
hash_modes_19_to_27_tables_3(dataPadded, hash, table1D);
break;
case 30:
hash_modes_19_to_27_tables_3(dataPadded, hash, table1E);
break;
case 31:
hash_modes_19_to_27_tables_3(dataPadded, hash, table1F);
break;
case 32:
hash_modes_19_to_27_tables_3(dataPadded, hash, table20);
break;
case 33:
hash_modes_19_to_27_tables_3(dataPadded, hash, table21);
break;
case 34:
hash_modes_19_to_27_tables_3(dataPadded, hash, table22);
break;
case 35:
hash_modes_19_to_27_tables_3(dataPadded, hash, table23);
break;
case 36:
hash_modes_19_to_27_tables_3(dataPadded, hash, table24);
break;
case 37:
hash_modes_19_to_27_tables_3(dataPadded, hash, table25);
break;
case 38:
hash_modes_19_to_27_tables_3(dataPadded, hash, table26);
break;
case 39:
hash_modes_19_to_27_tables_3(dataPadded, hash, table27);
break;
default:
cs_log("A new hash mode [%d] is in use.", mode);
break;
}
}
static void create_hash_mode_03(uint8_t *data, uint8_t *hash)
{
int i, j, c;
uint8_t buffer0[16], buffer1[8], buffer2[8], tmpBuff1[4], tmpBuff2[4];
uint8_t table[] =
{
0x68, 0xCE, 0xE7, 0x71, 0xCC, 0x3A, 0x0B, 0x6E, 0x2A, 0x43, 0x17, 0x07, 0x5A, 0xD9, 0x14, 0x5B,
0xB0, 0x8E, 0xA8, 0x7F, 0xD8, 0xA2, 0xCF, 0x73, 0xC2, 0xB9, 0x5D, 0x46, 0xDD, 0x2C, 0xE2, 0x2D,
0xFD, 0x50, 0xE9, 0x7C, 0x28, 0x72, 0x9B, 0xAA, 0xEC, 0x24, 0x74, 0xAB, 0x00, 0x1C, 0x8B, 0x65,
0x38, 0x13, 0x22, 0x82, 0xAC, 0x9A, 0x4D, 0x2B, 0xEA, 0x04, 0x31, 0x84, 0x32, 0x3D, 0x36, 0x53,
0x5F, 0x42, 0x96, 0xDE, 0x47, 0x08, 0x51, 0x4B, 0x3E, 0xD1, 0x1E, 0x12, 0xD2, 0x1F, 0x7D, 0x26,
0xCD, 0x57, 0x8C, 0xB6, 0xD3, 0xF8, 0x11, 0xAD, 0x6A, 0x88, 0x95, 0x21, 0xE8, 0xBF, 0x6B, 0x27,
0xBE, 0xA3, 0x33, 0xB8, 0x9E, 0xB3, 0x6C, 0xC3, 0x06, 0xC7, 0x6F, 0x99, 0x97, 0xDA, 0x09, 0xAF,
0xAE, 0xCB, 0x79, 0x37, 0x55, 0x85, 0x8D, 0x2F, 0x8A, 0x70, 0xA1, 0x7A, 0x66, 0x29, 0x67, 0x0F,
0xEB, 0x9C, 0xC8, 0xC4, 0xD6, 0x4C, 0xDF, 0x1A, 0xC0, 0x01, 0x64, 0xBC, 0x4E, 0xE1, 0x54, 0xD7,
0x4F, 0xB7, 0x5E, 0xCA, 0xF0, 0x91, 0xE4, 0x59, 0x4A, 0xC6, 0x83, 0x8F, 0xBD, 0x61, 0xFF, 0x56,
0x92, 0xF1, 0x5C, 0x77, 0xC9, 0x20, 0xF4, 0xE5, 0x10, 0x69, 0x03, 0x1D, 0xD5, 0x45, 0xF6, 0x0E,
0xEF, 0xA0, 0xE3, 0x58, 0xFC, 0xED, 0x80, 0x16, 0xEE, 0xFA, 0x02, 0xF5, 0xB4, 0x0A, 0xE0, 0x0C,
0xF7, 0xF9, 0xBA, 0x7E, 0x18, 0x78, 0x19, 0xB5, 0x0D, 0x44, 0x34, 0xD4, 0xDC, 0x30, 0x6D, 0x3B,
0x63, 0x41, 0x48, 0x40, 0xA7, 0xA5, 0xC5, 0x98, 0x76, 0x3F, 0xC1, 0x25, 0x93, 0x49, 0xD0, 0x62,
0x2E, 0x75, 0xDB, 0x94, 0xF3, 0x52, 0x05, 0x81, 0xFB, 0xBB, 0xA6, 0x89, 0x39, 0xA4, 0xF2, 0xA9,
0xFE, 0x60, 0x3C, 0x15, 0xB1, 0x35, 0x86, 0x9D, 0x9F, 0x90, 0x1B, 0xE6, 0x7B, 0x23, 0x87, 0xB2
};
for (i = 0; i < 4; i++)
{
buffer0[0 + i] = data[12 + i];
buffer0[4 + i] = data[8 + i];
buffer0[8 + i] = data[4 + i];
buffer0[12 + i] = data[0 + i];
}
for (c = 0; c < 12; c++)
{
for (i = 0; i < 4; i++)
{
buffer1[0 + i] = buffer0[8 + i] ^ buffer0[12 + i];
buffer1[4 + i] = buffer0[0 + i] ^ buffer0[4 + i];
}
for (i = 0; i < 8; i++)
{
buffer1[i] = table[buffer1[i] ^ data[16 + 16 * (c % 3) + i]];
}
for (j = 0; j < 8; j++)
{
buffer2[j] = 0;
for (i = 0; i < 8; i++)
{
buffer2[j] ^= buffer1[i] * (j * i + 1);
}
}
for (i = 0; i < 8; i++)
{
buffer2[i] = table[buffer2[i] ^ data[24 + 16 * (c % 3) + i]] ^ data[16 + 16 * (c % 3) + i];
}
for (i = 0; i < 4; i++)
{
buffer0[12 + i] ^= buffer2[0 + i];
buffer0[8 + i] ^= buffer2[0 + i];
buffer0[4 + i] ^= buffer2[4 + i];
buffer0[0 + i] ^= buffer2[4 + i];
}
tmpBuff1[0] = buffer0[14];
tmpBuff1[1] = buffer0[15];
tmpBuff1[2] = buffer0[12] ^ buffer0[14];
tmpBuff1[3] = buffer0[13] ^ buffer0[15];
tmpBuff2[0] = buffer0[6];
tmpBuff2[1] = buffer0[7];
tmpBuff2[2] = buffer0[4] ^ buffer0[6];
tmpBuff2[3] = buffer0[5] ^ buffer0[7];
for (i = 0; i < 4; i++)
{
buffer0[12 + i] = tmpBuff1[i];
buffer0[4 + i] = tmpBuff2[i];
}
}
for (i = 0; i < 4; i++)
{
hash[0 + i] = buffer0[12 + i] ^ data[0 + i];
hash[4 + i] = buffer0[8 + i] ^ data[4 + i];
hash[8 + i] = buffer0[4 + i] ^ data[8 + i];
hash[12 + i] = buffer0[0 + i] ^ data[12 + i];
}
}
static void create_data_cw_mode_03(uint8_t *seed, int lenSeed, uint8_t *basecw,
uint8_t val, uint8_t *ecmBody, uint8_t *data)
{
int idxData = 8, idxSeed = 0, idxBase = 0;
uint8_t padding[] =