OSCam Güncel Latest Oscam with emu

  • Konuyu Başlatan Konuyu Başlatan kingsman
  • Başlangıç tarihi Başlangıç tarihi
oscam-git11954-802

tests: enable reliable standalone test builds and proper CI failure reporting
* build: keep test binaries unsigned

Skip the link-stage signing step when BUILD_TESTS is enabled in the
Makefile. The tests target already avoids strip/sign/upx when copying
tests.bin from tests.bin.debug, but tests.bin.debug itself was still
passed through SIGN_COMMAND_OSCAM. With signing enabled this could still
reassemble stale UPX split files into the test binary before the copy
step, reintroducing the failure the tests build path was meant to avoid.

* build: add BUILD_TESTS support to CMake and skip strip/sign/upx

Makefile: SIGN_COMMAND_OSCAM reassembles any leftover UPX split parts
(upx.aa / upx.ab from a previous build) onto the current target — on
the second invocation this re-creates a UPX-compressed
tests.bin.debug, so the subsequent strip fails with 'input file has no
sections' and aborts the build. The test binary does not need to be
stripped, signed or compressed. Skip all three steps when
BUILD_TESTS=1 and just copy .debug → bin.

CMakeLists.txt previously had no tests target at all — 'make tests'
only worked via the Makefile. Add a BUILD_TESTS option (OFF by
default) that mirrors the Makefile path:
- pulls tests.c into the csoscam library
- adds -DBUILD_TESTS=1 to the global compile definitions
- renames the executable to tests.bin and links it without the
strip/sign/upx POST_BUILD commands
- exposes a 'run-tests' custom target that builds the binary and
executes it in the build tree

Standard usage:
mkdir build-tests && cd build-tests
cmake -DBUILD_TESTS=ON -DUSE_SSL=1 -DUSE_LIBCRYPTO=1 ..
make run-tests

* tests: add crypto test vectors

Extend run_all_tests() with known-answer tests against the crypto API
surface oscam uses:

- MD5 RFC 1321 Appendix A.5 + __md5_crypt ($1$ WebIf hashes)
- SHA1 FIPS 180-1 (short vectors, one-shot and streaming)
- SHA256 FIPS 180-2 + 1M 'a' long-stream via mbedtls_sha256
- MDC2 OpenSSL-1.0 mdc2test.c KAT + streaming split
- AES ECB NIST SP 800-38A F.1.1/F.1.3/F.1.5 (AES-128/192/256)
- AES CBC NIST SP 800-38A F.2.1/F.2.5, single + chunked (IV chain)
- AesCtx cscrypt/fast_aes ECB + CBC
- AES void* oscam-aes.c wrappers (aes_cbc_encrypt/decrypt,
aes_encrypt_idx, aes_decrypt)
- AES DB aes_decrypt_from_list / aes_present round-trip
- IDEA Ascom KAT + CBC reversal
- RC6 RC6 paper all-zero KAT
- DES ECB (Stallings) + single-block via schedule
- DES-CBC verified against openssl -des-cbc
- 3DES-EDE2-CBC KAT verified against openssl -des-ede-cbc
- 3DES-ECB3 reversal
- BN mod_exp, bn2bin, num_bytes, mod_inverse, mul,
add_word, sub_word, cmp, copy
- DES parity helpers (des_set_odd_parity / _all)

Exit status reflects failure count so CI can gate on it.

* tests: return failure count and exit with correct status

The test binary previously always exited with status 0, regardless of
whether any tests failed. This made it useless in CI: a regression would
print errors to stdout but the process would still report success.

This commit fixes that end-to-end, and addresses several related issues
found while doing so.

Exit status
-----------
run_all_tests() now returns int (total failure count) instead of void.
run_tests() in oscam.c passes that value to exit():

exit(run_all_tests() ? EXIT_FAILURE : EXIT_SUCCESS);

A non-zero failure count now produces a non-zero exit code. A summary
line is printed at the end of the run:

Summary: N failure(s)

Type-safe adapter layer
-----------------------
The test_type struct previously stored function pointers cast to generic
types (CHK_FN *, MK_T_FN *, etc.) in order to accommodate different
concrete data types. Calling a function through a mismatched pointer
type is undefined behavior in C, even when the signatures are similar.

This is replaced with a DEFINE_TEST_ADAPTERS macro that generates a set
of correctly-typed wrapper functions for each data type:

DEFINE_TEST_ADAPTERS(ecm_whitelist, ECM_WHITELIST, ewnum);
DEFINE_TEST_ADAPTERS(ecm_hdr_whitelist, ECM_HDR_WHITELIST, ehnum);
...

Each expansion produces chk_*, mk_t_*, clear_*, clone_*, and has_data_*
adapters that cast the void * argument to the correct concrete type and
forward the call. The struct fields now hold pointers to these adapters
with no casts required.

Clone failure detection
-----------------------
A new HAS_DATA_FN callback is added to test_type. It reports whether a
parsed data structure contains any entries (by checking the count field
named in the macro, e.g. ewnum, ehnum). This enables a meaningful
distinction in the test loop:

- If parsing produced data and clone_fn returns false, that is a clone
error and is reported as such with a dedicated "=== CLONE ERROR ==="
message.
- If parsing produced no data and clone returns false, that is expected
behavior and is not counted as a failure.

Previously a failed clone would silently fall through, potentially
producing misleading output from stale data.
 

Ekli dosyalar

oscam-git11955-802

tests: gate run_aes_key_list_tests with READER_VIACCESS
The AES key-list helpers it exercises — add_aes_entry,
aes_clear_entries, aes_decrypt_from_list, aes_present — are
defined in oscam-aes.c under #ifdef READER_VIACCESS, since
Viaccess is the only consumer. Calling them unconditionally
from run_crypto_tests() makes tests.bin fail to link on every
build without the Viaccess reader:

oscam-aes.c: undefined reference to add_aes_entry
aes_clear_entries
aes_decrypt_from_list
aes_present

Reproduces e.g. on the cmake test build for the VuZero4k target
with MODULE_CCCAM enabled (so WITH_LIB_AES is on) but no readers.

Wrap both the run_aes_key_list_tests() definition and its
caller in run_crypto_tests() in #ifdef READER_VIACCESS, matching
the gating of the helpers themselves.
 

Ekli dosyalar

Geri
Üst