Merge branch 'bug_487_service_selection_event_text_color'
[enigma2.git] / lib / base / etpm.h
1 #ifndef __lib_base_etpm_h
2 #define __lib_base_etpm_h
3
4 #include <lib/base/object.h>
5 #include <lib/python/python.h>
6
7 #ifndef SWIG
8 #define TPMD_SOCKET "/var/run/tpmd_socket"
9 #endif
10
11 class eTPM: public Object, public iObject
12 {
13         DECLARE_REF(eTPM);
14 #ifndef SWIG
15         int fd;
16         unsigned char level2_cert[210];
17         unsigned char level3_cert[210];
18         bool level2_cert_read;
19         bool level3_cert_read;
20
21         enum tpmd_cmd {
22                 TPMD_CMD_RESERVED               = 0x0000,
23                 TPMD_CMD_GET_DATA               = 0x0001,
24                 TPMD_CMD_APDU                   = 0x0002,
25                 TPMD_CMD_COMPUTE_SIGNATURE      = 0x0003,
26                 TPMD_CMD_APP_CERT               = 0x0004,
27         };
28
29         bool send_cmd(enum tpmd_cmd cmd, const void *data, unsigned int len);
30         void *recv_cmd(unsigned int *tag, unsigned int *len);
31         void parse_data(const unsigned char *data, unsigned int datalen);
32
33 #endif
34 public:
35         eTPM();
36         ~eTPM();
37
38         enum cert_type {
39                 TPMD_DT_LEVEL2_CERT = 0x04,
40                 TPMD_DT_LEVEL3_CERT = 0x05
41         };
42         PyObject *getCert(cert_type type);
43         PyObject *challenge(PyObject *rnd);
44 };
45
46 #endif // __lib_base_etpm_h