Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tvheadend (TVH) OSCam support #5504

Merged
merged 7 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cross/ffmpeg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ DEPENDS += cross/fdk-aac
CONFIGURE_ARGS += --enable-libfdk-aac --enable-nonfree

ifeq ($(call version_lt, ${TCVERSION}, 7.0),1)
ifneq ($(findstring $(ARCH),$(ARMv5_ARCHS) $(ARMv7L_ARCHS) $(OLD_PPC_ARCHS)),$(ARCH))
# Newer libass requires harfbuzz which in turns requires c++ from gcc >= 4.9 (88f6281-6.1 = gcc-4.6.4)
ifneq ($(findstring $(ARCH),$(ARMv5_ARCHS) $(OLD_PPC_ARCHS)),$(ARCH))
# libass requires harfbuzz which in turns requires c++ from gcc >= 4.8 (88f6281-6.1 = gcc-4.6.4)
DEPENDS += cross/libass
CONFIGURE_ARGS += --enable-libass
endif
Expand Down
3 changes: 2 additions & 1 deletion cross/harfbuzz_3/Makefile → cross/harfbuzz_2/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PKG_NAME = harfbuzz
# latest version that can be built with ARMv7 toolchain
PKG_VERS = 3.0.0
# Not considering v3.x as failing to work with libass
PKG_VERS = 2.9.1
PKG_EXT = tar.xz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/harfbuzz/harfbuzz/releases/download/$(PKG_VERS)
Expand Down
6 changes: 3 additions & 3 deletions cross/harfbuzz_3/PLIST → cross/harfbuzz_2/PLIST
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
lnk:lib/libharfbuzz-gobject.so
lnk:lib/libharfbuzz-gobject.so.0
lib:lib/libharfbuzz-gobject.so.0.30000.0
lib:lib/libharfbuzz-gobject.so.0.20901.0
lnk:lib/libharfbuzz-subset.so
lnk:lib/libharfbuzz-subset.so.0
lib:lib/libharfbuzz-subset.so.0.30000.0
lib:lib/libharfbuzz-subset.so.0.20901.0
lnk:lib/libharfbuzz.so
lnk:lib/libharfbuzz.so.0
lib:lib/libharfbuzz.so.0.30000.0
lib:lib/libharfbuzz.so.0.20901.0
3 changes: 3 additions & 0 deletions cross/harfbuzz_2/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
harfbuzz-2.9.1.tar.xz SHA1 081beab70a8afaed64a71c405b1e65e2f5d5eb40
harfbuzz-2.9.1.tar.xz SHA256 0edcc980f526a338452180e701d6aba6323aef457b6686976a7d17ccbddc51cf
harfbuzz-2.9.1.tar.xz MD5 f2cec0adcfea1de89b47de4b8e682808
3 changes: 0 additions & 3 deletions cross/harfbuzz_3/digests

This file was deleted.

12 changes: 11 additions & 1 deletion cross/libass/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/libass/libass/releases/download/$(PKG_VERS)
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/freetype cross/fribidi cross/fontconfig cross/harfbuzz
DEPENDS = cross/freetype cross/fribidi cross/fontconfig
OPTIONAL_DEPENDS = cross/harfbuzz cross/harfbuzz_2

# harfbuzz
UNSUPPORTED_ARCHS = $(ARMv5_ARCHS) $(OLD_PPC_ARCHS)
include ../../mk/spksrc.archs.mk
ifeq ($(findstring $(ARCH),$(ARMv7L_ARCHS)),$(ARCH))
DEPENDS += cross/harfbuzz_2
else
DEPENDS += cross/harfbuzz
endif

HOMEPAGE = https://github.com/libass/libass
COMMENT = libass is a portable subtitle renderer for the ASS/SSA (Advanced Substation Alpha/Substation Alpha) subtitle format.
Expand Down
1 change: 1 addition & 0 deletions cross/libdvbcsa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CONFIGURE_ARGS = --enable-shared
CONFIGURE_ARGS += --prefix=$(INSTALL_PREFIX)

