Petri Hintukainen pushed to branch master at VideoLAN / libaacs
Commits:
e7955b17 by npzacs at 2022-03-07T15:20:20+02:00
Add simple tool to dump cci file content
- - - - -
09fc423b by npzacs at 2022-03-07T15:20:36+02:00
Add const
- - - - -
37b8a480 by hpi1 at 2022-03-07T15:22:29+02:00
Add missing include
- - - - -
5 changed files:
- Makefile.am
- + src/devtools/cci_dump.c
- src/file/dirs_win32.c
- src/libaacs/cci.c
- src/libaacs/cci.h
Changes:
=====================================
Makefile.am
=====================================
@@ -93,7 +93,7 @@ dist-hook:
# programs
#
-noinst_PROGRAMS = parser_test uk_dump mkb_dump
+noinst_PROGRAMS = parser_test uk_dump mkb_dump cci_dump
bin_PROGRAMS = aacs_info
parser_test_SOURCES = \
@@ -121,6 +121,15 @@ mkb_dump_SOURCES = \
src/util/logging.c
mkb_dump_CFLAGS = -std=c99
+cci_dump_SOURCES = \
+ src/devtools/cci_dump.c \
+ src/devtools/read_file.h \
+ src/libaacs/cci.h \
+ src/libaacs/cci_data.h \
+ src/libaacs/cci.c \
+ src/util/logging.c
+cci_dump_CFLAGS = -std=c99
+
aacs_info_SOURCES = src/examples/aacs_info.c
aacs_info_CFLAGS = -std=c99
aacs_info_LDADD = libaacs.la $(LIBUDFREAD_LIBS)
=====================================
src/devtools/cci_dump.c
=====================================
@@ -0,0 +1,125 @@
+/*
+ * This file is part of libaacs
+ * Copyright (C) 2020 VideoLAN
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "util/strutl.h"
+#include "util/macro.h"
+#include "libaacs/cci.h"
+#include "libaacs/cci_data.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "read_file.h"
+
+static void _cci_dump(const AACS_CCI *cci)
+{
+ const AACS_BASIC_CCI *bcci = cci_get_basic_cci(cci);
+ unsigned title;
+
+ if (!bcci) {
+ fprintf(stderr, "No AACS Basic CCI found\n");
+ return;
+ }
+
+ printf("Encrypted CPS unit: %s\n\n", (!cci_is_unencrypted(cci)) ? "Yes" :
"No");
+ if (bcci->cci == 0)
+ printf("Encryption Plus Non-assertion
%d\n", bcci->epn);
+ printf("Copy Control Information %d
(0 = copy freely)\n", bcci->cci);
+ printf("High Definition Analog Output in High Definition Analog Form
%d\n", bcci->image_constraint);
+ printf("Output of decrypted content is allowed only for Digital Outputs
%d\n", bcci->digital_only);
+ printf("Analog copy protection information
%d\n", bcci->apstb);
+ printf("\nTitles: %d\n", bcci->num_titles);
+
+ printf("Basic titles: ");
+ for (title = 0; title < bcci->num_titles; title++)
+ if (!(bcci->title_type[title >> 3] & (1 << (title & 7))))
+ printf("%d ", title);
+ printf("\nEnhanced titles: ");
+ for (title = 0; title < bcci->num_titles; title++)
+ if (bcci->title_type[title >> 3] & (1 << (title & 7)))
+ printf("%d ", title);
+ printf("\n");
+}
+
+static void _raw_dump(const uint8_t *data, size_t size)
+{
+ uint32_t mask = 0;
+ size_t l, b;
+
+ printf("Raw data:\n");
+
+ for (l = 0; l < size; l += 16) {
+
+ /* skip large empty areas */
+ mask <<= 8;
+ for (b = 0; b < 32 && l+b < size; b++)
+ mask |= data[l + b];
+ if (!mask)
+ continue;
+
+ printf("%04lx: ", (long)l);
+ for (b = 0; b < 8 && l+b < size; b++)
+ printf("%02x ", data[l + b]);
+ printf(" ");
+ for (b = 8; b < 16 && l+b < size; b++)
+ printf("%02x ", data[l + b]);
+ printf(" ");
+ for (b = 0; b < 8 && l+b < size; b++)
+ if (data[l+b]) printf("%02x ", data[l + b]); else printf(" ");
+ printf(" ");
+ for (b = 8; b < 16 && l+b < size; b++)
+ if (data[l+b]) printf("%02x ", data[l + b]); else printf(" ");
+ printf("\n");
+ }
+}
+
+int main (int argc, char **argv)
+{
+ AACS_CCI *cci;
+ uint8_t *data;
+ size_t size;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: cci_dump <CPSUnit?????.cci>\n");
+ exit(-1);
+ }
+
+ size = _read_file(argv[1], 16, 1024*1024, &data);
+ if (!size) {
+ exit(-1);
+ }
+
+ printf("CCI file size: %zu bytes\n", size);
+ cci = cci_parse(data, size);
+
+ if (!cci) {
+ fprintf(stderr, "Parsing failed\n");
+ exit(-1);
+ }
+
+ _cci_dump(cci);
+
+ _raw_dump(data, size);
+
+ cci_free(&cci);
+ free(data);
+
+ return 0;
+}
=====================================
src/file/dirs_win32.c
=====================================
@@ -24,6 +24,7 @@
#include "dirs.h"
#include "util/logging.h"
+#include "util/macro.h"
#include <stdio.h>
#include <string.h>
@@ -66,10 +67,10 @@ char *file_get_data_home(void)
/* Get the "Application Data" folder for the user */
if (S_OK == SHGetFolderPathW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
NULL, SHGFP_TYPE_CURRENT, wdir)) {
- appdir = _wide_to_utf8(wdir);
- if (appdir) {
- return appdir;
- }
+ char *appdir = _wide_to_utf8(wdir);
+ if (appdir) {
+ return appdir;
+ }
}
BD_DEBUG(DBG_FILE, "Can't find user configuration directory !\n");
=====================================
src/libaacs/cci.c
=====================================
@@ -171,12 +171,12 @@ void cci_free(AACS_CCI **pp)
}
}
-int cci_is_unencrypted(AACS_CCI *cci)
+int cci_is_unencrypted(const AACS_CCI *cci)
{
unsigned int ii;
for (ii = 0; ii < cci->num_entry; ii++) {
- AACS_CCI_ENTRY *e = &cci->entry[ii];
+ const AACS_CCI_ENTRY *e = &cci->entry[ii];
if (e->type == cci_AACS_ENHANCED_TITLE_USAGE) {
BD_DEBUG(DBG_CCI, "Enhanced title usage CCI found\n");
@@ -212,7 +212,7 @@ int cci_is_unencrypted(AACS_CCI *cci)
return 0;
}
-AACS_BASIC_CCI *cci_get_basic_cci(AACS_CCI *cci)
+const AACS_BASIC_CCI *cci_get_basic_cci(const AACS_CCI *cci)
{
unsigned int ii;
=====================================
src/libaacs/cci.h
=====================================
@@ -29,8 +29,8 @@ typedef struct aacs_cci AACS_CCI;
BD_PRIVATE AACS_CCI *cci_parse(const void *data, size_t len);
BD_PRIVATE void cci_free(AACS_CCI **);
-BD_PRIVATE int cci_is_unencrypted(AACS_CCI *cci);
+BD_PRIVATE int cci_is_unencrypted(const AACS_CCI *cci);
-BD_PRIVATE struct aacs_basic_cci *cci_get_basic_cci(AACS_CCI *cci);
+BD_PRIVATE const struct aacs_basic_cci *cci_get_basic_cci(const AACS_CCI *cci);
#endif /* AACS_CCI_H_ */
View it on GitLab:
https://code.videolan.org/videolan/libaacs/-/compare/125eb6d3ae5a028e91fa36939efbbd8a2a4317c5...37b8a4807aedf7ff86751d2c4d9a68efdc665d2f
--
View it on GitLab:
https://code.videolan.org/videolan/libaacs/-/compare/125eb6d3ae5a028e91fa36939efbbd8a2a4317c5...37b8a4807aedf7ff86751d2c4d9a68efdc665d2f
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
_______________________________________________
libaacs-devel mailing list
libaacs-devel@videolan.org
https://mailman.videolan.org/listinfo/libaacs-devel