PageRenderTime 15ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/softcam/cas/nagra.c

https://bitbucket.org/cesbo/astra
C | 94 lines | 55 code | 9 blank | 30 comment | 12 complexity | 955767a862c6f0bc3e25353ec23865a0 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
 1/*
 2 * Astra Module: SoftCAM
 3 * http://cesbo.com/astra
 4 *
 5 * Copyright (C) 2012-2013, Andrey Dyldin <and@cesbo.com>
 6 *
 7 * This program is free software: you can redistribute it and/or modify
 8 * it under the terms of the GNU General Public License as published by
 9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "../module_cam.h"
22
23struct module_data_t
24{
25    MODULE_CAS_DATA();
26};
27
28static bool cas_check_em(module_data_t *mod, mpegts_psi_t *em)
29{
30    const uint8_t em_type = em->buffer[0];
31    switch(em_type)
32    {
33        // ECM
34        case 0x80:
35        case 0x81:
36        {
37            return true;
38        }
39        // EMM ( ret = MPEGTS_PACKET_EMM )
40        case 0x83:
41        {
42            const uint8_t *ua = mod->__cas.decrypt->cam->ua;
43            if(em->buffer[5] == ua[4]
44               && em->buffer[4] == ua[5]
45               && em->buffer[3] == ua[6])
46            {
47                if(em->buffer[7] == 0x10) // shared
48                    return true;
49                else if(em->buffer[6] == ua[7]) // unique
50                    return true;
51            }
52            break;
53        }
54        case 0x82: // global
55        {
56            return true;
57        }
58        default:
59            break;
60    }
61
62    return false;
63}
64
65static bool cas_check_keys(module_data_t *mod, const uint8_t *keys)
66{
67    __uarg(mod);
68    __uarg(keys);
69    return true;
70}
71
72/*
73 * CA descriptor (iso13818-1):
74 * tag      :8 (must be 0x09)
75 * length   :8
76 * caid     :16
77 * reserved :3
78 * pid      :13
79 * data     :length-4
80 */
81
82static bool cas_check_descriptor(module_data_t *mod, const uint8_t *desc)
83{
84    __uarg(mod);
85    __uarg(desc);
86    return true;
87}
88
89static bool cas_check_caid(uint16_t caid)
90{
91    return ((caid & 0xFF00) == 0x1800);
92}
93
94MODULE_CAS(nagra)