47 #ifdef INCLUDE_FREESAT 48 #include <openssl/sha.h> 49 #include <openssl/rsa.h> 50 #include <openssl/evp.h> 51 #include <openssl/x509.h> 54 #ifdef INCLUDE_CI_PLUS 61 #define MAX_WAI_LEN 256 65 #define RSA_SALT_SIZE 16 66 #define RSA_SIGNATURE_SIZE (1024 / 8) 67 #define MAX_VERSION_LEN 12 68 #define MAX_RSA_KEY_SIZE 1024 76 static MHEG5Int currentICStatus = -1;
87 #ifdef INCLUDE_FREESAT 110 assert( buffer != NULL && length != 0);
113 if (strncmp((
char *)buffer, (
char *)
"dvb://", 6) == 0)
117 else if (strncmp((
char *)buffer, (
char *)
"rec://svc/", 10) == 0)
122 if (strncmp((
char *)buffer, (
char *)
"def", 3) == 0)
127 else if (strncmp((
char *)buffer, (
char *)
"cur", 3) == 0)
131 TRACE(TSTRM, (
"svc/cur is default service %d", multiplexRef->
service_id))
135 else if (strncmp((
char *)buffer, (
char *)
"lcn/", 4) == 0 &&
156 #ifdef INCLUDE_FREESAT 157 else if (strncmp((
char *)buffer, (
char *)
"fsi/", 4) == 0 &&
167 (DVB_MhegGetFSILocator(fsi, &dvbLocator) ==
MHERR_OK))
213 if (serviceReference->
data && serviceReference->
len &&
221 TRACE(TTUNE, (
"net_id=%d trns_id=%d serv_id=%d",
229 TRACE(TTUNE, (
" %.*s --> index=%x", serviceReference->
len, serviceReference->
data, serviceIndex));
330 *transportStreamID = 0;
337 #ifdef INCLUDE_CI_PLUS 426 void MHEG5getICStatus(
MHEG5Int *icStatus)
428 if (currentICStatus == -1)
445 *icStatus = currentICStatus;
455 void MHEG5clearICStatus(
void)
458 currentICStatus = -1;
461 void MHEG5changedICStatus(
void)
464 currentICStatus = -1;
473 void MHEG5isConnectionEnabled(
MHEG5Bool *enabled)
476 #ifdef INCLUDE_FREESAT 479 DVB_MhegIsConnectionAllowed(service_index, &isAllowed);
502 #ifdef INCLUDE_FREESAT 504 DVB_MhegGetPINRequirement(&status);
516 TRACE(TICS,(
"PIN support %d %d",support,required))
547 out = guidanceMessage;
549 if (restriction != NULL)
554 len = restriction->
len;
561 byte = restriction->
data[index];
569 else if (byte <= 0x7f)
577 else if ((byte & 0xe0) == 0xc0)
583 else if ((byte & 0xf0) == 0xe0)
589 else if ((byte & 0xf8) == 0xf0)
597 if (byte >= 0x40 && byte <= 0x5e)
603 index += 2 + restriction->
data[index + 2];
611 else if (byte >= 0x60 && byte <= 0x7e)
624 if ((byte & 0xc0) == 0x80)
638 if ((byte & 0xc0) == 0x80)
652 if ((byte & 0xc0) == 0x80)
665 else if (ch <= 0x7ff)
667 *out++ = 0xc0 | (
U8BIT)(ch >> 6);
668 *out++ = 0x80 | (
U8BIT)(ch & 0x3f);
670 else if (ch <= 0xffff)
672 *out++ = 0xe0 | (
U8BIT)(ch >> 12);
673 *out++ = 0x80 | ((ch >> 6) & 0x3f);
674 *out++ = 0x80 | (ch & 0x3f);
678 *out++ = 0xe0 | (
U8BIT)(ch >> 18);
679 *out++ = 0x80 | ((ch >> 12) & 0x3f);
680 *out++ = 0x80 | ((ch >> 6) & 0x3f);
681 *out++ = 0x80 | (ch & 0x3f);
697 if ((((byte & 0x80) == 0x00) && (byte != 0x00)) ||
698 ((byte & 0xe0) == 0xc0) ||
699 ((byte & 0xf0) == 0xe0) ||
700 ((byte & 0xf8) == 0xf0))
718 #ifndef INCLUDE_FREESAT 776 DVB_MhegGetPINRequirement(&pinStatus);
811 if (DVB_MhegGetFSIServiceReference(serviceIndex, &fsiBuffer) ==
MHERR_OK)
814 if (fsiBuffer > 0x7ff || fsiBuffer < 1)
820 fsiChars[4] =
'0' + fsiBuffer % 10;
821 fsiChars[3] =
'0' + fsiBuffer / 10;
822 fsiChars[2] =
'0' + fsiBuffer / 100;
823 fsiChars[1] =
'0' + fsiBuffer / 1000;
824 fsiChars[0] =
'0' + fsiBuffer / 10000;
826 for (i = 0; i < 5; i++)
828 if (fsiChars[i] ==
'0')
839 memcpy(fsiString->
data,
"rec://svc/fsi/", 14);
840 memcpy(fsiString->
data + 14, &fsiChars[i], fsiString->
len - 14);
866 DVB_MhegValidatePIN(pin->
data, &pinStatus);
928 if (workspace != NULL)
932 ws_digest = ws_data + data->
len;
933 ws_key = ws_digest + SHA_DIGEST_LENGTH;
937 for (i = 0; i < 10; i++)
943 DVB_MhegGetMACAddress(ws_salt + 10);
946 memcpy(ws_data, data->
data, data->
len);
949 EVP_DigestInit(&ctx, EVP_sha1());
950 EVP_DigestUpdate(&ctx, workspace, RSA_SALT_SIZE + data->
len);
951 EVP_DigestFinal(&ctx, ws_digest, NULL);
954 DVB_MhegGetPrivateKey(ws_key, MAX_RSA_KEY_SIZE, &keylen, &version);
955 if (keylen <= MAX_RSA_KEY_SIZE)
957 bio = BIO_new_mem_buf(ws_key, keylen);
960 rsa = d2i_RSAPrivateKey_bio(bio, NULL);
966 rc = RSA_sign(NID_sha1, ws_digest, SHA_DIGEST_LENGTH,
967 ws_signature, &siglen, rsa);
982 sprintf(verstr,
"%u", version);
983 reslen = strlen(verstr) + 1 + 24 + 1 + 172;
985 result->
len = reslen;
987 if (result->
data != NULL)
989 strcpy((
char *)result->
data, verstr);
990 offset = strlen(verstr);
991 result->
data[offset] =
':';
994 result->
data + offset);
995 result->
data[offset] =
':';
997 offset += EncodeBase64(ws_signature, siglen,
998 result->
data + offset);
999 result->
data[offset] =
'\0';
1003 if (workspace != NULL)
1020 static char *base64 =
1021 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1022 "abcdefghijklmnopqrstuvwxyz" 1026 for (i = 0; i <
len; i += 3)
1028 result[i / 3 * 4 ] = base64[(data[i ] >> 2) & 0x3f];
1029 result[i / 3 * 4 + 1] = base64[(data[i ] << 4 | data[i + 1] >> 4) & 0x3f];
1030 result[i / 3 * 4 + 2] = base64[(data[i + 1] << 2 | data[i + 2] >> 6) & 0x3f];
1031 result[i / 3 * 4 + 3] = base64[(data[i + 2]) & 0x3f];
1038 result[i / 3 * 4 ] = base64[(data[i ] >> 2) & 0x3f];
1039 result[i / 3 * 4 + 1] = base64[(data[i ] << 4 | data[i + 1] >> 4) & 0x3f];
1040 result[i / 3 * 4 + 2] = base64[(data[i + 1] << 2) & 0x3f];
1041 result[i / 3 * 4 + 3] =
'=';
1044 result[i / 3 * 4 ] = base64[(data[i ] >> 2) & 0x3f];
1045 result[i / 3 * 4 + 1] = base64[(data[i ] << 4) & 0x3f];
1046 result[i / 3 * 4 + 2] =
'=';
1047 result[i / 3 * 4 + 3] =
'=';
1054 return (len + 2) / 3 * 4;
1064 #ifdef INCLUDE_CONNECTED_TV
Implement MHEG5 engine control functions (i.e. start/stop etc)
void DVB_MhegSetVideoAlignment(E_VIDEO_ASPECT_MODE mode)
unsigned long MHEG5random(void)
Calculate and return a psuedo random number.
void MHEG5sendAppEngineEvent(E_ENGINE_EVENT engine_event)
Store an Engine event in the asynchronous event queue.
U16BIT original_network_id
Interface functions to DSM-CC instance for MHEG5.
MHEG5Int MHEG5GetServiceIndex(MHEG5String *serviceReference)
Ref:[1] - 3.10.6.1 and [1] - 3.10.6.3 Get the serviceIndex, a positive integer which is used to refer...
void MG_SetSubtitleMode(MHEG5Bool subtitleOn)
Set the current subtitle display mode to be either On or Off, Should only have an impact if subtitles...
E_MhegErr DVB_MhegApplicationLaunch(U8BIT *location, U8BIT *args)
Hands control of execution to another application of an arbitrary type.
void MHEG5SuppressMHEGGraphics(MHEG5Bool request)
Request that the external application toggles between showing MHEG graphics or subtitles This functio...
unsigned char * STR_DataAlloc(unsigned int size)
Implement the MHEG5 Stream Class Stream Class Defines the behaviour of a composition of continuous me...
E_MhegErr DVB_MhegIndexToDvbLocation(S32BIT serviceIndex, S_DvbLocation *pDvbLocation)
Convert Service index into full DVB location information. This being networkID, origNetworkID, transportStreamID, serviceID.
E_MhegErr DVB_MhegGetPINSupport(E_ICSPinSupport *support)
Returns the PIN support in the receiver. This MUST be a non-blocking function, returning results imme...
E_MhegErr DVB_MhegPromptForGuidance(U8BIT *restriction, BOOLEAN show)
This function asks the external application to obtain permission from the user to present IP-delivere...
E_MhegErr DVB_MhegLcnToDvbLocator(U32BIT lcn, S_DvbLocator *pDvbLocator)
Convert Logical channel number into DVB locator information.
MHEG5Bool MHEG5RequestMPEGDecoder(MHEG5Bool request)
Requests exclusive access to a MPEG decoder and video plane to display I-frames. The MPEG decoder sha...
MHEG5Bool MHEG5streamGetCurrentService(S_DVB_LOCATOR *multiplexRef)
Return the current service (i.e. the service corresponding to the currently running Video...
U16BIT transport_stream_id
void MHEG5GetDefaultService(S_DVB_LOCATOR *dvb_locator)
MHEG5Bool MHEG5parseUrl(U8BIT *buffer, U32BIT length, S_DVB_LOCATOR *multiplexRef)
Parse a DAVIC style multiplex reference or UK-DTT inherritance format URL. This can be one of the fol...
U16BIT transport_stream_id
MHEG5String MHEG5stringCopy(MHEG5String source)
<Function description>="">
BOOLEAN MH5GlueSiqNetBootInfo(S_STRING *nbinfo)
Get current MHEG net boot info existance and nb info string.
U16BIT original_network_id
DVB Video functions are required by MHEG5 engine. All required functions should be non-blocking...
string parsing utility functions for MHEG5
E_MhegErr DVB_MhegSuppressMHEGGraphics(BOOLEAN suppress)
Toggle between displaying MHEG graphics and subtitles on platforms that do not support them both symu...
DVB Service information functions are required by MHEG5 engine. All required functions should be non-...
This file defines the profile for the MHEG engine.
void MHEG5TuneIndexInfo(MHEG5Int tuneInfo)
Sets the way the application expects the receiver is to perform all subsequence application initiated...
MHEG5String MHEG5GetBootInfo(MHEG5Bool *InfoResultVal)
Tell whether a network_boot_info sub-descriptor has been found and received. If so, returns the value of the NB_info field of the network_boot_info sub-descriptor. This function is used by the GetBootInfo resident program. See UK1.06 profile section 3.10.7.3.
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
void DVB_MhegSetAspectRatio(E_ASPECT_RATIO aspect)
Set display aspect ratio.
MHEG5Int MHEG5GetDisplayAspectRatio(void)
Find the setting of the attached display's aspect ratio This function is used by the GetDisplayAspect...
E_MhegErr DVB_MhegRequestMPEGDecoder(E_DecoderRequest request, BOOLEAN *pResult)
This function requests exclusive access to a MPEG decoder and video plane to display I-frames...
#define RSA_SIGNATURE_SIZE
Mheg5 logging and debug printing.
Common Interface functions required by MHEG5 engine.
MHEG5Bool MHEG5GetBasicSI(MHEG5Int serviceIndex, MHEG5Int *networkID, MHEG5Int *origNetworkID, MHEG5Int *transportStreamID, MHEG5Int *serviceID)
Returns a series of integers representing basic Service Information (SI) about a service. The service is identified by means of a receiver specific "ServiceIndex". This integer can be determined by means of the SI_GetServiceIndex resident program (see 3.10.6.1, "SI_GetServiceIndex", on page 3-20). This function is used by the SI_TuneIndexInfo resident program. See UK1.06 profile section 3.10.6.3.
void MHEG5restoreReceiverDefaults(void)
Restore receiver defaults as described in section 3.12.10 of the 1.06 profile.
MHEG5Bool MHEG5parseDvbUrl(U8BIT *buffer, U32BIT length, S_DVB_LOCATOR *dvb_loc)
Parse a DAVIC style multiplex reference or UK-DTT inherritance format URL. This can be one of the fol...
E_ASPECT_RATIO DVB_MhegGetDisplayAspectRatio(void)
Get display aspect ratio.
void MHEG5setInputEventRegister(MHEG5Int inputEventRegister)
Change the input event register. This indicates which keypresses the MHEG-5 engine requires to be pas...
This file describes the interface to an MHEG5 component for CI. For example, MHEG5_StartCIApplication...
E_NW_LINK_STATUS STB_NWGetLinkStatus(void)
Get the ethernet link status.
Video Scaling / Positioning functionality.
S32BIT MHEG5GetCurrentServiceIndex(void)
E_MhegErr DVB_MhegDvbLocatorToIndex(S_DvbLocator *pDvbLocator, S32BIT *pServiceIndex)
Get a DVB implementation dependant service index - an integer greater or equal to 0...
int MHEG5parseLcn(U8BIT *buf, U8BIT *end)