PRE_CONFIGURE_TARGET = libdvbcsa_pre_configure
PATCHES_LEVEL = 1

ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS) $(ARMv7L_ARCHS) $(ARMv8_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --enable-neon
Expand Down
181 changes: 181 additions & 0 deletions cross/libdvbcsa/patches/001-libdvbcsa-OSCam-support_v2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
diff --git a/README b/README
index f480e67..f41b865 100644
--- a/README
+++ b/README
@@ -135,6 +135,12 @@ Example:
dvbcsa_bs_encrypt(key, b, 184);


+ DVBCSA_KEY_ECM
+
+ unsigned char ecm = (ecm_caid >> 8 == 0x09 && (ecm_data[2] - ecm_data[4]) == 4) ? ecm_data[21] : 0;
+ dvbcsa_bs_key_set_ecm(ecm, cw, key);
+
+
Portability
===========

diff --git a/src/dvbcsa/dvbcsa.h b/src/dvbcsa/dvbcsa.h
index c7e9c59..4c37414 100644
--- a/src/dvbcsa/dvbcsa.h
+++ b/src/dvbcsa/dvbcsa.h
@@ -93,6 +93,10 @@ void dvbcsa_bs_key_free(struct dvbcsa_bs_key_s *key);

void dvbcsa_bs_key_set(const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key);

+#ifndef DVBCSA_KEY_ECM
+#define DVBCSA_KEY_ECM 1
+void dvbcsa_bs_key_set_ecm(const unsigned char ecm, const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key);
+#endif
/** get maximum number of packet per batch */

unsigned int dvbcsa_bs_batch_size(void);
diff --git a/src/dvbcsa_bs_key.c b/src/dvbcsa_bs_key.c
index e2fcf55..4c5570b 100644
--- a/src/dvbcsa_bs_key.c
+++ b/src/dvbcsa_bs_key.c
@@ -63,3 +63,41 @@ dvbcsa_bs_key_set (const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key)
}
}

+#if DVBCSA_KEY_ECM > 0
+void
+dvbcsa_bs_key_set_ecm (const unsigned char ecm, const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key)
+{
+ dvbcsa_keys_t kk;
+ int i;
+
+ /* precalculations for stream */
+
+ uint64_t ck = dvbcsa_load_le64(cw);
+
+ for (i = 0; i < DVBCSA_CWBITS_SIZE; i++)
+ key->stream[i] = (ck >> (i^4)) & 1 ? BS_VAL8(ff) : BS_VAL8(00);
+
+ /* precalculations for block */
+
+ dvbcsa_key_schedule_block_ecm(ecm, cw, kk);
+
+ for (i = 0; i < DVBCSA_KEYSBUFF_SIZE; i++)
+ {
+#if BS_BATCH_SIZE == 32
+ *(dvbcsa_u32_aliasing_t *)(key->block + i) = kk[i] * 0x01010101;
+
+#elif BS_BATCH_SIZE == 64
+ *(dvbcsa_u64_aliasing_t *)(key->block + i) = kk[i] * 0x0101010101010101ULL;
+
+#elif BS_BATCH_SIZE > 64 && BS_BATCH_SIZE % 64 == 0
+ uint64_t v = kk[i] * 0x0101010101010101ULL;
+ int j;
+
+ for (j = 0; j < BS_BATCH_BYTES / 8; j++)
+ *((dvbcsa_u64_aliasing_t *)(key->block + i) + j) = v;
+#else
+# error
+#endif
+ }
+}
+#endif
diff --git a/src/dvbcsa_key.c b/src/dvbcsa_key.c
index 1ff17e0..70e7d7e 100644
--- a/src/dvbcsa_key.c
+++ b/src/dvbcsa_key.c
@@ -585,3 +585,20 @@ dvbcsa_key_schedule_block(const dvbcsa_cw_t cw, uint8_t * kk)
kk[i*8+j] = (k[i]>>(j*8)) ^ i;
}

+#if DVBCSA_KEY_ECM > 0
+void
+dvbcsa_key_schedule_block_ecm(const unsigned char ecm, const dvbcsa_cw_t cw, uint8_t * kk)
+{
+ uint64_t k[7];
+ int i, j;
+
+ k[6] = dvbcsa_load_le64_ecm(ecm, cw);
+ for (i = 6; i > 0; i--)
+ k[i - 1] = dvbcsa_key_permute_block(k[i]);
+
+ for (i = 0; i < 7; i++)
+ for (j = 0; j < 8; j++)
+ kk[i*8+j] = (k[i]>>(j*8)) ^ i;
+}
+#endif
+
diff --git a/src/dvbcsa_pv.h b/src/dvbcsa_pv.h
index 83753b1..d4205ab 100644
--- a/src/dvbcsa_pv.h
+++ b/src/dvbcsa_pv.h
@@ -87,6 +87,27 @@ struct dvbcsa_key_s
};

