libaacs | branch: master | npzacs <[email protected]> | Fri May  4 10:41:54 2012 
+0300| [6ff177eaadefde6895028f27d49f3f289d614b26] | committer: npzacs

Added revocation lists to aacs_info

> http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=6ff177eaadefde6895028f27d49f3f289d614b26
---

 src/examples/aacs_info.c |   36 ++++++++++++++++++++++++++++++++++++
 src/libaacs/aacs.c       |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 src/libaacs/aacs.h       |   12 +++++++++++-
 3 files changed, 93 insertions(+), 1 deletions(-)

diff --git a/src/examples/aacs_info.c b/src/examples/aacs_info.c
index fd87c0e..3c7ca18 100644
--- a/src/examples/aacs_info.c
+++ b/src/examples/aacs_info.c
@@ -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;
 }
diff --git a/src/libaacs/aacs.c b/src/libaacs/aacs.c
index 71fc193..5f25226 100644
--- a/src/libaacs/aacs.c
+++ b/src/libaacs/aacs.c
@@ -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) {
diff --git a/src/libaacs/aacs.h b/src/libaacs/aacs.h
index 070ee8b..1aa5a2d 100644
--- a/src/libaacs/aacs.h
+++ b/src/libaacs/aacs.h
@@ -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_ */

_______________________________________________
libaacs-devel mailing list
[email protected]
http://mailman.videolan.org/listinfo/libaacs-devel

Reply via email to