Commit 6ff177ea authored by npzacs's avatar npzacs
Browse files

Added revocation lists to aacs_info

parent 3ea58ea8
......@@ -18,6 +18,7 @@
*/
#include "libaacs/aacs.h"
#include "../util/macro.h" /* MKINT_BE48 */
#include <stdio.h>
#include <stdlib.h>
......@@ -62,6 +63,28 @@ static const char *_error_str(int error_code)
return "Unknown error";
}
static void _dump_rl(const char *type, AACS_RL_ENTRY *rl, int num_entries, int mkb_version)
{
int ii;
printf("%s Revocation List (MKB version %d):\n", type, mkb_version);
if (num_entries < 1 || !rl) {
printf(" (empty)\n");
return;
}
for (ii = 0; ii < num_entries; ii++) {
unsigned long long id = MKINT_BE48(rl[ii].id);
if (rl[ii].range) {
printf(" %012llx - %012llx\n", id, id + rl[ii].range);
} else {
printf(" %012llx\n", id);
}
}
}
int main (int argc, char **argv)
{
int major, minor, micro, error_code = AACS_SUCCESS;
......@@ -93,5 +116,18 @@ int main (int argc, char **argv)
aacs_close(aacs);
/* dump revocation lists */
AACS_RL_ENTRY *rl;
int num_entries, mkb_version;
rl = aacs_get_hrl(&num_entries, &mkb_version);
_dump_rl("Host", rl, num_entries, mkb_version);
X_FREE(rl);
rl = aacs_get_drl(&num_entries, &mkb_version);
_dump_rl("Drive", rl, num_entries, mkb_version);
X_FREE(rl);
return EXIT_SUCCESS;
}
......@@ -820,6 +820,52 @@ const uint8_t *aacs_get_vid(AACS *aacs)
return aacs->vid;
}
static AACS_RL_ENTRY *_get_rl(const char *type, int *num_records, int *mkb_version)
{
uint32_t len, version;
void *data = NULL;
*num_records = *mkb_version = 0;
cache_get(type, &version, &len, NULL);
if (version > 0 && len > 24) {
data = malloc(len);
if (cache_get(type, &version, &len, data) && len > 24) {
if (_rl_verify_signature(data, len)) {
*mkb_version = version;
*num_records = MKINT_BE32((uint8_t*)data + 20);
memmove(data, (uint8_t*)data + 24, len - 24);
int ii;
AACS_RL_ENTRY *rl = data;
for (ii = 0; ii < *num_records; ii++) {
rl[ii].range = MKINT_BE16((uint8_t*)&rl[ii].range);
}
return rl;
}
DEBUG(DBG_AACS | DBG_CRIT, "invalid signature in cached %s\n", type);
}
X_FREE(data);
}
return data;
}
AACS_RL_ENTRY *aacs_get_hrl(int *num_records, int *mkb_version)
{
return _get_rl("hrl", num_records, mkb_version);
}
AACS_RL_ENTRY *aacs_get_drl(int *num_records, int *mkb_version)
{
return _get_rl("drl", num_records, mkb_version);
}
void aacs_select_title(AACS *aacs, uint32_t title)
{
if (!aacs) {
......
......@@ -46,8 +46,18 @@ 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);
/* Disc information */
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);
AACS_PUBLIC const uint8_t *aacs_get_vid(AACS *aacs); /* may fail even if disc can be decrypted */
/* revocation lists */
typedef struct {
uint16_t range;
uint8_t id[6];
} AACS_RL_ENTRY;
AACS_PUBLIC AACS_RL_ENTRY *aacs_get_hrl(int *num_entries, int *mkb_version);
AACS_PUBLIC AACS_RL_ENTRY *aacs_get_drl(int *num_entries, int *mkb_version);
#endif /* AACS_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment