1 | #ifndef __NDS_COMMON__
|
---|
2 | #define __NDS_COMMON
|
---|
3 |
|
---|
4 | #include "globals.h"
|
---|
5 |
|
---|
6 | #include <termios.h>
|
---|
7 | #include <unistd.h>
|
---|
8 | #ifdef OS_LINUX
|
---|
9 | #include <linux/serial.h>
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #define write_cmd_vg(cmd, data) (card_write(reader, cmd, data, cta_res, &cta_lr) == 0)
|
---|
13 |
|
---|
14 | #define VG_EMMTYPE_MASK 0xC0
|
---|
15 | #define VG_EMMTYPE_G 0
|
---|
16 | #define VG_EMMTYPE_U 1
|
---|
17 | #define VG_EMMTYPE_S 2
|
---|
18 |
|
---|
19 | #define NDSUNKNOWN 0
|
---|
20 | #define NDS1 1
|
---|
21 | #define NDS12 12
|
---|
22 | #define NDS2 2
|
---|
23 |
|
---|
24 | extern int VG_BASEYEAR;
|
---|
25 |
|
---|
26 | typedef struct nds_atr {
|
---|
27 | uchar atr[MAX_ATR_LEN];
|
---|
28 | ushort atr_len;
|
---|
29 | int base_year;
|
---|
30 | int nds_version;
|
---|
31 | const char *desc;
|
---|
32 | } NDS_ATR_ENTRY;
|
---|
33 |
|
---|
34 | AES_KEY dkey, ekey, Astro_Key;
|
---|
35 |
|
---|
36 | unsigned char CW1[8], CW2[8];
|
---|
37 |
|
---|
38 | extern int io_serial_need_dummy_char;
|
---|
39 |
|
---|
40 | struct CmdTabEntry {
|
---|
41 | unsigned char cla;
|
---|
42 | unsigned char cmd;
|
---|
43 | unsigned char len;
|
---|
44 | unsigned char mode;
|
---|
45 | };
|
---|
46 |
|
---|
47 | struct CmdTab {
|
---|
48 | unsigned char index;
|
---|
49 | unsigned char size;
|
---|
50 | unsigned char Nentries;
|
---|
51 | unsigned char dummy;
|
---|
52 | struct CmdTabEntry e[1];
|
---|
53 | };
|
---|
54 |
|
---|
55 | struct CmdTab *cmd_table;
|
---|
56 |
|
---|
57 | extern int cw_is_valid(unsigned char *cw);
|
---|
58 | extern void cAES_SetKey(const unsigned char *key);
|
---|
59 | extern int cAES_Encrypt(const unsigned char *data, int len, unsigned char *crypt);
|
---|
60 | extern void swap_lb (unsigned char *buff, int len);
|
---|
61 |
|
---|
62 | extern void __xxor(unsigned char *data, int len, const unsigned char *v1, const unsigned char *v2);
|
---|
63 | #define xor16(v1,v2,d) __xxor((d),16,(v1),(v2))
|
---|
64 | #define val_by2on3(x) ((0xaaab*(x))>>16) //fixed point *2/3
|
---|
65 |
|
---|
66 | extern void cCamCryptVG_SetSeed(unsigned char *Key1, unsigned char *Key2);
|
---|
67 | extern void cCamCryptVG_GetCamKey(unsigned char *buff);
|
---|
68 |
|
---|
69 | extern void do_post_dw_hash(unsigned char *cw, unsigned char *ecm_header_data);
|
---|
70 | extern void memorize_cmd_table (const unsigned char *mem, int size);
|
---|
71 | extern void Manage_Tag(unsigned char *Answer);
|
---|
72 | extern int status_ok(const unsigned char *status);
|
---|
73 | extern int read_cmd_len(struct s_reader * reader, const unsigned char *cmd);
|
---|
74 | extern int do_cmd(struct s_reader * reader, const unsigned char *ins, const unsigned char *txbuff, unsigned char *rxbuff, unsigned char * cta_res);
|
---|
75 | extern void rev_date_calc(const unsigned char *Date, int *year, int *mon, int *day, int *hh, int *mm, int *ss, int base_year);
|
---|
76 | extern void getNdsAtrEntry(NDS_ATR_ENTRY *nds_atr_entry);
|
---|
77 |
|
---|
78 | #endif // __NDS_COMMON__
|
---|
79 |
|
---|