extern const uint8_t dvbcsa_block_sbox[256];
+#if DVBCSA_KEY_ECM > 0
+static const uint8_t csa_block_perm_ecm[256] =
+{
+ 0x00, 0x02, 0x80, 0x82, 0x20, 0x22, 0xa0, 0xa2, 0x04, 0x06, 0x84, 0x86, 0x24, 0x26, 0xa4, 0xa6,
+ 0x40, 0x42, 0xc0, 0xc2, 0x60, 0x62, 0xe0, 0xe2, 0x44, 0x46, 0xc4, 0xc6, 0x64, 0x66, 0xe4, 0xe6,
+ 0x01, 0x03, 0x81, 0x83, 0x21, 0x23, 0xa1, 0xa3, 0x05, 0x07, 0x85, 0x87, 0x25, 0x27, 0xa5, 0xa7,
+ 0x41, 0x43, 0xc1, 0xc3, 0x61, 0x63, 0xe1, 0xe3, 0x45, 0x47, 0xc5, 0xc7, 0x65, 0x67, 0xe5, 0xe7,
+ 0x08, 0x0a, 0x88, 0x8a, 0x28, 0x2a, 0xa8, 0xaa, 0x0c, 0x0e, 0x8c, 0x8e, 0x2c, 0x2e, 0xac, 0xae,
+ 0x48, 0x4a, 0xc8, 0xca, 0x68, 0x6a, 0xe8, 0xea, 0x4c, 0x4e, 0xcc, 0xce, 0x6c, 0x6e, 0xec, 0xee,
+ 0x09, 0x0b, 0x89, 0x8b, 0x29, 0x2b, 0xa9, 0xab, 0x0d, 0x0f, 0x8d, 0x8f, 0x2d, 0x2f, 0xad, 0xaf,
+ 0x49, 0x4b, 0xc9, 0xcb, 0x69, 0x6b, 0xe9, 0xeb, 0x4d, 0x4f, 0xcd, 0xcf, 0x6d, 0x6f, 0xed, 0xef,
+ 0x10, 0x12, 0x90, 0x92, 0x30, 0x32, 0xb0, 0xb2, 0x14, 0x16, 0x94, 0x96, 0x34, 0x36, 0xb4, 0xb6,
+ 0x50, 0x52, 0xd0, 0xd2, 0x70, 0x72, 0xf0, 0xf2, 0x54, 0x56, 0xd4, 0xd6, 0x74, 0x76, 0xf4, 0xf6,
+ 0x11, 0x13, 0x91, 0x93, 0x31, 0x33, 0xb1, 0xb3, 0x15, 0x17, 0x95, 0x97, 0x35, 0x37, 0xb5, 0xb7,
+ 0x51, 0x53, 0xd1, 0xd3, 0x71, 0x73, 0xf1, 0xf3, 0x55, 0x57, 0xd5, 0xd7, 0x75, 0x77, 0xf5, 0xf7,
+ 0x18, 0x1a, 0x98, 0x9a, 0x38, 0x3a, 0xb8, 0xba, 0x1c, 0x1e, 0x9c, 0x9e, 0x3c, 0x3e, 0xbc, 0xbe,
+ 0x58, 0x5a, 0xd8, 0xda, 0x78, 0x7a, 0xf8, 0xfa, 0x5c, 0x5e, 0xdc, 0xde, 0x7c, 0x7e, 0xfc, 0xfe,
+ 0x19, 0x1b, 0x99, 0x9b, 0x39, 0x3b, 0xb9, 0xbb, 0x1d, 0x1f, 0x9d, 0x9f, 0x3d, 0x3f, 0xbd, 0xbf,
+ 0x59, 0x5b, 0xd9, 0xdb, 0x79, 0x7b, 0xf9, 0xfb, 0x5d, 0x5f, 0xdd, 0xdf, 0x7d, 0x7f, 0xfd, 0xff
+};
+#endif

