[libbluray-devel] aacs: support retrieving content certificate information
npzacs
git at videolan.org
Tue Mar 29 12:42:20 CEST 2016
libbluray | branch: master | npzacs <npzacs at gmail.com> | Tue Mar 29 13:31:07 2016 +0300| [aba38316a036cf9828332bc928ceafffdb69a977] | committer: npzacs
aacs: support retrieving content certificate information
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=aba38316a036cf9828332bc928ceafffdb69a977
---
src/libbluray/bdj/java/org/videolan/Libbluray.java | 3 +++
src/libbluray/bdj/native/org_videolan_Libbluray.c | 15 ++++++++++++--
src/libbluray/disc/aacs.c | 21 ++++++++++++++++++++
src/libbluray/disc/aacs.h | 2 ++
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index d74edc4..2ab68a4 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -658,6 +658,9 @@ public class Libbluray {
public static final int AACS_MEDIA_PMSN = 3;
public static final int AACS_DEVICE_BINDING_ID = 4;
public static final int AACS_DEVICE_NONCE = 5;
+ public static final int AACS_MEDIA_KEY = 6;
+ public static final int AACS_CONTENT_CERT_ID = 7;
+ public static final int AACS_BDJ_ROOT_CERT_HASH= 8;
private static native byte[] getAacsDataN(long np, int type);
private static native TitleInfo[] getTitleInfosN(long np);
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.c b/src/libbluray/bdj/native/org_videolan_Libbluray.c
index c940ec5..980ebf5 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -193,14 +193,25 @@ JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getAacsDataN
{
BLURAY* bd = (BLURAY*)(intptr_t)np;
const uint8_t *data = bd_get_aacs_data(bd, type);
+ size_t data_size = 16;
BD_DEBUG(DBG_JNI, "getAacsDataN(%d) -> %p\n", (int)type, (const void *)data);
if (!data) {
return NULL;
}
- jbyteArray array = (*env)->NewByteArray(env, 16);
- (*env)->SetByteArrayRegion(env, array, 0, 16, (const jbyte *)data);
+ if (type == 1/*BD_AACS_DISC_ID*/) {
+ data_size = 20;
+ }
+ if (type == 7/*BD_AACS_CONTENT_CERT_ID*/) {
+ data_size = 6;
+ }
+ if (type == 8/*BD_AACS_BDJ_ROOT_CERT_HASH*/) {
+ data_size = 20;
+ }
+
+ jbyteArray array = (*env)->NewByteArray(env, data_size);
+ (*env)->SetByteArrayRegion(env, array, 0, data_size, (const jbyte *)data);
return array;
}
diff --git a/src/libbluray/disc/aacs.c b/src/libbluray/disc/aacs.c
index 13860cd..cf44f06 100644
--- a/src/libbluray/disc/aacs.c
+++ b/src/libbluray/disc/aacs.c
@@ -340,6 +340,19 @@ int libaacs_get_bec_enabled(BD_AACS *p)
return get_bec(p->aacs) == 3;
}
+static const uint8_t *_get_data(BD_AACS *p, const char *func)
+{
+ fptr_p_void fp;
+
+ *(void **)(&fp) = dl_dlsym(p->h_libaacs, func);
+ if (!fp) {
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "%s() dlsym failed!\n", func);
+ return NULL;
+ }
+
+ return (const uint8_t*)fp(p->aacs);
+}
+
static const char *_type2str(int type)
{
switch (type) {
@@ -349,6 +362,8 @@ static const char *_type2str(int type)
case BD_AACS_DEVICE_BINDING_ID: return "DEVICE_BINDING_ID";
case BD_AACS_DEVICE_NONCE: return "DEVICE_NONCE";
case BD_AACS_MEDIA_KEY: return "MEDIA_KEY";
+ case BD_AACS_CONTENT_CERT_ID: return "CONTENT_CERT_ID";
+ case BD_AACS_BDJ_ROOT_CERT_HASH: return "BDJ_ROOT_CERT_HASH";
default: return "???";
}
}
@@ -378,6 +393,12 @@ BD_PRIVATE const uint8_t *libaacs_get_aacs_data(BD_AACS *p, int type)
case BD_AACS_MEDIA_KEY:
return _get_media_key(p);
+
+ case BD_AACS_CONTENT_CERT_ID:
+ return _get_data(p, "aacs_get_content_cert_id");
+
+ case BD_AACS_BDJ_ROOT_CERT_HASH:
+ return _get_data(p, "aacs_get_bdj_root_cert_hash");
}
BD_DEBUG(DBG_BLURAY | DBG_CRIT, "get_aacs_data(): unknown query %d\n", type);
diff --git a/src/libbluray/disc/aacs.h b/src/libbluray/disc/aacs.h
index 7380a5c..58dd6c6 100644
--- a/src/libbluray/disc/aacs.h
+++ b/src/libbluray/disc/aacs.h
@@ -47,6 +47,8 @@ BD_PRIVATE int libaacs_get_bec_enabled(BD_AACS *p);
#define BD_AACS_DEVICE_BINDING_ID 4
#define BD_AACS_DEVICE_NONCE 5
#define BD_AACS_MEDIA_KEY 6
+#define BD_AACS_CONTENT_CERT_ID 7
+#define BD_AACS_BDJ_ROOT_CERT_HASH 8
BD_PRIVATE const uint8_t *libaacs_get_aacs_data(BD_AACS *p, int type);
More information about the libbluray-devel
mailing list