libaacs | branch: master | npzacs <[email protected]> | Mon Apr 30 23:25:27 2012 +0300| [b0950da1a0023618297c8eba36896d31ce61a9ef] | committer: npzacs
Added aacs_get_mkb_version() > http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=b0950da1a0023618297c8eba36896d31ce61a9ef --- ChangeLog | 1 + src/examples/aacs_info.c | 1 + src/libaacs/aacs.c | 43 +++++++++++++++++++++++++++++++------------ src/libaacs/aacs.h | 3 ++- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a58fa7..9139949 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ ????-??-??: Version 0.4.0 - Added aacs_open2() and error codes - Renamed libaacs_test to aacs_info + - Added aacs_get_mkb_version() 2012-03-21: Version 0.3.1 - Added configure option for libgcrypt prefix diff --git a/src/examples/aacs_info.c b/src/examples/aacs_info.c index 3815089..d1d7f29 100644 --- a/src/examples/aacs_info.c +++ b/src/examples/aacs_info.c @@ -89,6 +89,7 @@ int main (int argc, char **argv) const uint8_t *id = aacs_get_disc_id(aacs); printf("Disc ID: %s\n", id ? _hex2str(id, 20) : "???"); printf("VID : %s\n", vid ? _hex2str(vid, 20) : "???"); + printf("MKBv : %d\n", aacs_get_mkb_version(aacs)); aacs_close(aacs); diff --git a/src/libaacs/aacs.c b/src/libaacs/aacs.c index a3ce0cd..bf99617 100644 --- a/src/libaacs/aacs.c +++ b/src/libaacs/aacs.c @@ -53,6 +53,9 @@ struct aacs { uint32_t num_titles; uint16_t current_cps_unit; uint16_t *cps_units; /* [0] = first play ; [1] = top menu ; [2] = title 1 ... */ + + char *path; + int mkb_version; }; static const uint8_t empty_key[] = "\x00\x00\x00\x00\x00\x00\x00\x00" @@ -93,7 +96,7 @@ static int _validate_pk(const uint8_t *pk, return AACS_ERROR_NO_PK; } -static int _calc_mk(AACS *aacs, const char *path) +static int _calc_mk(AACS *aacs) { int a, num_uvs = 0; size_t len; @@ -107,8 +110,9 @@ static int _calc_mk(AACS *aacs, const char *path) DEBUG(DBG_AACS, "Calculate media key...\n"); - if ((mkb = mkb_open(path))) { + if ((mkb = mkb_open(aacs->path))) { DEBUG(DBG_AACS, "Get UVS...\n"); + aacs->mkb_version = mkb_version(mkb); uvs = mkb_subdiff_records(mkb, &len); rec = uvs; while (rec < uvs + len) { @@ -151,11 +155,11 @@ static int _calc_mk(AACS *aacs, const char *path) return AACS_ERROR_NO_PK; } - DEBUG(DBG_AACS | DBG_CRIT, "Error opening %s/AACS/MKB_RO.inf\n", path); + DEBUG(DBG_AACS | DBG_CRIT, "Error opening %s/AACS/MKB_RO.inf\n", aacs->path); return AACS_ERROR_CORRUPTED_DISC; } -static int _read_vid(AACS *aacs, const char *path) +static int _read_vid(AACS *aacs) { /* Use VID given in config file if available */ if (memcmp(aacs->vid, empty_key, 16)) { @@ -163,7 +167,7 @@ static int _read_vid(AACS *aacs, const char *path) } MMC* mmc = NULL; - if (!(mmc = mmc_open(path))) { + if (!(mmc = mmc_open(aacs->path))) { return AACS_ERROR_MMC_OPEN; } @@ -211,7 +215,7 @@ static int _read_vid(AACS *aacs, const char *path) return error_code; } -static int _calc_vuk(AACS *aacs, const char *path) +static int _calc_vuk(AACS *aacs) { int error_code; @@ -228,13 +232,13 @@ static int _calc_vuk(AACS *aacs, const char *path) } /* make sure we have media key */ - error_code = _calc_mk(aacs, path); + error_code = _calc_mk(aacs); if (error_code != AACS_SUCCESS) { return error_code; } /* acquire VID */ - error_code = _read_vid(aacs, path); + error_code = _read_vid(aacs); if (error_code != AACS_SUCCESS) { return error_code; } @@ -325,7 +329,7 @@ static AACS_FILE_H *_open_unit_key_file(const char *path) return fp; } -static int _calc_uks(AACS *aacs, const char *path) +static int _calc_uks(AACS *aacs) { AACS_FILE_H *fp = NULL; uint8_t buf[16]; @@ -338,14 +342,14 @@ static int _calc_uks(AACS *aacs, const char *path) return AACS_SUCCESS; /* Make sure we have VUK */ - error_code = _calc_vuk(aacs, path); + error_code = _calc_vuk(aacs); if (error_code != AACS_SUCCESS) { return error_code; } DEBUG(DBG_AACS, "Calculate CPS unit keys...\n"); - fp = _open_unit_key_file(path); + fp = _open_unit_key_file(aacs->path); if (!fp) { return AACS_ERROR_CORRUPTED_DISC; } @@ -651,6 +655,8 @@ AACS *aacs_open2(const char *path, const char *configfile_path, int *error_code) return NULL; } + aacs->path = str_printf("%s", path); + *error_code = _calc_title_hash(path, aacs->disc_id); if (*error_code != AACS_SUCCESS) { aacs_close(aacs); @@ -661,7 +667,7 @@ AACS *aacs_open2(const char *path, const char *configfile_path, int *error_code) _find_config_entry(aacs); DEBUG(DBG_AACS, "Starting AACS waterfall...\n"); - *error_code = _calc_uks(aacs, path); + *error_code = _calc_uks(aacs); keydbcfg_config_file_close(aacs->cf); aacs->cf = NULL; @@ -687,6 +693,7 @@ void aacs_close(AACS *aacs) X_FREE(aacs->uks); X_FREE(aacs->cps_units); + X_FREE(aacs->path); DEBUG(DBG_AACS, "AACS destroyed! (%p)\n", aacs); @@ -719,6 +726,18 @@ int aacs_decrypt_unit(AACS *aacs, uint8_t *buf) return 0; } +int aacs_get_mkb_version(AACS *aacs) +{ + if (!aacs->mkb_version) { + MKB *mkb; + if ((mkb = mkb_open(aacs->path))) { + aacs->mkb_version = mkb_version(mkb); + mkb_close(mkb); + } + } + return aacs->mkb_version; +} + const uint8_t *aacs_get_disc_id(AACS *aacs) { return aacs->disc_id; diff --git a/src/libaacs/aacs.h b/src/libaacs/aacs.h index f2ba4cc..070ee8b 100644 --- a/src/libaacs/aacs.h +++ b/src/libaacs/aacs.h @@ -45,8 +45,9 @@ AACS_PUBLIC AACS *aacs_open2(const char *path, const char *keyfile_path, int *er AACS_PUBLIC void aacs_close(AACS *aacs); AACS_PUBLIC void aacs_select_title(AACS *aacs, uint32_t title); /* 0 - top menu, 0xffff - first play */ AACS_PUBLIC int aacs_decrypt_unit(AACS *aacs, uint8_t *buf); + +AACS_PUBLIC int aacs_get_mkb_version(AACS *aacs); AACS_PUBLIC const uint8_t *aacs_get_disc_id(AACS *aacs); AACS_PUBLIC const uint8_t *aacs_get_vid(AACS *aacs); - #endif /* AACS_H_ */ _______________________________________________ libaacs-devel mailing list [email protected] http://mailman.videolan.org/listinfo/libaacs-devel
