Commit 48a25022 authored by npzacs's avatar npzacs Committed by hpi1

Convert unit keys in parser

parent ed63fc91
......@@ -27,9 +27,13 @@
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_key[16] = {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 tmp[256];
if (!list)
{
printf("Error: No digit key pair list passed as parameter.\n");
......@@ -39,10 +43,10 @@ static int print_digit_key_pair_enties(digit_key_pair_list *list)
digit_key_pair_list *cursor = list;
while (cursor)
{
if (!cursor->key_pair.key)
if (!memcmp(cursor->key_pair.key, empty_key, 16))
break;
printf(" %u - %s\n", cursor->key_pair.digit, cursor->key_pair.key);
printf(" %u - %s\n", cursor->key_pair.digit, str_print_hex(tmp, cursor->key_pair.key, 16));
cursor = cursor->next;
}
......@@ -53,7 +57,6 @@ static int print_digit_key_pair_enties(digit_key_pair_list *list)
/* Function that prints all entries parsed from a config file */
static int print_title_entries(title_entry_list *list)
{
static const uint8_t empty_key[16] = {0};
char tmp[256];
if (!list)
......
......@@ -48,7 +48,6 @@
while (X) \
{ \
digit_key_pair_list *pnext = X->next;\
X_FREE(X->key_pair.key); \
X_FREE(X); \
X = pnext; \
} \
......@@ -772,8 +771,15 @@ static digit_key_pair_list *add_digit_key_pair_entry(digit_key_pair_list *list,
return NULL;
}
if (!key || strlen(key) != 32) {
fprintf(stderr, "Ignoring bad UK entry %s\n", key ? key : "<null>");
X_FREE(key);
return list;
}
list->key_pair.digit = digit;
list->key_pair.key = key;
hexstring_to_hex_array(list->key_pair.key, 16, key);
X_FREE(key);
list->next = new_digit_key_pair_list();
......
......@@ -30,7 +30,7 @@ typedef struct digit_key_pair_t digit_key_pair;
struct digit_key_pair_t
{
unsigned int digit;
char *key;
uint8_t key[16];
};
/* list of digit_key_pair struct used in title entry */
......
......@@ -876,7 +876,7 @@ static void _find_config_entry(AACS *aacs, title_entry_list *ce,
/* count keys */
unsigned num_uks = 0;
digit_key_pair_list *ukcursor = ce->entry.uk;
while (ukcursor && ukcursor->key_pair.key) {
while (ukcursor && memcmp(ukcursor->key_pair.key, empty_key, 16)) {
num_uks++;
ukcursor = ukcursor->next;
}
......@@ -897,8 +897,8 @@ static void _find_config_entry(AACS *aacs, title_entry_list *ce,
num_uks = 0;
ukcursor = ce->entry.uk;
while (ukcursor && ukcursor->key_pair.key) {
hexstring_to_hex_array(aacs->uk->uk[num_uks].key, 16, ukcursor->key_pair.key);
while (ukcursor && memcmp(ukcursor->key_pair.key, empty_key, 16)) {
memcpy(aacs->uk->uk[num_uks].key, ukcursor->key_pair.key, 16);
BD_DEBUG(DBG_AACS, "Unit key %u from keydb entry: %s\n",
num_uks,
......
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