void dvbcsa_block_decrypt (const dvbcsa_keys_t key, const dvbcsa_block_t in, dvbcsa_block_t out);
void dvbcsa_block_encrypt (const dvbcsa_keys_t key, const dvbcsa_block_t in, dvbcsa_block_t out);
@@ -95,6 +116,9 @@ void dvbcsa_stream_xor (const dvbcsa_cw_t cw, const dvbcsa_block_t iv,
uint8_t *stream, unsigned int len);

void dvbcsa_key_schedule_block(const dvbcsa_cw_t cw, uint8_t * kk);
+#if DVBCSA_KEY_ECM > 0
+void dvbcsa_key_schedule_block_ecm(const unsigned char ecm, const dvbcsa_cw_t cw, uint8_t * kk);
+#endif

DVBCSA_INLINE static inline void
dvbcsa_xor_64 (uint8_t *b, const uint8_t *a)
@@ -141,6 +165,35 @@ dvbcsa_load_le64(const uint8_t *p)
#endif
}

+#if DVBCSA_KEY_ECM > 0
+DVBCSA_INLINE static inline uint64_t
+dvbcsa_load_le64_ecm(const unsigned char ecm, const uint8_t *p)
+{
+ dvbcsa_block_t W;
+ memcpy(W, p, sizeof(W));
+ if (ecm == 4)
+ {
+ W[0] = csa_block_perm_ecm[p[0]];
+ W[4] = csa_block_perm_ecm[p[4]];
+ }
+#if defined(DVBCSA_ENDIAN_LITTLE)
+ uint64_t i;
+ memcpy(&i, W, 8);
+ return i;
+#else
+ return (uint64_t)( ((uint64_t)W[7] << 56) |
+ ((uint64_t)W[6] << 48) |
+ ((uint64_t)W[5] << 40) |
+ ((uint64_t)W[4] << 32) |
+ ((uint64_t)W[3] << 24) |
+ ((uint64_t)W[2] << 16) |
+ ((uint64_t)W[1] << 8 ) |
+ (uint64_t)W[0]
+ );
+#endif
+}
+# endif
+
DVBCSA_INLINE static inline void
dvbcsa_store_le64(uint8_t *p, const uint64_t w)
{
5 changes: 2 additions & 3 deletions cross/libraqm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ PKG_DIST_SITE = https://github.com/HOST-Oman/libraqm/releases/download/v$(PKG_VE
PKG_DIR = raqm-$(PKG_VERS)

DEPENDS = cross/freetype cross/fribidi
OPTIONAL_DEPENDS = cross/harfbuzz cross/harfbuzz_3
OPTIONAL_DEPENDS = cross/harfbuzz cross/harfbuzz_2

# harfbuzz
UNSUPPORTED_ARCHS = $(ARMv5_ARCHS) $(OLD_PPC_ARCHS)
include ../../mk/spksrc.archs.mk
ifeq ($(findstring $(ARCH),$(ARMv7L_ARCHS)),$(ARCH))
DEPENDS += cross/harfbuzz_3
DEPENDS += cross/harfbuzz_2
else
DEPENDS += cross/harfbuzz
endif


HOMEPAGE = https://host-oman.github.io/libraqm/
COMMENT = Raqm is a small library that encapsulates the logic for complex text layout and provides a convenient API.
LICENSE = MIT
Expand Down
4 changes: 2 additions & 2 deletions cross/libtasn1/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PKG_NAME = libtasn1
PKG_VERS = 4.17.0
PKG_VERS = 4.19.0
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://ftp.gnu.org/gnu/$(PKG_NAME)
Expand All @@ -13,6 +13,6 @@ LICENSE = LGPLv2.1

GNU_CONFIGURE = 1
CONFIGURE_ARGS = --disable-gcc-warnings --disable-static
ADDITIONAL_CPPFLAGS = -std=c99
ADDITIONAL_CFLAGS = -std=gnu99

include ../../mk/spksrc.cross-cc.mk
2 changes: 1 addition & 1 deletion cross/libtasn1/PLIST
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ bin:bin/asn1Decoding
bin:bin/asn1Parser
lnk:lib/libtasn1.so
lnk:lib/libtasn1.so.6
lib:lib/libtasn1.so.6.6.1
lib:lib/libtasn1.so.6.6.3
6 changes: 3 additions & 3 deletions cross/libtasn1/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libtasn1-4.17.0.tar.gz SHA1 327c3f1305a502dbceb098838a9baed2f0449ddd
libtasn1-4.17.0.tar.gz SHA256 ece7551cea7922b8e10d7ebc70bc2248d1fdd73351646a2d6a8d68a9421c45a5
libtasn1-4.17.0.tar.gz MD5 c46f6eb3bd1287031ae5d36465094402
libtasn1-4.19.0.tar.gz SHA1 9c4b6616de65513a0a4d27e0b7f25184391ca8fd
libtasn1-4.19.0.tar.gz SHA256 1613f0ac1cf484d6ec0ce3b8c06d56263cc7242f1c23b30d82d23de345a63f7a
libtasn1-4.19.0.tar.gz MD5 f701ab57eb8e7d9c105b2cd5d809b29a
4 changes: 2 additions & 2 deletions cross/pango/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/fontconfig cross/cairo cross/glib
OPTIONAL_DEPENDS = cross/harfbuzz cross/harfbuzz_3
OPTIONAL_DEPENDS = cross/harfbuzz cross/harfbuzz_2

include ../../mk/spksrc.archs.mk
ifneq ($(findstring $(ARCH),$(ARMv5_ARCHS) $(OLD_PPC_ARCHS)),$(ARCH))
# REMARKS: we must build glib before harfbuzz to get harbuzz glib integration (hb-glib.h)
ifeq ($(findstring $(ARCH),$(ARMv7L_ARCHS)),$(ARCH))
DEPENDS += cross/harfbuzz_3
DEPENDS += cross/harfbuzz_2
else
DEPENDS += cross/harfbuzz
endif
Expand Down
15 changes: 10 additions & 5 deletions cross/tvheadend/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PKG_NAME = tvheadend
PKG_VERS = 4.3
PKG_EXT = tar.gz
# git hash from November 10th 2022
PKG_GIT_HASH = 52c3ed3ef17eeccddc6a4cf7c0d7151c2823438f
# git hash from November 28th 2022
PKG_GIT_HASH = d8854960361b0fb6846f0912f509dfad61f3ccbf
PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/tvheadend/tvheadend/archive
PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT)
Expand Down Expand Up @@ -48,19 +48,24 @@ ifeq ($(wildcard $(FFMPEG_DIR)),)
DEPENDS += cross/ffmpeg
endif

