Projects
Essentials
libaacs
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 11
View file
libaacs.changes
Changed
@@ -1,4 +1,21 @@ ------------------------------------------------------------------- +Sat Sep 5 08:52:47 UTC 2020 - Luigi Baldoni <aloisio@gmx.com> + +2020-07-22: Version 0.11.0 + * Add more AACS2 support (still not complete). + * Add support for partial unit keys in KEYDB.CFG. + * Improve opening of UHD discs (~ 10 seconds faster). + * Improve large KEYDB.CFG parsing (~ 4 times faster). + * Improve error resilience. + * Reduce memory usage (does not depend on config file size + anymore). + * Fix segfault on macOS when MMC opening fails. + * Fix memory leak with multiple UK entries in KEYDB.cfg file. + * Fix AACS2 with multiple unit keys. + * Fix include flags order (do not include wrong headers + outside of source tree). + +------------------------------------------------------------------- Mon Apr 27 18:50:11 UTC 2020 - Luigi Baldoni <aloisio@gmx.com> - Update to version 0.10.0
View file
libaacs.spec
Changed
@@ -20,7 +20,7 @@ %define sover 0 Name: libaacs -Version: 0.10.0 +Version: 0.11.0 Release: 0 Summary: Open implentation of AACS specification License: LGPL-2.1-or-later
View file
libaacs-0.10.0.tar.bz2/README.txt
Deleted
@@ -1,30 +0,0 @@ -Disclaimer ----------- - -This library is written for the purpose of playing Blu-ray movies. It is -intended for software that want to support Blu-ray playback (such as VLC and -MPlayer). We, the authors of this library, do not condone nor endorse piracy. - -This library is simply a tool for playback of Blu-ray movies. Like any tool, the -use of this tool can also be abused. There are already numerous laws in -different countries and juridictions all over the world that protect copyrighted -material, such as Blu-ray movies. With that said, it would have been -inappropriate for us to distribute this library with terms such as "you cannot -use this library for piracy". Instead, we present to everyone this disclaimer. - -As a reminder, here is also the disclaimer found at the beginning of any movie -in relation to copyrights. - -ATTENTION - -International agreement and national laws protect copyrighted motion pictures, -videotapes, and sound recordings. - -UNAUTHORIZED REPRODUCTION, EXHIBITION OR DISTRIBUTION OF COPYRIGHTED MOTION -PICTURES CAN RESULT IN SEVERE CRIMINAL AND CIVIL PENALTIES UNDER THE LAWS OF -YOUR COUNTRY. - -The International Criminal Police Organization - INTERPOL, has expressed its -concern about motion picture and sound recording piracy to all of its member -national police forces. (Resolution adopted at INTERPOL General Assembly, -Stockholm, Sweden, September 8, 1977.)
View file
libaacs-0.10.0.tar.bz2/src/examples/parser_test.c
Deleted
@@ -1,181 +0,0 @@ -/* - * This file is part of libaacs - * Copyright (C) 2010 gates - * - * 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 "file/keydbcfg.h" -#include "util/strutl.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -static int print_digit_key_pair_enties(digit_key_pair_list *list); -static int print_title_entries(title_entry_list *list); - -/* Function to print the entres in a digit key pair list */ -static int print_digit_key_pair_enties(digit_key_pair_list *list) -{ - if (!list) - { - printf("Error: No digit key pair list passed as parameter.\n"); - return 0; - } - - digit_key_pair_list *cursor = list; - while (cursor) - { - if (!cursor->key_pair.key) - break; - - printf(" %u - %s\n", cursor->key_pair.digit, cursor->key_pair.key); - - cursor = cursor->next; - } - - return 1; -} - -/* Function that prints all entries parsed from a config file */ -static int print_title_entries(title_entry_list *list) -{ - static const uint8_t empty_key16 = {0}; - char tmp256; - - if (!list) - { - printf("Error: No title list passed as parameter.\n"); - return 0; - } - - title_entry_list *cursor = list; - while (cursor) - { - printf("DISCID: %s\n", str_print_hex(tmp, cursor->entry.discid, 20)); -#if 0 - printf(" Title: %s\n", cursor->entry.title); - printf(" Date: %u-%u-%u\n", cursor->entry.date.year, - cursor->entry.date.month, cursor->entry.date.day); -#endif - if (cursor->entry.mek) - printf(" MEK: %s\n", cursor->entry.mek); - if (cursor->entry.vid) - printf(" VID: %s\n", cursor->entry.vid); -#if 0 - if (cursor->entry.bn) - { - printf(" BN:\n"); - print_digit_key_pair_enties(cursor->entry.bn); - } -#endif - if (memcmp(cursor->entry.vuk, empty_key, 16)) - printf(" VUK: %s\n", str_print_hex(tmp, cursor->entry.vuk, 16)); -#if 0 - if (cursor->entry.pak) - { - printf(" PAK:\n"); - print_digit_key_pair_enties(cursor->entry.pak); - } - if (cursor->entry.tk) - { - printf(" TK:\n"); - print_digit_key_pair_enties(cursor->entry.tk); - } -#endif - if (cursor->entry.uk) - { - printf(" UK:\n"); - print_digit_key_pair_enties(cursor->entry.uk); - } - - cursor = cursor->next; - } - - return 1; -} - -/* Function to print certificate list from config file */ -static int print_cert_list(cert_list *list) -{ - char tmp256; - - printf("Available certificates:\n"); - cert_list *cursor = list; - while (cursor) - { - printf(" Host private key: %s\n", str_print_hex(tmp, cursor->host_priv_key, 20)); - printf(" Host certificate: %s\n", str_print_hex(tmp, cursor->host_cert, 92)); - printf("\n"); - - cursor = cursor->next; - } - - printf("\n"); - - return 1; -} - -/* Function to print config file */ -static int print_config_file(config_file *cfgfile) -{ - char tmp256; - - printf("Available device keys:\n"); - dk_list *dkcursor = cfgfile->dkl; - while (dkcursor) - { - printf(" Device key: %s\n", str_print_hex(tmp, dkcursor->key, 16)); - printf(" Device node: %lu\n", dkcursor->node); - - dkcursor = dkcursor->next; - } - printf("\n"); - - - printf("Available processing keys:\n"); - - pk_list *cursor = cfgfile->pkl; - while (cursor) - { - printf(" %s\n", str_print_hex(tmp, cursor->key, 16)); - - cursor = cursor->next; - } - printf("\n"); - - int status1 = print_cert_list(cfgfile->host_cert_list); - int status2 = print_title_entries(cfgfile->list); - - return status1 & status2; -} - -/* main */ -int main (int argc, char **argv) -{ - /* suppress unused parameter warning */ - if (argc) {} - - config_file *cfgfile = keydbcfg_new_config_file(); - int retval = keydbcfg_parse_config(cfgfile, argv1); - retval &= print_config_file(cfgfile); - keydbcfg_config_file_close(cfgfile); - - if (!retval) - return EXIT_FAILURE; - - return EXIT_SUCCESS; -}
View file
libaacs-0.10.0.tar.bz2/ChangeLog -> libaacs-0.11.0.tar.bz2/ChangeLog
Changed
@@ -1,3 +1,15 @@ +2020-07-22: Version 0.11.0 +- Add more AACS2 support (still not complete). +- Add support for partial unit keys in KEYDB.CFG. +- Improve opening of UHD discs (~ 10 seconds faster). +- Improve large KEYDB.CFG parsing (~ 4 times faster). +- Improve error resilience. +- Reduce memory usage (does not depend on config file size anymore). +- Fix segfault on macOS when MMC opening fails. +- Fix memory leak with multiple UK entries in KEYDB.cfg file. +- Fix AACS2 with multiple unit keys. +- Fix include flags order (do not include wrong headers outside of source tree). + 2020-03-22: Version 0.10.0 - Add support for AACS2 content certificate. - Add aacs_set_key_caching().
View file
libaacs-0.10.0.tar.bz2/Makefile.am -> libaacs-0.11.0.tar.bz2/Makefile.am
Changed
@@ -1,11 +1,12 @@ ACLOCAL_AMFLAGS=-I m4 -EXTRA_DIST=bootstrap COPYING KEYDB.cfg README.txt ChangeLog +EXTRA_DIST=bootstrap COPYING KEYDB.cfg README.md ChangeLog SET_FEATURES = @SET_FEATURES@ SET_INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src/libaacs -AM_CFLAGS = -std=c99 $(SET_FEATURES) $(SET_INCLUDES) $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) +AM_CFLAGS = -std=c99 $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) +AM_CPPFLAGS = $(SET_FEATURES) $(SET_INCLUDES) AM_YFLAGS = -d -p libaacs_yy lib_LTLIBRARIES = libaacs.la @@ -92,17 +93,34 @@ # programs # -noinst_PROGRAMS = parser_test +noinst_PROGRAMS = parser_test uk_dump mkb_dump bin_PROGRAMS = aacs_info parser_test_SOURCES = \ - src/examples/parser_test.c \ + src/devtools/parser_test.c \ src/file/keydbcfg-parser.y \ src/file/keydbcfg-lexer.l \ src/util/strutl.c \ src/util/logging.c -parser_test_CFLAGS = -std=c99 $(SET_FEATURES) $(SET_INCLUDES) +parser_test_CFLAGS = -std=c99 + +uk_dump_SOURCES = \ + src/devtools/uk_dump.c \ + src/devtools/read_file.h \ + src/libaacs/unit_key.h \ + src/libaacs/unit_key.c \ + src/util/logging.c +uk_dump_CFLAGS = -std=c99 + +mkb_dump_SOURCES = \ + src/devtools/mkb_dump.c \ + src/devtools/read_file.h \ + src/libaacs/mkb.h \ + src/libaacs/mkb.c \ + src/util/strutl.c \ + src/util/logging.c +mkb_dump_CFLAGS = -std=c99 aacs_info_SOURCES = src/examples/aacs_info.c -aacs_info_CFLAGS = -std=c99 $(SET_FEATURES) $(SET_INCLUDES) +aacs_info_CFLAGS = -std=c99 aacs_info_LDADD = libaacs.la
View file
libaacs-0.10.0.tar.bz2/Makefile.in -> libaacs-0.11.0.tar.bz2/Makefile.in
Changed
@@ -108,7 +108,8 @@ @HAVE_DARWIN_FALSE@@HAVE_WIN32_FALSE@ src/file/mmc_device_linux.c \ @HAVE_DARWIN_FALSE@@HAVE_WIN32_FALSE@ src/file/path.c -noinst_PROGRAMS = parser_test$(EXEEXT) +noinst_PROGRAMS = parser_test$(EXEEXT) uk_dump$(EXEEXT) \ + mkb_dump$(EXEEXT) bin_PROGRAMS = aacs_info$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -211,8 +212,17 @@ aacs_info_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(aacs_info_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_mkb_dump_OBJECTS = src/devtools/mkb_dump-mkb_dump.$(OBJEXT) \ + src/libaacs/mkb_dump-mkb.$(OBJEXT) \ + src/util/mkb_dump-strutl.$(OBJEXT) \ + src/util/mkb_dump-logging.$(OBJEXT) +mkb_dump_OBJECTS = $(am_mkb_dump_OBJECTS) +mkb_dump_LDADD = $(LDADD) +mkb_dump_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(mkb_dump_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_parser_test_OBJECTS = \ - src/examples/parser_test-parser_test.$(OBJEXT) \ + src/devtools/parser_test-parser_test.$(OBJEXT) \ src/file/parser_test-keydbcfg-parser.$(OBJEXT) \ src/file/parser_test-keydbcfg-lexer.$(OBJEXT) \ src/util/parser_test-strutl.$(OBJEXT) \ @@ -222,6 +232,14 @@ parser_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(parser_test_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_uk_dump_OBJECTS = src/devtools/uk_dump-uk_dump.$(OBJEXT) \ + src/libaacs/uk_dump-unit_key.$(OBJEXT) \ + src/util/uk_dump-logging.$(OBJEXT) +uk_dump_OBJECTS = $(am_uk_dump_OBJECTS) +uk_dump_LDADD = $(LDADD) +uk_dump_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(uk_dump_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -237,8 +255,10 @@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = src/examples/$(DEPDIR)/aacs_info-aacs_info.Po \ - src/examples/$(DEPDIR)/parser_test-parser_test.Po \ +am__depfiles_remade = src/devtools/$(DEPDIR)/mkb_dump-mkb_dump.Po \ + src/devtools/$(DEPDIR)/parser_test-parser_test.Po \ + src/devtools/$(DEPDIR)/uk_dump-uk_dump.Po \ + src/examples/$(DEPDIR)/aacs_info-aacs_info.Po \ src/file/$(DEPDIR)/dirs_darwin.Plo \ src/file/$(DEPDIR)/dirs_win32.Plo \ src/file/$(DEPDIR)/dirs_xdg.Plo src/file/$(DEPDIR)/file.Plo \ @@ -257,12 +277,18 @@ src/libaacs/$(DEPDIR)/cci.Plo \ src/libaacs/$(DEPDIR)/content_cert.Plo \ src/libaacs/$(DEPDIR)/crypto.Plo src/libaacs/$(DEPDIR)/ec.Plo \ - src/libaacs/$(DEPDIR)/mkb.Plo src/libaacs/$(DEPDIR)/mmc.Plo \ + src/libaacs/$(DEPDIR)/mkb.Plo \ + src/libaacs/$(DEPDIR)/mkb_dump-mkb.Po \ + src/libaacs/$(DEPDIR)/mmc.Plo \ + src/libaacs/$(DEPDIR)/uk_dump-unit_key.Po \ src/libaacs/$(DEPDIR)/unit_key.Plo \ src/util/$(DEPDIR)/logging.Plo \ + src/util/$(DEPDIR)/mkb_dump-logging.Po \ + src/util/$(DEPDIR)/mkb_dump-strutl.Po \ src/util/$(DEPDIR)/parser_test-logging.Po \ src/util/$(DEPDIR)/parser_test-strutl.Po \ - src/util/$(DEPDIR)/strutl.Plo + src/util/$(DEPDIR)/strutl.Plo \ + src/util/$(DEPDIR)/uk_dump-logging.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -302,10 +328,11 @@ am__v_YACC_0 = @echo " YACC " $@; am__v_YACC_1 = SOURCES = $(libaacs_la_SOURCES) $(EXTRA_libaacs_la_SOURCES) \ - $(aacs_info_SOURCES) $(parser_test_SOURCES) + $(aacs_info_SOURCES) $(mkb_dump_SOURCES) \ + $(parser_test_SOURCES) $(uk_dump_SOURCES) DIST_SOURCES = $(am__libaacs_la_SOURCES_DIST) \ $(EXTRA_libaacs_la_SOURCES) $(aacs_info_SOURCES) \ - $(parser_test_SOURCES) + $(mkb_dump_SOURCES) $(parser_test_SOURCES) $(uk_dump_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -507,9 +534,10 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = bootstrap COPYING KEYDB.cfg README.txt ChangeLog +EXTRA_DIST = bootstrap COPYING KEYDB.cfg README.md ChangeLog SET_INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src/libaacs -AM_CFLAGS = -std=c99 $(SET_FEATURES) $(SET_INCLUDES) $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) +AM_CFLAGS = -std=c99 $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) +AM_CPPFLAGS = $(SET_FEATURES) $(SET_INCLUDES) AM_YFLAGS = -d -p libaacs_yy lib_LTLIBRARIES = libaacs.la libaacs_la_SOURCES = src/libaacs/aacs.h src/libaacs/aacs.c \ @@ -541,15 +569,32 @@ BUILT_SOURCES = src/libaacs.pc src/libaacs/aacs-version.h src/file/keydbcfg-parser.h src/file/keydbcfg-parser.c src/file/keydbcfg-lexer.c CLEANFILES = $(BUILT_SOURCES) parser_test_SOURCES = \ - src/examples/parser_test.c \ + src/devtools/parser_test.c \ src/file/keydbcfg-parser.y \ src/file/keydbcfg-lexer.l \ src/util/strutl.c \ src/util/logging.c -parser_test_CFLAGS = -std=c99 $(SET_FEATURES) $(SET_INCLUDES) +parser_test_CFLAGS = -std=c99 +uk_dump_SOURCES = \ + src/devtools/uk_dump.c \ + src/devtools/read_file.h \ + src/libaacs/unit_key.h \ + src/libaacs/unit_key.c \ + src/util/logging.c + +uk_dump_CFLAGS = -std=c99 +mkb_dump_SOURCES = \ + src/devtools/mkb_dump.c \ + src/devtools/read_file.h \ + src/libaacs/mkb.h \ + src/libaacs/mkb.c \ + src/util/strutl.c \ + src/util/logging.c + +mkb_dump_CFLAGS = -std=c99 aacs_info_SOURCES = src/examples/aacs_info.c -aacs_info_CFLAGS = -std=c99 $(SET_FEATURES) $(SET_INCLUDES) +aacs_info_CFLAGS = -std=c99 aacs_info_LDADD = libaacs.la all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -786,9 +831,28 @@ aacs_info$(EXEEXT): $(aacs_info_OBJECTS) $(aacs_info_DEPENDENCIES) $(EXTRA_aacs_info_DEPENDENCIES) @rm -f aacs_info$(EXEEXT) $(AM_V_CCLD)$(aacs_info_LINK) $(aacs_info_OBJECTS) $(aacs_info_LDADD) $(LIBS) -src/examples/parser_test-parser_test.$(OBJEXT): \ - src/examples/$(am__dirstamp) \ - src/examples/$(DEPDIR)/$(am__dirstamp) +src/devtools/$(am__dirstamp): + @$(MKDIR_P) src/devtools + @: > src/devtools/$(am__dirstamp) +src/devtools/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) src/devtools/$(DEPDIR) + @: > src/devtools/$(DEPDIR)/$(am__dirstamp) +src/devtools/mkb_dump-mkb_dump.$(OBJEXT): \ + src/devtools/$(am__dirstamp) \ + src/devtools/$(DEPDIR)/$(am__dirstamp) +src/libaacs/mkb_dump-mkb.$(OBJEXT): src/libaacs/$(am__dirstamp) \ + src/libaacs/$(DEPDIR)/$(am__dirstamp) +src/util/mkb_dump-strutl.$(OBJEXT): src/util/$(am__dirstamp) \ + src/util/$(DEPDIR)/$(am__dirstamp) +src/util/mkb_dump-logging.$(OBJEXT): src/util/$(am__dirstamp) \ + src/util/$(DEPDIR)/$(am__dirstamp) + +mkb_dump$(EXEEXT): $(mkb_dump_OBJECTS) $(mkb_dump_DEPENDENCIES) $(EXTRA_mkb_dump_DEPENDENCIES) + @rm -f mkb_dump$(EXEEXT) + $(AM_V_CCLD)$(mkb_dump_LINK) $(mkb_dump_OBJECTS) $(mkb_dump_LDADD) $(LIBS) +src/devtools/parser_test-parser_test.$(OBJEXT): \ + src/devtools/$(am__dirstamp) \ + src/devtools/$(DEPDIR)/$(am__dirstamp) src/file/parser_test-keydbcfg-parser.$(OBJEXT): \ src/file/$(am__dirstamp) src/file/$(DEPDIR)/$(am__dirstamp) src/file/parser_test-keydbcfg-lexer.$(OBJEXT): \ @@ -801,9 +865,20 @@ parser_test$(EXEEXT): $(parser_test_OBJECTS) $(parser_test_DEPENDENCIES) $(EXTRA_parser_test_DEPENDENCIES) @rm -f parser_test$(EXEEXT) $(AM_V_CCLD)$(parser_test_LINK) $(parser_test_OBJECTS) $(parser_test_LDADD) $(LIBS) +src/devtools/uk_dump-uk_dump.$(OBJEXT): src/devtools/$(am__dirstamp) \ + src/devtools/$(DEPDIR)/$(am__dirstamp) +src/libaacs/uk_dump-unit_key.$(OBJEXT): src/libaacs/$(am__dirstamp) \ + src/libaacs/$(DEPDIR)/$(am__dirstamp) +src/util/uk_dump-logging.$(OBJEXT): src/util/$(am__dirstamp) \ + src/util/$(DEPDIR)/$(am__dirstamp) + +uk_dump$(EXEEXT): $(uk_dump_OBJECTS) $(uk_dump_DEPENDENCIES) $(EXTRA_uk_dump_DEPENDENCIES) + @rm -f uk_dump$(EXEEXT) + $(AM_V_CCLD)$(uk_dump_LINK) $(uk_dump_OBJECTS) $(uk_dump_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f src/devtools/*.$(OBJEXT) -rm -f src/examples/*.$(OBJEXT) -rm -f src/file/*.$(OBJEXT) -rm -f src/file/*.lo @@ -815,8 +890,10 @@ distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@src/devtools/$(DEPDIR)/mkb_dump-mkb_dump.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@src/devtools/$(DEPDIR)/parser_test-parser_test.Po@am__quote@ # am--include-marker
View file
libaacs-0.11.0.tar.bz2/README.md
Added
@@ -0,0 +1,69 @@ +# libaacs + +**libaacs** is a research project for a cross-platform open-source implementation of the AACS specification. + +# Disclaimer + +This library is written for the purpose of playing Blu-ray movies. + +It is intended for software that want to support Blu-ray playback (such as VLC and +MPlayer). We, the authors of this library, do not condone nor endorse piracy. + +This library is simply a tool for playback of Blu-ray movies. Like any tool, the +use of this tool can also be abused. There are already numerous laws in +different countries and juridictions all over the world that protect copyrighted +material, such as Blu-ray movies. + +With that said, it would have been impossible for us to distribute this library +with terms such as "you cannot use this library for piracy", because this would +violate the Open Source Definition and the LGPL license. +Instead, we present to everyone this disclaimer. + +As a reminder, here is also the disclaimer found at the beginning of any movie +in relation to copyrights. + +## ATTENTION + +International agreement and national laws protect copyrighted motion pictures, +videotapes, and sound recordings. + +UNAUTHORIZED REPRODUCTION, EXHIBITION OR DISTRIBUTION OF COPYRIGHTED MOTION +PICTURES CAN RESULT IN SEVERE CRIMINAL AND CIVIL PENALTIES UNDER THE LAWS OF +YOUR COUNTRY. + +The International Criminal Police Organization - INTERPOL, has expressed its +concern about motion picture and sound recording piracy to all of its member +national police forces. (Resolution adopted at INTERPOL General Assembly, +Stockholm, Sweden, September 8, 1977.) + +# Contribute + +To contribute, just compile the library and open merge requests on the repository: +https://code.videolan.org/videolan/libaacs + +## CoC + +The VideoLAN Code of Conduct(https://wiki.videolan.org/CoC) applies to this project. + +## CLA + +There is no CLA. + +People will keep their copyright and their authorship rights, while adhering to the license. + +VideoLAN will only have the collective work rights. + +# FAQ + +## Do you give the keys? + +We do not ship any encryption keys or cert, no. + +## Do you provide binaries? + +No, we don't. You should compile this yourself. + +## Do you implement HD-DVD AACS version? + +We do not, but patches are very welcome. +
View file
libaacs-0.10.0.tar.bz2/build-aux/ltmain.sh -> libaacs-0.11.0.tar.bz2/build-aux/ltmain.sh
Changed
@@ -31,7 +31,7 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4.6 Debian-2.4.6-11" +VERSION="2.4.6 Debian-2.4.6-14" package_revision=2.4.6 @@ -387,7 +387,7 @@ # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # -# debug_cmd='eval echo "${FUNCNAME0} $*" >&2' bash your-script-name +# debug_cmd='echo "${FUNCNAME0} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: @@ -2141,7 +2141,7 @@ compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) - version: $progname $scriptversion Debian-2.4.6-11 + version: $progname $scriptversion Debian-2.4.6-14 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` @@ -7368,10 +7368,12 @@ # -stdlib=* select c++ std lib with clang # -fsanitize=* Clang/GCC memory and address sanitizer # -fuse-ld=* Linker select flags for GCC + # -static-* direct GCC to link specific libraries statically + # -fcilkplus Cilk Plus language extension features for C/C++ -64|-mips0-9|-r0-90-9*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t45*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ - -specs=*|-fsanitize=*|-fuse-ld=*) + -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg"
View file
libaacs-0.10.0.tar.bz2/config.h.in -> libaacs-0.11.0.tar.bz2/config.h.in
Changed
@@ -4,10 +4,6 @@ don't. */ #undef HAVE_DECL_STRERROR_R -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H @@ -38,9 +34,6 @@ /* Define to 1 if you have the <mntent.h> header file. */ #undef HAVE_MNTENT_H -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - /* Define to 1 if you have the <pthread.h> header file. */ #undef HAVE_PTHREAD_H @@ -62,20 +55,9 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H -/* Define to 1 if `d_type' is a member of `struct dirent'. */ -#undef HAVE_STRUCT_DIRENT_D_TYPE - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - /* Define to 1 if you have the <sys/mount.h> header file. */ #undef HAVE_SYS_MOUNT_H -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - /* Define to 1 if you have the <sys/param.h> header file. */ #undef HAVE_SYS_PARAM_H @@ -85,15 +67,9 @@ /* Define to 1 if you have the <sys/stat.h> header file. */ #undef HAVE_SYS_STAT_H -/* Define to 1 if you have the <sys/time.h> header file. */ -#undef HAVE_SYS_TIME_H - /* Define to 1 if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H -/* Define to 1 if you have the <time.h> header file. */ -#undef HAVE_TIME_H - /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H
View file
libaacs-0.10.0.tar.bz2/configure -> libaacs-0.11.0.tar.bz2/configure
Changed
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libaacs 0.10.0. +# Generated by GNU Autoconf 2.69 for libaacs 0.11.0. # # Report bugs to <http://www.videolan.org/developers/libaacs.html>. # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='libaacs' PACKAGE_TARNAME='libaacs' -PACKAGE_VERSION='0.10.0' -PACKAGE_STRING='libaacs 0.10.0' +PACKAGE_VERSION='0.11.0' +PACKAGE_STRING='libaacs 0.11.0' PACKAGE_BUGREPORT='http://www.videolan.org/developers/libaacs.html' PACKAGE_URL='' @@ -1363,7 +1363,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libaacs 0.10.0 to adapt to many kinds of systems. +\`configure' configures libaacs 0.11.0 to adapt to many kinds of systems. Usage: $0 OPTION... VAR=VALUE... @@ -1435,7 +1435,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libaacs 0.10.0:";; + short | recursive ) echo "Configuration of libaacs 0.11.0:";; esac cat <<\_ACEOF @@ -1565,7 +1565,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libaacs configure 0.10.0 +libaacs configure 0.11.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1931,63 +1931,6 @@ } # ac_fn_c_check_header_mongrel -# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES -# ---------------------------------------------------- -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_c_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if eval \${$4+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_member - # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR @@ -2037,7 +1980,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libaacs $as_me 0.10.0, which was +It was created by libaacs $as_me 0.11.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3012,7 +2955,7 @@ # Define the identity of the package. PACKAGE='libaacs' - VERSION='0.10.0' + VERSION='0.11.0' cat >>confdefs.h <<_ACEOF @@ -3339,9 +3282,6 @@ fi -library_not_found="Could not find required library!" -function_not_found="Could not find required function!" - # Check whether --enable-werror was given. if test "${enable_werror+set}" = set; then : enableval=$enable_werror; @@ -6007,7 +5947,7 @@ fi : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} @@ -7728,8 +7668,8 @@ _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 + echo "$AR cr libconftest.a conftest.o" >&5 + $AR cr libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF @@ -12960,7 +12900,7 @@ -for ac_header in stdarg.h sys/types.h dirent.h errno.h libgen.h malloc.h +for ac_header in stdarg.h sys/types.h errno.h libgen.h malloc.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -12986,7 +12926,7 @@ done -for ac_header in sys/time.h time.h sys/select.h limits.h sys/param.h +for ac_header in sys/select.h limits.h sys/param.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -13012,195 +12952,6 @@ done -ac_header_dirent=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 -$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } -if eval \${$as_ac_Header+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> -#include <$ac_hdr> - -int -main () -{ -if ((DIR *) 0) -return 0; - ; - return 0;
View file
libaacs-0.10.0.tar.bz2/configure.ac -> libaacs-0.11.0.tar.bz2/configure.ac
Changed
@@ -1,6 +1,6 @@ dnl library version number m4_define(aacs_major, 0) -m4_define(aacs_minor, 10) +m4_define(aacs_minor, 11) m4_define(aacs_micro, 0) m4_define(aacs_version,aacs_major.aacs_minor.aacs_micro) @@ -16,7 +16,7 @@ m4_define(lt_current, 7) m4_define(lt_age, 7) -m4_define(lt_revision, 0) +m4_define(lt_revision, 1) dnl initilization AC_INIT(libaacs, aacs_version, http://www.videolan.org/developers/libaacs.html) @@ -62,10 +62,6 @@ AM_CONDITIONAL(HAVE_WIN32, test "${SYS}" = "mingw32") AM_CONDITIONAL(HAVE_DARWIN, test "${SYS}" = "darwin") -dnl messages -library_not_found="Could not find required library!" -function_not_found="Could not find required function!" - dnl configure options AC_ARG_ENABLE(werror, AS_HELP_STRING(--enable-werror, set warnings as errors via -Werror @<:@default=disabled@:>@)) @@ -93,20 +89,14 @@ AC_TYPE_SIGNAL dnl required headers -AC_CHECK_HEADERS(stdarg.h sys/types.h dirent.h errno.h libgen.h malloc.h) +AC_CHECK_HEADERS(stdarg.h sys/types.h errno.h libgen.h malloc.h) AC_CHECK_HEADERS(stdlib.h mntent.h linux/cdrom.h inttypes.h) -AC_CHECK_HEADERS(sys/time.h time.h sys/select.h limits.h sys/param.h) +AC_CHECK_HEADERS(sys/select.h limits.h sys/param.h) AC_CHECK_HEADERS(sys/mount.h) -dnl required structures -AC_STRUCT_DIRENT_D_TYPE - dnl required system services AC_SYS_LARGEFILE -dnl required functions -AC_CHECK_FUNC(snprintf,, AC_MSG_ERROR($function_not_found)) - dnl required libraries dnl gcrypt check
View file
libaacs-0.10.0.tar.bz2/m4/libtool.m4 -> libaacs-0.11.0.tar.bz2/m4/libtool.m4
Changed
@@ -1041,8 +1041,8 @@ _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF @@ -1492,7 +1492,7 @@ m4_defun(_LT_PROG_AR, AC_CHECK_TOOLS(AR, ar, false) : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} _LT_DECL(, AR, 1, The archiver) _LT_DECL(, AR_FLAGS, 1, Flags to create an archive)
View file
libaacs-0.11.0.tar.bz2/src/devtools
Added
+(directory)
View file
libaacs-0.11.0.tar.bz2/src/devtools/mkb_dump.c
Added
@@ -0,0 +1,260 @@ +/* + * 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/mkb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <inttypes.h> + +#include "read_file.h" + +static const struct { + uint8_t type; + const char *name; +} rec_names = { + { 0x02, "End of media key block" }, + { 0x04, "Explicit Subset-Difference" }, + { 0x05, "Media Key Data / CVALUE" }, + { 0x07, "Subset-Difference Index" }, + { 0x0c, "Media Key Variant Data" }, + { 0x10, "Type and version" }, + { 0x20, "Drive revocation list (AACS1)" }, + { 0x21, "Host revocation list (AACS1)" }, + { 0x30, "Drive revocation list (AACS2)" }, + { 0x31, "Host revocation list (AACS2)" }, + { 0x81, "Verify media key / DVALUE" }, + { 0x86, "Verify media key / DVALUE (AACS2)" }, +}; + +static const struct { + uint32_t type; + const char *name; +} mkb_types = { + { MKB_TYPE_3, "Type 3" }, + { MKB_TYPE_4, "Type 4" }, + { MKB_TYPE_10_CLASS_II, "Type 10, class II" }, + { MKB_20_CATEGORY_C, "Type 2.0 Category C" }, + { MKB_21_CATEGORY_C, "Type 2.1 Category C" }, +}; + +static const char *rec_name(uint8_t type) { + size_t i; + for (i = 0; i < sizeof(rec_names)/sizeof(rec_names0); i++) + if (rec_namesi.type == type) + return rec_namesi.name; + return "(UNKNOWN)"; +} + +static const char *type_name(uint32_t type) { + size_t i; + for (i = 0; i < sizeof(mkb_types)/sizeof(mkb_types0); i++) + if (mkb_typesi.type == type) + return mkb_typesi.name; + return "(UNKNOWN)"; +} + +static void _dump_signature(const uint8_t *sig, size_t len) +{ + size_t i; + + printf(" Signature (%zu bytes): ", len); + for (i = 0; i < len; i++) { + printf("%02x", sigi); + } + printf("\n"); +} + +static void _dump_aacs1_rl(const uint8_t *rl, size_t rl_size) +{ + if (rl_size < 4) + return; + + uint32_t total_entries = MKINT_BE32(rl); + rl += 4; rl_size -= 4; + + while (total_entries > 0 && rl_size >= 4) { + uint32_t entries = MKINT_BE32(rl); + rl += 4; rl_size -= 4; + if (entries >= (0xffffffff - 8 - 40) / 8) { + printf(" invalid revocation list\n"); + break; + } + + size_t rec_len = 8 * entries + 40; + if (rec_len > rl_size) { + printf(" revocation list size mismatch\n"); + break; + } + + unsigned ii; + for (ii = 0; ii < entries; ii++) { + uint16_t len = MKINT_BE16(rl); + uint64_t id = MKINT_BE48(rl + 2); + printf(" %3d: id %12" PRIx64, ii, id); + if (len) { + printf("-%12" PRIx64, id + len); + } + printf("\n"); + rl += 8; rl_size -= 8; + } + _dump_signature(rl, 40); + rl += 40; rl_size -= 40; + total_entries -= entries; + } +} + +static void _dump_type_and_version(const uint8_t *p, size_t size) +{ + if (size >= 4) + printf(" MKB type: 0x%08x (%s)\n", MKINT_BE32(p), type_name(MKINT_BE32(p))); + if (size >= 8) + printf(" MKB version: %8d\n", MKINT_BE32(p+4)); +} + +static void _dump_record(MKB *mkb, int record) +{ + size_t size = mkb_data_size(mkb); + const uint8_t *data = mkb_data(mkb); + size_t pos, len; + + printf("\nRecord 0x%02x (%s):\n", record, rec_name(record)); + + for (pos = 0; pos + 4 <= size; pos += len) { + uint8_t type = datapos; + len = MKINT_BE24(data + pos + 1); + if (type == record) { + switch (record) { + case 0x02: _dump_signature(data + pos + 4, len - 4); break; + case 0x10: _dump_type_and_version(data + pos + 4, len - 4); break; + case 0x20: + case 0x21: _dump_aacs1_rl(data + pos + 4, len - 4); break; + } + printf(" Raw data (%zu bytes):\n", len - 4); + const uint8_t *p = data + pos + 4; + const uint8_t *e = data + pos + len; + while (p < e) { + size_t i; + printf(" "); + for (i = 0; i < 8 && p < e; i++, p++) + printf("%02x ", *p); + printf(" "); + for (i = 0; i < 8 && p < e; i++, p++) + printf("%02x ", *p); + printf("\n"); + } + break; + } + } +} + +static void _list_missing_records(const uint8_t *seen_map) +{ + int type; + + for (type = 0; type < 256; type++) { + if (!seen_maptype) { + size_t i; + for (i = 0; i < sizeof(rec_names)/sizeof(rec_names0); i++) { + if (rec_namesi.type == type) { + printf(" %s\n", rec_namesi.name); + } + } + } + } +} + +static void _list_records(MKB *mkb, uint8_t *seen_map) +{ + const uint8_t *data = mkb_data(mkb); + size_t size = mkb_data_size(mkb); + size_t pos, len; + + for (pos = 0; pos + 4 <= size; pos += len) { + uint8_t type = datapos; + len = MKINT_BE24(data + pos + 1); + printf(" record 0x%02x: %10zu bytes %s\n", type, len, rec_name(type)); + seen_maptype = 1; + if (len == 0) { + printf(" UNKNOWN: %10zu bytes\n", size - pos);
View file
libaacs-0.11.0.tar.bz2/src/devtools/parser_test.c
Added
@@ -0,0 +1,203 @@ +/* + * This file is part of libaacs + * Copyright (C) 2010 gates + * + * 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 "file/keydbcfg.h" +#include "util/strutl.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +static int print_digit_key_pair_enties(digit_key_pair_list *list); +static int print_title_entries(title_entry_list *list); + +static const uint8_t empty_key16 = {0}; + +/* Function to print the entres in a digit key pair list */ +static int print_digit_key_pair_enties(digit_key_pair_list *list) +{ + char tmp256; + + if (!list) + { + printf("Error: No digit key pair list passed as parameter.\n"); + return 0; + } + + digit_key_pair_list *cursor = list; + while (cursor) + { + printf(" %u - %s\n", cursor->key_pair.digit, str_print_hex(tmp, cursor->key_pair.key, 16)); + + cursor = cursor->next; + } + + return 1; +} + +/* Function that prints all entries parsed from a config file */ +static int print_title_entries(title_entry_list *list) +{ + char tmp256; + + if (!list) + { + printf("Error: No title list passed as parameter.\n"); + return 0; + } + + title_entry_list *cursor = list; + while (cursor) + { + printf("DISCID: %s\n", str_print_hex(tmp, cursor->entry.discid, 20)); +#if 0 + printf(" Title: %s\n", cursor->entry.title); + printf(" Date: %u-%u-%u\n", cursor->entry.date.year, + cursor->entry.date.month, cursor->entry.date.day); +#endif + if (memcmp(cursor->entry.mk, empty_key, 16)) + printf(" MEK: %s\n", str_print_hex(tmp, cursor->entry.mk, 16)); + if (memcmp(cursor->entry.vid, empty_key, 16)) + printf(" VID: %s\n", str_print_hex(tmp, cursor->entry.vid, 16)); +#if 0 + if (cursor->entry.bn) + { + printf(" BN:\n"); + print_digit_key_pair_enties(cursor->entry.bn); + } +#endif + if (memcmp(cursor->entry.vuk, empty_key, 16)) + printf(" VUK: %s\n", str_print_hex(tmp, cursor->entry.vuk, 16)); +#if 0 + if (cursor->entry.pak) + { + printf(" PAK:\n"); + print_digit_key_pair_enties(cursor->entry.pak); + } + if (cursor->entry.tk) + { + printf(" TK:\n"); + print_digit_key_pair_enties(cursor->entry.tk); + } +#endif + if (cursor->entry.uk) + { + printf(" UK:\n"); + print_digit_key_pair_enties(cursor->entry.uk); + } + + cursor = cursor->next; + } + + return 1; +} + +/* Function to print certificate list from config file */ +static int print_cert_list(cert_list *list) +{ + char tmp256; + + printf("Available certificates:\n"); + cert_list *cursor = list; + while (cursor) + { + printf(" Host private key: %s\n", str_print_hex(tmp, cursor->host_priv_key, 20)); + printf(" Host certificate: %s\n", str_print_hex(tmp, cursor->host_cert, 92)); + printf("\n"); + + cursor = cursor->next; + } + + printf("\n"); + + return 1; +} + +/* Function to print config file */ +static int print_config_file(config_file *cfgfile) +{ + char tmp256; + + printf("Available device keys:\n"); + dk_list *dkcursor = cfgfile->dkl; + while (dkcursor) + { + printf(" Device key: %s\n", str_print_hex(tmp, dkcursor->key, 16)); + printf(" Device node: %lu\n", dkcursor->node); + + dkcursor = dkcursor->next; + } + printf("\n"); + + + printf("Available processing keys:\n"); + + pk_list *cursor = cfgfile->pkl; + while (cursor) + { + printf(" %s\n", str_print_hex(tmp, cursor->key, 16)); + + cursor = cursor->next; + } + printf("\n"); + + int status1 = print_cert_list(cfgfile->host_cert_list); + int status2 = print_title_entries(cfgfile->list); + + return status1 & status2; +} + +/* main */ +int main (int argc, char **argv) +{ + config_file *cfgfile; + uint8_t disc_id20 = {0}; + const uint8_t *want_disc_id = NULL; + int retval = 0; + + if (argc < 2 || argc > 3) { + fprintf(stderr, "usage: parser_test config_file disc_id\n"); + return EXIT_FAILURE; + } + + if (argc > 2) { + if (strlen(argv2) != 40) { + fprintf(stderr, "disc id must be 40 chars long\n"); + return EXIT_FAILURE; + } + if (!hexstring_to_hex_array(disc_id, 20, argv2)) { + fprintf(stderr, "invalid disc id %s\n", argv2); + return EXIT_FAILURE; + } + want_disc_id = disc_id; + } + + + cfgfile = keydbcfg_new_config_file(); + if (cfgfile) { + retval = keydbcfg_parse_config(cfgfile, argv1, want_disc_id, want_disc_id == NULL); + retval &= print_config_file(cfgfile); + keydbcfg_config_file_close(cfgfile); + } + + if (!retval)
View file
libaacs-0.11.0.tar.bz2/src/devtools/read_file.h
Added
@@ -0,0 +1,77 @@ +/* + * 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 <stdio.h> +#include <stdlib.h> +#include <errno.h> + +static size_t _read_file(const char *name, off_t min_size, off_t max_size, uint8_t **pdata) +{ + FILE *f; + uint8_t *data = NULL; + off_t file_size; + size_t size; + + f = fopen(name, "rb"); + if (!f) { + fprintf(stderr, "error opening '%s': %s (%d)\n", name, strerror(errno), errno); + return 0; + } + + if (fseek(f, 0, SEEK_END) < 0) { + fprintf(stderr, "error seeking to end: %s (%d)\n", strerror(errno), errno); + goto fail; + } + + file_size = ftell(f); + + if (file_size < 0) { + fprintf(stderr, "error getting file size: %s (%d)\n", strerror(errno), errno); + goto fail; + } + if (file_size < min_size || file_size > max_size) { + fprintf(stderr, "weird file size: %lld\n", (long long)file_size); + goto fail; + } + if (fseek(f, 0, SEEK_SET) < 0) { + fprintf(stderr, "error seeking to start: %s (%d)\n", strerror(errno), errno); + goto fail; + } + + size = (size_t)file_size; + + data = malloc(size); + if (!data) { + fprintf(stderr, "error allocating %zu bytes: %s (%d)\n", size, strerror(errno), errno); + goto fail; + } + if (fread(data, size, 1, f) != 1) { + fprintf(stderr, "error reading %zu bytes: %s (%d)\n", size, strerror(errno), errno); + goto fail; + } + fclose(f); + + *pdata = data; + return size; + + fail: + free(data); + fclose(f); + return 0; +}
View file
libaacs-0.11.0.tar.bz2/src/devtools/uk_dump.c
Added
@@ -0,0 +1,113 @@ +/* + * 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/unit_key.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "read_file.h" + +static void _uk_dump(AACS_UK *uk) +{ + unsigned i, j; + + printf("Num BDMV dir: %d\n", uk->num_bdmv_dir); + printf("Application type: %d\n", uk->app_type); + printf("Use_SKB_Unified_MKB_Flag: %d\n", uk->use_skb_mkb); + + printf("Encrypted unit keys: %u\n", uk->num_uk); + for (i = 0; i < uk->num_uk; i++) { + printf(" %u: ", i + 1); + for (j = 0; j < 16; j++) { + printf("%02x", uk->enc_uki.keyj); + } + printf("\n"); + } + + printf("Title CPS units (%d titles):\n", uk->num_titles); + if (uk->num_titles > 0) + printf(" FP: %u\n", uk->title_cps_unit0); + if (uk->num_titles > 1) + printf(" TM: %u\n", uk->title_cps_unit1); + for (i = 0; i < uk->num_titles; i++) + printf(" %2u: %u\n", i + 1, uk->title_cps_uniti + 2); +} + +int main (int argc, char **argv) +{ + AACS_UK *uk; + uint8_t *data; + size_t size; + int aacs2 = argc > 2; + size_t l, b; + + if (argc < 2) { + fprintf(stderr, "usage: uk_dump <Unit_Key_RO.inf> AACS2\n"); + exit(-1); + } + + size = _read_file(argv1, 16, 1024*1024, &data); + if (!size) { + exit(-1); + } + + printf("Unit key file size: %8zu bytes\n", size); + uk = uk_parse(data, size, aacs2); + + if (!uk) { + fprintf(stderr, "Parsing failed\n"); + exit(-1); + } + + _uk_dump(uk); + + printf("Raw data:\n"); + uint32_t mask = 0; + for (l = 0; l < size; l += 16) { + mask <<= 8; + for (b = 0; b < 32 && l+b < size; b++) + mask |= datal + b; + if (mask) { + printf("%04lx: ", (long)l); + + for (b = 0; b < 8 && l+b < size; b++) + printf("%02x ", datal + b); + printf(" "); + for (b = 8; b < 16 && l+b < size; b++) + printf("%02x ", datal + b); + printf(" "); + for (b = 0; b < 8 && l+b < size; b++) + if (datal+b) printf("%02x ", datal + b); else printf(" "); + printf(" "); + for (b = 8; b < 16 && l+b < size; b++) + if (datal+b) printf("%02x ", datal + b); else printf(" "); + + printf("\n"); + } + } + + uk_free(&uk); + free(data); + + return 0; +}
View file
libaacs-0.10.0.tar.bz2/src/file/file.h -> libaacs-0.11.0.tar.bz2/src/file/file.h
Changed
@@ -38,15 +38,28 @@ * file access */ -#define file_close(X) X->close(X) -#define file_seek(X,Y,Z) X->seek(X,Y,Z) -#define file_tell(X) X->tell(X) +static inline void file_close(AACS_FILE_H *fp) +{ + fp->close(fp); +} + +static inline int64_t file_tell(AACS_FILE_H *fp) +{ + return fp->tell(fp); +} + +static inline BD_USED int64_t file_seek(AACS_FILE_H *fp, int64_t offset, int32_t origin) +{ + return fp->seek(fp, offset, origin); +} -static inline int64_t file_read(AACS_FILE_H *fp, void *buf, int64_t size) { +static inline int64_t file_read(AACS_FILE_H *fp, void *buf, int64_t size) +{ return fp->read(fp, buf, size); } -static inline int64_t file_write(AACS_FILE_H *fp, const void *buf, int64_t size) { +static inline int64_t file_write(AACS_FILE_H *fp, const void *buf, int64_t size) +{ return fp->write ? fp->write(fp, buf, size) : 0; }
View file
libaacs-0.10.0.tar.bz2/src/file/file_posix.c -> libaacs-0.11.0.tar.bz2/src/file/file_posix.c
Changed
@@ -31,15 +31,24 @@ #include <stdlib.h> #include <string.h> -#include <fcntl.h> #include <unistd.h> -#include <sys/stat.h> #include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#ifdef __ANDROID__ +# undef lseek +# define lseek lseek64 +# undef off_t +# define off_t off64_t +#endif static void _file_close(AACS_FILE_H *file) { if (file) { - close((int)(intptr_t)file->internal); + if (close((int)(intptr_t)file->internal)) { + BD_DEBUG(DBG_CRIT | DBG_FILE, "Error closing POSIX file (%p)\n", (void*)file); + } BD_DEBUG(DBG_FILE, "Closed POSIX file (%p)\n", (void*)file); @@ -67,7 +76,7 @@ ssize_t got, result; if (size <= 0 || size >= BD_MAX_SSIZE) { - BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %"PRId64" (%p)\n", size, (void*)file); + BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %" PRId64 " (%p)\n", size, (void*)file); return 0; } @@ -92,7 +101,14 @@ ssize_t written, result; if (size <= 0 || size >= BD_MAX_SSIZE) { - BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid write of size %"PRId64" (%p)\n", size, (void*)file); + if (size == 0) { + if (fsync((int)(intptr_t)file->internal)) { + BD_DEBUG(DBG_FILE, "fsync() failed (%p)\n", (void*)file); + return -1; + } + return 0; + } + BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid write of size %" PRId64 " (%p)\n", size, (void*)file); return 0; }
View file
libaacs-0.10.0.tar.bz2/src/file/file_win32.c -> libaacs-0.11.0.tar.bz2/src/file/file_win32.c
Changed
@@ -39,7 +39,9 @@ static void _file_close(AACS_FILE_H *file) { if (file) { - fclose((FILE *)file->internal); + if (fclose((FILE *)file->internal)) { + BD_DEBUG(DBG_FILE | DBG_CRIT, "Error closing WIN32 file (%p)\n", (void*)file); + } BD_DEBUG(DBG_FILE, "Closed WIN32 file (%p)\n", (void*)file); @@ -71,7 +73,7 @@ return (int64_t)fread(buf, 1, (size_t)size, (FILE *)file->internal); } - BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %"PRId64" (%p)\n", size, (void*)file); + BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %" PRId64 " (%p)\n", size, (void*)file); return 0; } @@ -81,7 +83,15 @@ return (int64_t)fwrite(buf, 1, (size_t)size, (FILE *)file->internal); } - BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid write of size %"PRId64" (%p)\n", size, (void*)file); + if (size == 0) { + if (fflush((FILE *)file->internal)) { + BD_DEBUG(DBG_FILE, "fflush() failed (%p)\n", (void*)file); + return -1; + } + return 0; + } + + BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid write of size %" PRId64 " (%p)\n", size, (void*)file); return 0; } @@ -128,7 +138,10 @@ { wchar_t wfileMAX_PATH; - MultiByteToWideChar(CP_UTF8, 0, file, -1, wfile, MAX_PATH); + if (!MultiByteToWideChar(CP_UTF8, 0, file, -1, wfile, MAX_PATH)) { + return -1; + } + return _wremove(wfile); } @@ -136,7 +149,9 @@ { wchar_t wpathMAX_PATH; - MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH); + if (!MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH)) { + return -1; + } DWORD dwAttrib = GetFileAttributesW(wpath); if (dwAttrib != INVALID_FILE_ATTRIBUTES) { @@ -149,7 +164,9 @@ { wchar_t wdirMAX_PATH; - MultiByteToWideChar(CP_UTF8, 0, dir, -1, wdir, MAX_PATH); + if (!MultiByteToWideChar(CP_UTF8, 0, dir, -1, wdir, MAX_PATH)) { + return -1; + } if (!CreateDirectoryW(wdir, NULL)) return -1; return 0;
View file
libaacs-0.10.0.tar.bz2/src/file/filesystem.h -> libaacs-0.11.0.tar.bz2/src/file/filesystem.h
Changed
@@ -20,8 +20,16 @@ #ifndef AACS_FILESYSTEM_H_ #define AACS_FILESYSTEM_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include <stdint.h> +/* + * file access + */ + typedef struct aacs_file_s AACS_FILE_H; struct aacs_file_s { @@ -68,5 +76,8 @@ struct aacs; AACS_PUBLIC void aacs_set_fopen(struct aacs *aacs, void *handle, AACS_FILE_OPEN2 p); +#ifdef __cplusplus +} +#endif #endif /* AACS_FILESYSTEM_H_ */
View file
libaacs-0.10.0.tar.bz2/src/file/keydb.h -> libaacs-0.11.0.tar.bz2/src/file/keydb.h
Changed
@@ -1,8 +1,6 @@ /* encrypted keys */ -static const uint32_t internal_device_number = 0; - static const uint8_t internal_dk_list21 = { { },
View file
libaacs-0.10.0.tar.bz2/src/file/keydbcfg-parser.y -> libaacs-0.11.0.tar.bz2/src/file/keydbcfg-parser.y
Changed
@@ -1,5 +1,22 @@ %code requires { #include "file/keydbcfg.h" + +#define MAX_KEY_SIZE 128 + +typedef struct { + title_entry_list *celist; /* current disc entry or NULL */ + digit_key_pair_list *dkplist; /* current list */ + + const uint64_t *want_disc_id; /* parse only this disc (none if NULL) */ + int all_discs; /* parse entries for all discs */ + + size_t hexkey_size; + union { /* make sure we're properly aligned */ + char bMAX_KEY_SIZE; + uint64_t u645; + } hexkey; +} parser_state; + } %code { @@ -23,6 +40,7 @@ */ #include "util/macro.h" +#include "util/strutl.h" #include <stdio.h> #include <stdlib.h> @@ -48,7 +66,6 @@ while (X) \ { \ digit_key_pair_list *pnext = X->next;\ - X_FREE(X->key_pair.key); \ X_FREE(X); \ X = pnext; \ } \ @@ -78,19 +95,29 @@ static void add_cert_entry(config_file *cf, char *host_priv_key, char *host_cert); static title_entry_list *new_title_entry_list(void); -static int add_entry(title_entry_list *list, int type, char *entry); -static digit_key_pair_list *new_digit_key_pair_list(void); -static digit_key_pair_list *add_digit_key_pair_entry(digit_key_pair_list *list, - int type, unsigned int digit, char *key); +static int add_entry(title_entry_list *list, int type, const char *entry); +static digit_key_pair_list *new_digit_key_pair_entry(int type, unsigned int digit, const char *key); /* static int add_date_entry(title_entry_list *list, unsigned int year, unsigned int month, unsigned int day); */ -void yyerror (void *scanner, config_file *cf, - title_entry_list *celist, digit_key_pair_list *dkplist, - const char *msg); +void yyerror (void *scanner, config_file *cf, parser_state *ps, const char *msg); extern int libaacs_yyget_lineno (void *scanner); +static inline int _discid_cmp(const uint64_t *want_disc_id, const uint64_t *disc_id) +{ + unsigned i; + + /* We know input strings are valid hex strings, len 40: + * want_disc_id was created from binary data, disc_id was checked by lexer and parser. + * -> we just need to make sure all letters are lower case (= bit 0x20 set) + */ + for (i = 0; i < 40/sizeof(uint64_t); i++) + if (want_disc_idi != (disc_idi | UINT64_C(0x2020202020202020))) + return 0; + return 1; +} + /* uncomment the line below for debugging */ // int yydebug = 1; } @@ -105,8 +132,7 @@ %lex-param{void *scanner} %parse-param{void *scanner} %parse-param{config_file *cf} -%parse-param{title_entry_list *celist} -%parse-param{digit_key_pair_list *dkplist} +%parse-param{parser_state *ps} %union { @@ -147,7 +173,7 @@ %token BAD_ENTRY %type <string> discid disc_title -%type <string> host_priv_key host_cert host_nonce host_key_point hexstring_list +%type <string> host_priv_key host_cert host_nonce host_key_point hexstring_list hexkey %type <string> device_key device_node key_uv key_u_mask_shift %% config_file @@ -283,20 +309,24 @@ disc_info : discid PUNCT_EQUALS_SIGN disc_title { - if (!cf->list) { - celist = cf->list = new_title_entry_list(); + if (ps->hexkey_size != 40) { + fprintf(stderr, "Ignoring invalid disc id: %s (len = %zu)\n", $1, ps->hexkey_size); + ps->celist = NULL; + } else if (!ps->all_discs && (!ps->want_disc_id || !_discid_cmp(ps->want_disc_id, ps->hexkey.u64))) { + ps->celist = NULL; /* ignore this disc */ } else { - for (; celist->next; celist = celist->next) ; - celist->next = new_title_entry_list(); - celist = celist->next; + ps->celist = new_title_entry_list(); + if (ps->celist) { + ps->celist->next = cf->list; + cf->list = ps->celist; + hexstring_to_hex_array(ps->celist->entry.discid, 20, ps->hexkey.b); + } } - add_entry(celist, ENTRY_TYPE_DISCID, $1); - /*add_entry(celist, ENTRY_TYPE_TITLE, $3);*/ } ; discid - : hexstring_list + : hexkey ; disc_title @@ -329,23 +359,23 @@ ; mek_entry - : ENTRY_ID_MEK hexstring_list + : ENTRY_ID_MEK hexkey { - add_entry(celist, ENTRY_TYPE_MEK, $2); + add_entry(ps->celist, ENTRY_TYPE_MEK, $2); } ; vid_entry - : ENTRY_ID_VID hexstring_list + : ENTRY_ID_VID hexkey { - add_entry(celist, ENTRY_TYPE_VID, $2); + add_entry(ps->celist, ENTRY_TYPE_VID, $2); } ; bn_entry : ENTRY_ID_BN bn_data_list { - dkplist = NULL; + ps->dkplist = NULL; } ; @@ -369,16 +399,16 @@ ; vuk_entry - : ENTRY_ID_VUK hexstring_list + : ENTRY_ID_VUK hexkey { - add_entry(celist, ENTRY_TYPE_VUK, $2); + add_entry(ps->celist, ENTRY_TYPE_VUK, $2); } ; pak_entry : ENTRY_ID_PAK pak_data_list { - dkplist = NULL; + ps->dkplist = NULL; } ; @@ -404,7 +434,7 @@ tk_entry : ENTRY_ID_TK tk_data_list { - dkplist = NULL; + ps->dkplist = NULL; } ; @@ -430,7 +460,7 @@ uk_entry : ENTRY_ID_UK uk_data_list { - dkplist = NULL; + ps->dkplist = NULL; } ; @@ -440,17 +470,54 @@ ; uk_data - : DIGIT PUNCT_HYPHEN hexstring_list
View file
libaacs-0.10.0.tar.bz2/src/file/keydbcfg.c -> libaacs-0.11.0.tar.bz2/src/file/keydbcfg.c
Changed
@@ -168,9 +168,10 @@ pk_list *e = calloc(1, sizeof(pk_list)); if (e) { - hexstring_to_hex_array(e->key, 16, str); - - if (_is_duplicate_pk(cf->pkl, e->key)) { + if (!hexstring_to_hex_array(e->key, 16, str)) { + BD_DEBUG(DBG_FILE, "Skipping invalid processing key %s\n", str); + X_FREE(e); + } else if (_is_duplicate_pk(cf->pkl, e->key)) { BD_DEBUG(DBG_FILE, "Skipping duplicate processing key %s\n", str); X_FREE(e); } else { @@ -229,10 +230,11 @@ cert_list *e = calloc(1, sizeof(cert_list)); if (e) { - hexstring_to_hex_array(e->host_priv_key, 20, host_priv_key); - hexstring_to_hex_array(e->host_cert, 92, host_cert); - - if (_is_duplicate_cert(cf->host_cert_list, e)) { + if (!hexstring_to_hex_array(e->host_priv_key, 20, host_priv_key) || + !hexstring_to_hex_array(e->host_cert, 92, host_cert)) { + BD_DEBUG(DBG_FILE, "Skipping invalid certificate entry %s %s\n", host_priv_key, host_cert); + X_FREE(e); + } else if (_is_duplicate_cert(cf->host_cert_list, e)) { BD_DEBUG(DBG_FILE, "Skipping duplicate certificate entry %s %s\n", host_priv_key, host_cert); X_FREE(e); } else { @@ -313,7 +315,7 @@ return NULL; } - hex_array_to_hexstring(disc_id_str, disc_id, 20); + str_print_hex(disc_id_str, disc_id, 20); result = str_printf("%s"DIR_SEP"%s"DIR_SEP"%s"DIR_SEP"%s", cache_dir, CFG_DIR, type, disc_id_str); X_FREE(cache_dir); @@ -331,7 +333,7 @@ AACS_FILE_H *fp = file_open(file, "w"); if (fp) { - hex_array_to_hexstring(key_str, key, len); + str_print_hex(key_str, key, len); if (file_write(fp, key_str, len*2) == len*2) { BD_DEBUG(DBG_FILE, "Wrote %s to %s\n", type, file); @@ -547,7 +549,7 @@ } -static int _load_config_file(config_file *cf, int system) +static int _load_config_file(config_file *cf, int system, const uint8_t *disc_id) { static const char cfg_file_name = CFG_FILE_NAME; @@ -565,7 +567,7 @@ BD_DEBUG(DBG_FILE, "found config file: %s\n", cfg_file); file_close(fp); - result = keydbcfg_parse_config(cf, cfg_file); + result = keydbcfg_parse_config(cf, cfg_file, disc_id, 0); } X_FREE(cfg_file); @@ -588,9 +590,9 @@ break; decrypt_key(e->key, internal_dk_listjj, 16); - e->node = internal_device_number; - e->uv = MKINT_BE32(internal_dk_listjj + 16); - e->u_mask_shift = internal_dk_listjj20; + e->node = MKINT_BE16(internal_dk_listjj + 16); + e->uv = MKINT_BE32(internal_dk_listjj + 16 + 2); + e->u_mask_shift = internal_dk_listjj20 + 2; if (!e->uv || _is_duplicate_dk(cf->dkl, e)) { X_FREE(e); @@ -646,7 +648,26 @@ return result; } -config_file *keydbcfg_config_load(const char *configfile_path) +static void _config_summary(config_file *cf) +{ + int n; + dk_list *dkl = cf->dkl; + pk_list *pkl = cf->pkl; + cert_list *hcl = cf->host_cert_list; + title_entry_list *tel = cf->list; + + BD_DEBUG(DBG_AACS, "Config summary:\n"); + for (n = 0; dkl; dkl = dkl->next, n++) ; + BD_DEBUG(DBG_AACS, " %d Device keys\n", n); + for (n = 0; pkl; pkl = pkl->next, n++) ; + BD_DEBUG(DBG_AACS, " %d Processing keys\n", n); + for (n = 0; hcl; hcl = hcl->next, n++) ; + BD_DEBUG(DBG_AACS, " %d Host certificates\n", n); + for (n = 0; tel; tel = tel->next, n++) ; + BD_DEBUG(DBG_AACS, " %d Disc entries\n", n); +} + +config_file *keydbcfg_config_load(const char *configfile_path, const uint8_t *disc_id) { int config_ok = 0; @@ -658,14 +679,14 @@ /* try to load KEYDB.cfg */ if (configfile_path) { - config_ok = keydbcfg_parse_config(cf, configfile_path); + config_ok = keydbcfg_parse_config(cf, configfile_path, disc_id, 0); } else { /* If no configfile path given, check for config files in user's home and * under /etc. */ - config_ok = _load_config_file(cf, 0); - config_ok = _load_config_file(cf, 1) || config_ok; + config_ok = _load_config_file(cf, 0, disc_id); + config_ok = _load_config_file(cf, 1, disc_id) || config_ok; } /* Try to load simple (aacskeys) config files */ @@ -682,6 +703,8 @@ return NULL; } + _config_summary(cf); + return cf; }
View file
libaacs-0.10.0.tar.bz2/src/file/keydbcfg.h -> libaacs-0.11.0.tar.bz2/src/file/keydbcfg.h
Changed
@@ -30,7 +30,7 @@ struct digit_key_pair_t { unsigned int digit; - char *key; + uint8_t key16; }; /* list of digit_key_pair struct used in title entry */ @@ -89,8 +89,8 @@ uint8_t discid20; //char *title; //date_entry date; - char *mek; - char *vid; + uint8_t mk16; + uint8_t vid16; //digit_key_pair_list *bn; uint8_t vuk16; //digit_key_pair_list *pak; @@ -116,14 +116,13 @@ title_entry_list *list; }; -/* Functions used throughout the parser */ -BD_PRIVATE int keydbcfg_parse_config(config_file *cfgfile, const char *path); +BD_PRIVATE int keydbcfg_parse_config(config_file *cfgfile, const char *path, const uint8_t *disc_id, int all_discs); BD_PRIVATE config_file *keydbcfg_new_config_file(void); BD_PRIVATE int keydbcfg_config_file_close(config_file *cfgfile); /* */ -BD_PRIVATE config_file *keydbcfg_config_load(const char *configfile_path); +BD_PRIVATE config_file *keydbcfg_config_load(const char *configfile_path, const uint8_t *disc_id); BD_PRIVATE int keycache_save(const char *type, const uint8_t *disc_id, const uint8_t *key, unsigned int len);
View file
libaacs-0.10.0.tar.bz2/src/file/mmc_device_darwin.c -> libaacs-0.11.0.tar.bz2/src/file/mmc_device_darwin.c
Changed
@@ -371,13 +371,13 @@ static int iokit_da_init(MMCDEV *mmc) { mmc->session = DASessionCreate(kCFAllocatorDefault); if (NULL == mmc->session) { - BD_DEBUG(DBG_MMC, "Could not create a disc arbitration session\n"); + BD_DEBUG(DBG_MMC | DBG_CRIT, "Could not create a disc arbitration session\n"); return -1; } mmc->disk = DADiskCreateFromBSDName(kCFAllocatorDefault, mmc->session, mmc->bsd_name); if (NULL == mmc->disk) { - BD_DEBUG(DBG_MMC, "Could not create a disc arbitration disc for the device\n"); + BD_DEBUG(DBG_MMC | DBG_CRIT, "Could not create a disc arbitration disc for the device\n"); CFRelease(mmc->session); mmc->session = NULL; return -1; @@ -429,14 +429,14 @@ /* get the bsd name associated with this mount */ rc = get_mounted_device_from_path(mmc, path); if (0 != rc) { - BD_DEBUG(DBG_MMC, "Could not locate mounted device associated with %s\n", path); + BD_DEBUG(DBG_MMC | DBG_CRIT, "Could not locate mounted device associated with %s\n", path); return rc; } /* find a matching io service (IOBDServices) */ rc = iokit_find_service_matching(mmc, &service); if (0 != rc) { - BD_DEBUG(DBG_MMC, "Could not find matching IOBDServices mounted @ %s\n", path); + BD_DEBUG(DBG_MMC | DBG_CRIT, "Could not find matching IOBDServices mounted @ %s\n", path); return rc; } @@ -446,6 +446,10 @@ /* done with the ioservice. release it */ (void) IOObjectRelease(service); + if (0 != rc) { + return rc; + } + /* Init DiskArbitration */ rc = iokit_da_init(mmc); if (0 != rc) { @@ -463,7 +467,7 @@ /* finally, obtain exclusive access */ rc = (*mmc->taskInterface)->ObtainExclusiveAccess(mmc->taskInterface); if (kIOReturnSuccess != rc) { - BD_DEBUG(DBG_MMC, "Failed to obtain exclusive access. rc = %x\n", rc); + BD_DEBUG(DBG_MMC | DBG_CRIT, "Failed to obtain exclusive access. rc = %x\n", rc); return -1; } @@ -533,6 +537,12 @@ IODestroyPlugInInterface(mmc->plugInInterface); } + if (!mmc->sync_sem) { + /* open failed before iokit_da_init() */ + X_FREE(*pp); + return; + } + /* Wait for disc to re-appear for 20 seconds. * This timeout was figured out by experimentation with * a USB BD drive which sometimes can take really long to
View file
libaacs-0.10.0.tar.bz2/src/libaacs/aacs.c -> libaacs-0.11.0.tar.bz2/src/libaacs/aacs.c
Changed
@@ -81,6 +81,7 @@ int bee; /* bus encryption enabled flag in content certificate */ int bec; /* bus encryption capable flag in drive certificate */ uint8_t read_data_key16; + uint8_t drive_cert_hash20; /* content certificate */ CONTENT_CERT *cc; @@ -472,17 +473,67 @@ return *data ? size : 0; } +static size_t _read_mkb_file(AACS *aacs, const char *file, void **pdata) +{ + AACS_FILE_H *fp; + size_t size = 0; + size_t data_size = 65536; /* initial alloc */ + uint32_t chunk_size = 4; /* initial read */ + uint8_t *data; + + *pdata = NULL; + + fp = _file_open(aacs, file); + if (!fp) { + BD_DEBUG(DBG_AACS | DBG_CRIT, "Unable to open %s\n", file); + return 0; + } + + data = malloc(data_size); + if (!data) { + BD_DEBUG(DBG_AACS | DBG_CRIT, "Out of memory\n"); + file_close(fp); + return 0; + } + + do { + int64_t read_size = chunk_size; + if (file_read(fp, data + size, read_size) != read_size) { + BD_DEBUG(DBG_AACS | DBG_CRIT, "Failed reading %s\n", file); + X_FREE(data); + break; + } + size += read_size; + chunk_size = MKINT_BE24(data + size - 4 + 1); + if (data_size < size + chunk_size) { + for ( ; data_size < size + chunk_size; data_size *= 2) ; + void *tmp = realloc(data, data_size); + if (!tmp) { + X_FREE(data); + break; + } + data = tmp; + } + } while (chunk_size >= 4); + + file_close(fp); + + *pdata = data; + + return data ? size : 0; +} + static MKB *_mkb_open(AACS *aacs) { size_t size; void *data; MKB *mkb; - size = _read_file(aacs, "AACS" DIR_SEP "MKB_RO.inf", &data); + size = _read_mkb_file(aacs, "AACS" DIR_SEP "MKB_RO.inf", &data); if (size < 4) { /* retry with backup file */ X_FREE(data); - size = _read_file(aacs, "AACS" DIR_SEP "DUPLICATE" DIR_SEP "MKB_RO.inf", &data); + size = _read_mkb_file(aacs, "AACS" DIR_SEP "DUPLICATE" DIR_SEP "MKB_RO.inf", &data); } if (size < 4) { X_FREE(data); @@ -561,6 +612,12 @@ return AACS_SUCCESS; } + /* get cached mk */ + if (!aacs->no_cache && keycache_find("mk", aacs->disc_id, mk, 16)) { + BD_DEBUG(DBG_AACS, "Using cached MK\n"); + return AACS_SUCCESS; + } + BD_DEBUG(DBG_AACS, "Calculate media key...\n"); mkb = _mkb_open(aacs); @@ -585,6 +642,12 @@ if (result == AACS_SUCCESS) { memcpy(aacs->mk, mk, sizeof(aacs->mk)); + /* cache mk */ + if (!aacs->no_cache) { + if (memcmp(aacs->disc_id, empty_key, sizeof(aacs->disc_id))) { + keycache_save("mk", aacs->disc_id, mk, 16); + } + } } mkb_close(mkb); @@ -668,10 +731,33 @@ static int _read_read_data_key(AACS *aacs, cert_list *hcl) { - int error_code = _mmc_read_auth(aacs, hcl, MMC_READ_DATA_KEYS, aacs->read_data_key, NULL); + int error_code; + char *cache_path = NULL; + char str41; + + cache_path = str_printf("rdk" DIR_SEP "%s", str_print_hex(str, aacs->drive_cert_hash, 20)); + + error_code =_mmc_read_auth(aacs, hcl, MMC_READ_DATA_KEYS, aacs->read_data_key, NULL); + if (error_code == AACS_SUCCESS) { + /* cache read data key */ + if (!aacs->no_cache) { + keycache_save(cache_path, aacs->disc_id, aacs->read_data_key, 16); + } + + } else { + /* get cached read data key */ + if (!aacs->no_cache && keycache_find(cache_path, aacs->disc_id, aacs->read_data_key, 16)) { + BD_DEBUG(DBG_AACS, "Using cached READ DATA KEY\n"); + error_code = AACS_SUCCESS; + } + } + + X_FREE(cache_path); + if (error_code != AACS_SUCCESS) { BD_DEBUG(DBG_AACS, "Error reading data keys!\n"); } + return error_code; } @@ -743,9 +829,10 @@ } /* Function that collects keys from keydb config entry */ -static void _find_config_entry(AACS *aacs, title_entry_list *ce, +static void _find_config_entry(AACS *aacs, config_file *cf, uint8_t *mk, uint8_t *vuk) { + title_entry_list *ce = cf->list; char str48; char str248; @@ -762,16 +849,16 @@ return; } - if (ce->entry.mek) { - hexstring_to_hex_array(mk, 16, ce->entry.mek); + if (memcmp(ce->entry.mk, empty_key, 16)) { + memcpy(mk, ce->entry.mk, 16); + memcpy(aacs->mk, mk, 16); BD_DEBUG(DBG_AACS, "Found media key for %s: %s\n", str_print_hex(str2, ce->entry.discid, 20), str_print_hex(str, mk, 16)); } - if (ce->entry.vid) { - hexstring_to_hex_array(aacs->vid, sizeof(aacs->vid), - ce->entry.vid); + if (memcmp(ce->entry.vid, empty_key, 16)) { + memcpy(aacs->vid, ce->entry.vid, 16); BD_DEBUG(DBG_AACS, "Found volume id for %s: %s\n", str_print_hex(str2, ce->entry.discid, 20), str_print_hex(str, aacs->vid, 16)); @@ -790,20 +877,29 @@ /* count keys */ unsigned num_uks = 0; digit_key_pair_list *ukcursor = ce->entry.uk; - while (ukcursor && ukcursor->key_pair.key) { + while (ukcursor) { num_uks++; ukcursor = ukcursor->next; } - /* check against Unit_Key_RO.inf */ + /* check against Unit_Key_RO.inf, only discard incorrect amount of UKs if VUK or MK+VID is available */ if (num_uks != aacs->uk->num_uk) { - BD_DEBUG(DBG_CRIT | DBG_AACS, "Ignoring unit keys from config file (expected %u keys, found %u)\n", + if (_calc_vuk(aacs, mk, vuk, cf) == AACS_SUCCESS) { + BD_DEBUG(DBG_CRIT | DBG_AACS, "Ignoring unit keys from config file (expected %u keys, found %u)\n", + aacs->uk->num_uk, num_uks); + return; + } + BD_DEBUG(DBG_CRIT | DBG_AACS, "Incomplete unit keys in config file (expected %u keys, found %u)\n", aacs->uk->num_uk, num_uks); - return; } /* get keys */ + if (num_uks > aacs->uk->num_uk) {
View file
libaacs-0.10.0.tar.bz2/src/libaacs/crypto.c -> libaacs-0.11.0.tar.bz2/src/libaacs/crypto.c
Changed
@@ -325,7 +325,7 @@ /* Points are currently only supported in standard format, so get a * hexstring out of Q. */ - hex_array_to_hexstring(str_Q, Q, 1 + 2*key_len); + str_print_hex(str_Q, Q, 1 + 2*key_len); char *strfmt = str_printf( "(%s"
View file
libaacs-0.10.0.tar.bz2/src/libaacs/mkb.c -> libaacs-0.11.0.tar.bz2/src/libaacs/mkb.c
Changed
@@ -77,6 +77,7 @@ mkb->buf = data; BD_DEBUG(DBG_MKB, "MKB size: %u\n", (unsigned)mkb->size); + BD_DEBUG(DBG_MKB, "MKB type: 0x%x\n", mkb_type(mkb)); BD_DEBUG(DBG_MKB, "MKB version: %d\n", mkb_version(mkb)); return mkb; @@ -110,7 +111,7 @@ } -uint8_t mkb_type(MKB *mkb) +uint32_t mkb_type(MKB *mkb) { const uint8_t *rec = mkb_type_and_version_record(mkb); @@ -207,12 +208,29 @@ const uint8_t *mkb_mk_dv(MKB *mkb) { + const uint8_t *rec; + uint8_t dv_record; size_t len; - const uint8_t *rec = _record(mkb, 0x81, &len); + + switch (mkb_type(mkb)) { + case MKB_20_CATEGORY_C: + case MKB_21_CATEGORY_C: + dv_record = 0x86; + break; + case MKB_TYPE_3: + case MKB_TYPE_4: + case MKB_TYPE_10_CLASS_II: + default: + dv_record = 0x81; + break; + } + + rec = _record(mkb, dv_record, &len); if (len < 20) { return NULL; } + if (rec) { rec += 4; }
View file
libaacs-0.10.0.tar.bz2/src/libaacs/mkb.h -> libaacs-0.11.0.tar.bz2/src/libaacs/mkb.h
Changed
@@ -29,6 +29,12 @@ struct aacs_file_s; +#define MKB_TYPE_3 0x00031003 +#define MKB_TYPE_4 0x00041003 +#define MKB_TYPE_10_CLASS_II 0x000A1003 +#define MKB_20_CATEGORY_C 0x48141003 +#define MKB_21_CATEGORY_C 0x48151003 + BD_PRIVATE MKB *mkb_init(uint8_t *data, size_t len); // init MKB from data BD_PRIVATE void mkb_close(MKB *mkb); // free MKB @@ -36,7 +42,7 @@ BD_PRIVATE size_t mkb_data_size(MKB *mkb); // returns type -BD_PRIVATE uint8_t mkb_type(MKB *mkb); +BD_PRIVATE uint32_t mkb_type(MKB *mkb); // returns version BD_PRIVATE uint32_t mkb_version(MKB *mkb); // returns type and version record (required to verify signatures)
View file
libaacs-0.10.0.tar.bz2/src/libaacs/unit_key.c -> libaacs-0.11.0.tar.bz2/src/libaacs/unit_key.c
Changed
@@ -143,8 +143,9 @@ return 0; } -static int _parse_uks(AACS_UK *uk, const uint8_t *p, size_t size) +static int _parse_uks(AACS_UK *uk, const uint8_t *p, size_t size, int aacs2) { + const uint8_t empty_key16 = {0}; uint32_t uk_pos; unsigned int i; @@ -173,6 +174,17 @@ return -1; } + if (aacs2 && uk->num_uk > 1) { + /* do some sanity checks ... */ + if (!memcmp(empty_key, p + 48 + 48 + 16, 16)) { + BD_DEBUG(DBG_UK | DBG_CRIT, "AACS2 unit key not found from expected location ?\n"); + aacs2 = 0; + } else if (size < uk_pos + 64 * uk->num_uk + 16) { + BD_DEBUG(DBG_UK | DBG_CRIT, "Unexpected EOF (AACS2 unit key data truncated)\n"); + return -1; + } + } + /* alloc storage for keys */ uk->enc_uk = calloc(uk->num_uk, sizeof(AACS_UK)); @@ -181,19 +193,29 @@ return -1; } - BD_DEBUG(DBG_UK, "%d CPS unit keys\n", uk->num_uk); + BD_DEBUG(DBG_UK, "%d CPS unit keys (AACS%d)\n", uk->num_uk, aacs2 ? 2 : 1); /* get encrypted keys */ for (i = 0; i < uk->num_uk; i++) { uk_pos += 48; memcpy(uk->enc_uki.key, p + uk_pos, 16); + + if (!memcmp(empty_key, uk->enc_uki.key, 16)) { + BD_DEBUG(DBG_UK | DBG_CRIT, "WARNING: Unit key %d is empty!\n", i+1); + } + + /* XXX there seems to be nothing in this file that could be used to detect this ... */ + if (aacs2) { + /* skip unknown */ + uk_pos += 16; + } } return 0; } -static int _parse(AACS_UK *uk, const uint8_t *data, size_t len) +static int _parse(AACS_UK *uk, const uint8_t *data, size_t len, int aacs2) { int result; @@ -201,7 +223,7 @@ return -1; } - result = _parse_uks(uk, data, len); + result = _parse_uks(uk, data, len, aacs2); /* not fatal, just speeds up things ... */ _assign_titles(uk, data, len); @@ -209,7 +231,7 @@ return result; } -AACS_UK *uk_parse(const void *data, size_t len) +AACS_UK *uk_parse(const void *data, size_t len, int aacs2) { AACS_UK *uk = calloc(1, sizeof(*uk)); @@ -217,7 +239,7 @@ return NULL; } - if (_parse(uk, data, len) < 0) { + if (_parse(uk, data, len, aacs2) < 0) { BD_DEBUG(DBG_UK | DBG_CRIT, "Corrupt unit key file (AACS/Unit_Key_RO.inf)\n"); X_FREE(uk); }
View file
libaacs-0.10.0.tar.bz2/src/libaacs/unit_key.h -> libaacs-0.11.0.tar.bz2/src/libaacs/unit_key.h
Changed
@@ -50,7 +50,7 @@ uint16_t *title_cps_unit; /* map title to CPS unit (key index) */ }; -BD_PRIVATE AACS_UK *uk_parse(const void *data, size_t len); +BD_PRIVATE AACS_UK *uk_parse(const void *data, size_t len, int aacs2); BD_PRIVATE void uk_free(AACS_UK **); #endif /* AACS_UK_H_ */
View file
libaacs-0.10.0.tar.bz2/src/util/strutl.c -> libaacs-0.11.0.tar.bz2/src/util/strutl.c
Changed
@@ -141,22 +141,6 @@ return 1; } -/* Function to convert a hex array into a hex string. - * str must be allocated by caller - * size is the size of the hex_array - */ -int hex_array_to_hexstring(char *str, const uint8_t *hex_array, uint32_t size) -{ - unsigned int i; - - for (i = 0; i < size; i++) - { - sprintf(str + (i*2), "%02x", hex_arrayi); - } - - return 1; -} - char *str_dup(const char *str) { char *dup = NULL; @@ -265,10 +249,13 @@ char *str_print_hex(char *out, const uint8_t *buf, int count) { + static const char nibble16 = "0123456789abcdef"; int zz; for (zz = 0; zz < count; zz++) { - sprintf(out + (zz * 2), "%02x", bufzz); + outzz*2 = nibblebufzz >> 4; + outzz*2 + 1 = nibblebufzz & 0x0f; } + outzz*2 = 0; return out; }
View file
libaacs-0.10.0.tar.bz2/src/util/strutl.h -> libaacs-0.11.0.tar.bz2/src/util/strutl.h
Changed
@@ -26,7 +26,6 @@ BD_PRIVATE int hexstring_to_hex_array(uint8_t *hex_array, uint32_t size, const char *hexstring); -BD_PRIVATE int hex_array_to_hexstring(char *str, const uint8_t *hex_array, uint32_t size); BD_PRIVATE char * str_dup(const char *str) BD_ATTR_MALLOC; BD_PRIVATE char * str_printf(const char *fmt, ...) BD_ATTR_FORMAT_PRINTF(1,2) BD_ATTR_MALLOC;
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.