Skip to content

Commit

Permalink
Merge branch 'master' into FBC
Browse files Browse the repository at this point in the history
* master: (24 commits)
  [MenuList] * partialy revert aa2c1a7
  add vti workaroud
  [ServiceScan.py] Update after this commit aa2c1a7!
  [dvbci_ccmgr_helper] * Replace call to the non reentrant function "localtime" by a call to "localtime_r".
  ci add ci+ 1.4 support
  [skin.py] Small corrections and adjustments
  [TemplatedMultiContent.py] Sort imports
  [MultiContent.py] Remove unneeded import
  [eListbox] * rename setSpacerColor -> setSpacingColor
  GUI Updates (#2943)
  [Geolocation.py] Code updates (#2950)
  [main] * checkInternetAccess change return codes to:
  [Timers] * remove duplicate getSpace
  Unicable connected (#2949)
  [enigma] (#2947)
  [StackTrace.py] Small code clean up
  multiboot fix slot R target selection for kexecmultiboot
  information.py, multiboot sortslots
  [VideoWizard] * stop timer after press red for language selection
  [VideoWizard] * enable red button for language selection in video wizard
  ...
  • Loading branch information
jbleyel committed Jun 23, 2023
2 parents ea5d593 + fc611b6 commit 7682222
Show file tree
Hide file tree
Showing 75 changed files with 5,421 additions and 1,271 deletions.
1 change: 1 addition & 0 deletions .github/workflows/SonarCloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
sudo apt-get install libavahi-client-dev
sudo apt-get install libjpeg-turbo8-dev
sudo apt-get install libgif-dev
sudo apt-get install libcurl4-openssl-dev
- uses: actions/checkout@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/enigma2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
sudo apt-get install libavahi-client-dev
sudo apt-get install libjpeg-turbo8-dev
sudo apt-get install libgif-dev
sudo apt-get install libcurl4-openssl-dev
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AC_ARG_WITH(gstversion,

PKG_CHECK_MODULES(TUXTXT, tuxbox-tuxtxt)
PKG_CHECK_MODULES(GSTREAMER, gstreamer-$GST_MAJORMINOR gstreamer-pbutils-$GST_MAJORMINOR)
PKG_CHECK_MODULES(BASE, [freetype2 fribidi gstreamer-$GST_MAJORMINOR gstreamer-pbutils-$GST_MAJORMINOR libdvbsi++ libpng libxml-2.0 sigc++-2.0 libssl libcrypto])
PKG_CHECK_MODULES(BASE, [freetype2 fribidi gstreamer-$GST_MAJORMINOR gstreamer-pbutils-$GST_MAJORMINOR libdvbsi++ libpng libxml-2.0 sigc++-2.0 libssl libcrypto libcurl])
PKG_CHECK_MODULES(LIBDDVD, libdreamdvd, HAVE_LIBDDVD="yes", HAVE_LIBDDVD="no")
AM_CONDITIONAL(HAVE_LIBDDVD, test "$HAVE_LIBDDVD" = "yes")
PKG_CHECK_MODULES(AVAHI, avahi-client)
Expand Down
1 change: 0 additions & 1 deletion data/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ self.session.openWithCallback(msgClosed, EpgDeleteMsg)
<item key="softcam_settings" level="0" text="Softcam Settings" weight="50" requires="HAVEINITCAM"><screen module="SoftcamSetup" screen="SoftcamSetup" /></item>
<item key="oscam_info" level="0" text="OScam Information" weight="60" requires="ShowOscamInfo"><screen module="OScamInfo" screen="OscamInfoMenu" /></item>
<item key="cccam_info" level="0" text="CCCam Information" weight="70" requires="ShowCCCamInfo"><screen module="CCcamInfo" screen="CCcamInfoMain" /></item>
<item key="ci_settings" level="1" text="CI Basic Settings" weight="80" requires="CommonInterface"><setup setupKey="CISettings" /></item>
<item key="ci_setup" level="1" text="CI Helper Settings" weight="90" requires="CIHelper"><screen module="Ci" screen="CIHelper" /></item>
<item key="ci_selection" level="1" text="Common Interface Settings" weight="100" requires="CommonInterface"><screen module="Ci" screen="CiSelection" /></item>
<item key="parental_setup" level="0" text="Parental Control Settings" weight="200"><screen module="ParentalControlSetup" screen="ParentalControlSetup" /></item>
Expand Down
9 changes: 1 addition & 8 deletions data/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@
<item level="2" text="Number of digits in channel number" description="This allows you to set the number of digits to 5, if you have more than 9999 channels.">config.usage.maxchannelnumlen</item>
<item level="0" text="Set action for 'Info' key" description="Here you can set what is called when pressing the 'Info' key.">config.usage.servicelist_infokey</item>
</setup>
<setup key="CISettings" title="CI Basic Settings" requires="CommonInterface" showOpenWebif="1">
<item level="1" text="DVB CI Delay" description="Choose dvb wait delay for ci response." requires="CommonInterfaceCIDelay">config.cimisc.dvbCiDelay</item>
<if requires="HaveCISSL">
<item level="1" text="CI Operation Mode" description="Choose the CI protocol operation mode for standard ci or ciplus.">config.cimisc.civersion</item>
<else />
<item level="1" text="CI Operation Mode" description="Your Hardware can detect ci mode self or work only in legacy mode.">config.cimisc.civersion</item>
</if>
</setup>
<setup key="Display" title="Display Settings" requires="FrontpanelDisplay" showOpenWebif="1">
<item level="0" text="Clone TV screen to LCD" description="Shows live tv or informations on LCD." requires="FBLCDDisplay">config.lcd.fblcddisplay</item>
<item level="0" text="Brightness (Normal)" description="Configure the brightness level of the front panel display for normal operation.">config.lcd.bright</item>
Expand Down Expand Up @@ -887,6 +879,7 @@
<item level="0" text="Show transponder remaining/elapsed as" description="This option allows you choose how to display the remaining/elapsed time for live tv.">config.usage.swap_time_display_on_osd</item>
<item level="0" text="Media playback Remaining/Elapsed as" description="This option allows you choose how to display the remaining/elapsed time for media playback.">config.usage.swap_media_time_display_on_osd</item>
<item level="2" text="Hide zap errors" description="Hide any zap error messages.">config.usage.hide_zap_errors</item>
<item level="2" text="Hide CI messages" description="Hide error messages from the Common Interface module.">config.usage.hide_ci_messages</item>
<item level="2" text="Show crypto info in InfoBar" description="Show encryption information in the InfoBar (when supported by the skin).">config.usage.show_cryptoinfo</item>
<item level="2" text="InfoBar front end data source" description="Configure the source of the frontend data as shown on the infobars. 'Settings' is as stored on the settings. 'Tuner' is as reported by the tuner.">config.usage.infobar_frontend_source</item>
<item level="2" text="Swap SNR in '&#37;' with SNR in 'db'" description="This option allows you to the SNR as a percentage (not all receivers support this).">config.usage.swap_snr_on_osd</item>
Expand Down
23 changes: 21 additions & 2 deletions lib/dvb_ci/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ dvb_ci_libenigma_dvb_ci_a_SOURCES = \
dvb_ci/dvbci_mmi.cpp \
dvb_ci/dvbci_resmgr.cpp \
dvb_ci/dvbci_session.cpp \
dvb_ci/dvbci_ui.cpp
dvb_ci/dvbci_ui.cpp \
dvb_ci/dvbci_ccmgr.cpp \
dvb_ci/dvbci_ccmgr_helper.cpp \
dvb_ci/dvbci_hlcmgr.cpp \
dvb_ci/dvbci_host_ctrl.cpp \
dvb_ci/dvbci_cam_upgrade.cpp \
dvb_ci/dvbci_app_mmi.cpp \
dvb_ci/dvbci_operatorprofile.cpp \
dvb_ci/aes_xcbc_mac.cpp \
dvb_ci/descrambler.cpp


dvbciincludedir = $(pkgincludedir)/lib/dvb_ci
dvbciinclude_HEADERS = \
Expand All @@ -19,4 +29,13 @@ dvbciinclude_HEADERS = \
dvb_ci/dvbci_mmi.h \
dvb_ci/dvbci_resmgr.h \
dvb_ci/dvbci_session.h \
dvb_ci/dvbci_ui.h
dvb_ci/dvbci_ui.h \
dvb_ci/dvbci_ccmgr.h \
dvb_ci/dvbci_ccmgr_helper.h \
dvb_ci/dvbci_hlcmgr.h \
dvb_ci/dvbci_host_ctrl.h \
dvb_ci/dvbci_cam_upgrade.h \
dvb_ci/dvbci_app_mmi.h \
dvb_ci/dvbci_operatorprofile.h \
dvb_ci/aes_xcbc_mac.h \
dvb_ci/descrambler.h
62 changes: 62 additions & 0 deletions lib/dvb_ci/aes_xcbc_mac.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <stdint.h>
#include <string.h>
#include <openssl/aes.h>

#include "aes_xcbc_mac.h"

int aes_xcbc_mac_init(struct aes_xcbc_mac_ctx *ctx, const uint8_t *key)
{
AES_KEY aes_key;
int y, x;

AES_set_encrypt_key(key, 128, &aes_key);

for (y = 0; y < 3; y++) {
for (x = 0; x < 16; x++)
ctx->K[y][x] = y + 1;
AES_ecb_encrypt(ctx->K[y], ctx->K[y], &aes_key, 1);
}

/* setup K1 */
AES_set_encrypt_key(ctx->K[0], 128, &ctx->key);

memset(ctx->IV, 0, 16);
ctx->buflen = 0;

return 0;
}

int aes_xcbc_mac_process(struct aes_xcbc_mac_ctx *ctx, const uint8_t *in, unsigned int len)
{
while (len) {
if (ctx->buflen == 16) {
AES_ecb_encrypt(ctx->IV, ctx->IV, &ctx->key, 1);
ctx->buflen = 0;
}
ctx->IV[ctx->buflen++] ^= *in++;
--len;
}

return 0;
}

int aes_xcbc_mac_done(struct aes_xcbc_mac_ctx *ctx, uint8_t *out)
{
int i;

if (ctx->buflen == 16) {
/* K2 */
for (i = 0; i < 16; i++)
ctx->IV[i] ^= ctx->K[1][i];
} else {
ctx->IV[ctx->buflen] ^= 0x80;
/* K3 */
for (i = 0; i < 16; i++)
ctx->IV[i] ^= ctx->K[2][i];
}

AES_ecb_encrypt(ctx->IV, ctx->IV, &ctx->key, 1);
memcpy(out, ctx->IV, 16);

return 0;
}
17 changes: 17 additions & 0 deletions lib/dvb_ci/aes_xcbc_mac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __AES_XCBC_H_
#define __AES_XCBC_H_

#include <openssl/aes.h>

struct aes_xcbc_mac_ctx {
uint8_t K[3][16];
uint8_t IV[16];
AES_KEY key;
int buflen;
};

int aes_xcbc_mac_init(struct aes_xcbc_mac_ctx *ctx, const uint8_t *key);
int aes_xcbc_mac_process(struct aes_xcbc_mac_ctx *ctx, const uint8_t *in, unsigned int len);
int aes_xcbc_mac_done(struct aes_xcbc_mac_ctx *ctx, uint8_t *out);

#endif
111 changes: 111 additions & 0 deletions lib/dvb_ci/descrambler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <linux/dvb/ca.h>

#include <lib/base/eerror.h>

#ifndef CA_SET_PID
/**
* CA_SET_PID and ca_pid struct removed on 4.14 kernel
* Check commit 833ff5e7feda1a042b83e82208cef3d212ca0ef1
**/
struct ca_pid {
unsigned int pid;
int index; /* -1 == disable*/
};
#define CA_SET_PID _IOW('o', 135, struct ca_pid)
#endif

enum ca_descr_data_type {
CA_DATA_IV,
CA_DATA_KEY,
};

enum ca_descr_parity {
CA_PARITY_EVEN,
CA_PARITY_ODD,
};

struct ca_descr_data {
unsigned int index;
enum ca_descr_parity parity;
enum ca_descr_data_type data_type;
unsigned int length;
unsigned char *data;
};


#define CA_SET_DESCR_DATA _IOW('o', 137, struct ca_descr_data)

int descrambler_set_key(int desc_fd, int index, int parity, unsigned char *data)
{
struct ca_descr_data d;

d.index = index;
d.parity = (enum ca_descr_parity)parity;
d.data_type = CA_DATA_KEY;
d.length = 16;
d.data = data;

if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d) == -1) {
eWarning("[CI descrambler] set key failed");
return -1;
}

d.index = index;
d.parity = (enum ca_descr_parity)parity;
d.data_type = CA_DATA_IV;
d.length = 16;
d.data = data + 16;

if (ioctl(desc_fd, CA_SET_DESCR_DATA, &d) == -1) {
eWarning("[CI descrambler] set iv failed");
return -1;
}

return 0;
}

int descrambler_set_pid(int desc_fd, int index, int enable, int pid)
{
struct ca_pid p;
unsigned int flags = 0x80;

if (index)
flags |= 0x40;

if (enable)
flags |= 0x20;

p.pid = pid;
p.index = flags;

if (ioctl(desc_fd, CA_SET_PID, &p) == -1) {
eWarning("[CI descrambler] set pid failed");
return -1;
}

return 0;
}

int descrambler_init(void)
{
int desc_fd;
const char *filename = "/dev/dvb/adapter0/ca0";

desc_fd = open(filename, O_RDWR);
if (desc_fd == -1) {
eWarning("[CI descrambler] can not open %s", filename);
}

return desc_fd;
}

void descrambler_deinit(int desc_fd)
{
close(desc_fd);
}
9 changes: 9 additions & 0 deletions lib/dvb_ci/descrambler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef __DESCR_H_
#define __DESCR_H_

int descrambler_init(void);
void descrambler_deinit(int desc_fd);
int descrambler_set_key(int desc_fd, int index, int parity, unsigned char *data);
int descrambler_set_pid(int desc_fd, int index, int enable, int pid);

#endif
Loading

0 comments on commit 7682222

Please sign in to comment.