include ../../mk/spksrc.cross-cc.mk

ifeq ($(call version_lt, $(TC_GCC), 5.0),1)
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
ADDITIONAL_CFLAGS += -std=gnu11
else
CONFIGURE_ARGS += --nowerror
ADDITIONAL_CFLAGS += -std=gnu99
endif

include ../../mk/spksrc.common.mk

ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --enable-vaapi
ifeq ($(wildcard $(FFMPEG_DIR)),)
DEPENDS += cross/libva
endif
endif

include ../../mk/spksrc.cross-cc.mk

.PHONY: tvheadend_pre_configure
tvheadend_pre_configure:
# Fix so mkbundle finds the pngquant binary
Expand Down
6 changes: 3 additions & 3 deletions cross/tvheadend/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tvheadend-git52c3ed3ef17eeccddc6a4cf7c0d7151c2823438f.tar.gz SHA1 aaa5235fa5eabacfc1d647ff31febfe3674f151a
tvheadend-git52c3ed3ef17eeccddc6a4cf7c0d7151c2823438f.tar.gz SHA256 7602af0481481e112435cedf8f148eb18f2f3e67b169973946edb7f6cbf02e6f
tvheadend-git52c3ed3ef17eeccddc6a4cf7c0d7151c2823438f.tar.gz MD5 db678d1e6856ed7c4986398ba3361a99
tvheadend-gitd8854960361b0fb6846f0912f509dfad61f3ccbf.tar.gz SHA1 19923b760f08548272bb279b0bccdcfcae7dcc51
tvheadend-gitd8854960361b0fb6846f0912f509dfad61f3ccbf.tar.gz SHA256 91a7c27230d8413d4cc84f5470feb55f9f930ed29a727b91daee1ebae7c254be
tvheadend-gitd8854960361b0fb6846f0912f509dfad61f3ccbf.tar.gz MD5 b58f9f2d0c8c889d3028bfcbf456704f
Loading