Custom CAS

General JS API Page 97

Readme

test-cas.c/mk.sh/MAG-CAS-plugin.h

Example custom cas(ECM):

Example test-cas.c:

#include "MAG-CAS-plugin.h"
#include "stdio.h"
-#define DEBUG(x...) {}//printf(x)
+#define DEBUG(x...) printf(x)
#define DEBUG_CALL() DEBUG("Called function %s\n",__FUNCTION__)
STB_MAG_Cas_t PluginInterface;
@@ -123,7 +123,7 @@
CAS_Flags_e CAS_GetCasFlags(void)
{
DEBUG_CALL();
- return CAS_Flags_DecodeAll;
+ return CAS_Flags_PMT_ECM;
};
/**
* Get the format of ECM data expected by the plugin in
@@ -155,7 +155,7 @@
DescramblerInterface.SetScramblingKey = mag_interface->SetScramblingKey;
DescramblerInterface.SetScramblingType = mag_interface->SetScramblingType;
}
- PluginInterface.Decrypt = CAS_Decrypt;
+ PluginInterface.Decrypt = NULL;
PluginInterface.Deinit = CAS_Deinit;
PluginInterface.GetCasFlags = CAS_GetCasFlags;
PluginInterface.GetEcmFormat = NULL;
@@ -165,6 +165,13 @@
PluginInterface.OnPmtChange = NULL;
PluginInterface.ResetStream = CAS_ResetStream;
PluginInterface.SetAdditionalParam = CAS_SetAdditionalParam;
+
+ DescramblerInterface.SetScramblingType(CAS_SCRAMBLING_TYPE_CSA);
+ char evenKey[8]={0x11,0x11,0x11,0x33,0x11,0x11,0x11,0x33};
+ char oddKey[8]={0x11,0x11,0x11,0x33,0x11,0x11,0x11,0x33};
+ DescramblerInterface.SetScramblingKey(evenKey,0);
+ DescramblerInterface.SetScramblingKey(oddKey,1);
+
return &PluginInterface;
};

Notes:

When compiling, set option -fPIC

Set GetSysID

/** * Get CAS vendor SysID as defined in DVB. Useful only in * CAS_Flags_PMT_ECM mode */ int (*GetSysID)(void);

According this SysID - from stream PID is determined where ECM packets are. Example was designed to decrypt totally with resources of plugin.