Commit 848b3b5b authored by Accident's avatar Accident

Accident: Add checked for gcrypt in autoconf, and add to compile
          Remove spurious called to bdplus from someone.
parent 33f5f7cc
......@@ -77,7 +77,7 @@ AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
ssl_found=no
for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS -lssl -lcrypto -lgcrypt"
LIBS="$saved_LIBS -lssl -lcrypto"
# Skip the directory if it isn't there.
if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
......@@ -207,6 +207,29 @@ AC_CHECK_HEADERS([openssl/ecdsa.h], [], [
, [])
dnl
dnl libgcrypt
dnl
AC_ARG_ENABLE(libgcrypt,
[ --disable-libgcrypt gcrypt support (default enabled)])
AS_IF([test "${enable_libgcrypt}" != "no"], [
libgcrypt-config --version >/dev/null || \
AC_MSG_ERROR([gcrypt.h present but libgcrypt-config could not be found])
AC_CHECK_LIB(gcrypt, gcry_control, [
have_libgcrypt="yes"
GCRYPT_CFLAGS="`libgcrypt-config --cflags`"
GCRYPT_LIBS="`libgcrypt-config --libs`"
], [
AC_MSG_ERROR([libgcrypt not found. Install libgcrypt or use --disable-libgcrypt. Have a nice day.])
], [`libgcrypt-config --libs`])
]
)
AC_SUBST(GCRYPT_CFLAGS)
AC_SUBST(GCRYPT_LIBS)
AM_CONDITIONAL([HAVE_GCRYPT], [test "${have_libgcrypt}" = "yes"])
AM_CONFIG_HEADER(config.h)
# List all Makefiles here.
......
......@@ -23,7 +23,8 @@ BLURAY *bd_open(const char* device_path, const char* keyfile_path)
BLURAY *bd = calloc(1, sizeof(BLURAY));
if (device_path) {
strncpy(bd->device_path, device_path, 100); // <-- FIXME. bufrun,size,term
bd->device_path = strdup(device_path);
bd->aacs = NULL;
bd->h_libaacs = NULL;
......@@ -37,7 +38,7 @@ BLURAY *bd_open(const char* device_path, const char* keyfile_path)
DEBUG(DBG_BLURAY, "Downloaded libaacs (0x%08x)\n", bd->h_libaacs);
fptr_p_void fptr = dl_dlsym(bd->h_libaacs, "aacs_open");
fptr = dl_dlsym(bd->h_libaacs, "aacs_open");
bd->aacs = fptr(device_path, keyfile_path);
} else {
DEBUG(DBG_BLURAY, "libaacs not found!\n");
......@@ -93,7 +94,7 @@ void bd_close(BLURAY *bd)
{
if (bd->h_libaacs && bd->aacs) {
fptr_p_void fptr = dl_dlsym(bd->h_libaacs, "aacs_close");
fptr(bd->aacs);
fptr(bd->aacs); // FIXME: NULL
dl_dlclose(bd->h_libaacs);
}
......@@ -128,11 +129,6 @@ uint64_t bd_seek(BLURAY *bd, uint64_t pos)
file_seek(bd->fp, bd->s_pos, SEEK_SET);
if (bd->h_libbdplus && bd->bdplus) {
fptr_p_void fptr = dlsym(bd->h_libbdplus, "bdplus_seek");
fptr(bd->bdplus, bd->s_pos);
}
bd->int_buf_off = 6144;
DEBUG(DBG_BLURAY, "Seek to %ld (0x%08x)\n", bd->s_pos, bd);
......@@ -156,39 +152,33 @@ int bd_read(BLURAY *bd, unsigned char *buf, int len)
if (bd->int_buf_off == 6144) {
int read_len;
if ((read_len = file_read(bd->fp, buf, len))) {
if (bd->h_libaacs && bd->aacs) {
// FIXME: calling dlsym for every read() call.
if ((bd->libaacs_decrypt_unit = dl_dlsym(bd->h_libaacs, "aacs_decrypt_unit"))) {
if (!bd->libaacs_decrypt_unit(bd->aacs, buf, len, bd->s_pos)) {
DEBUG(DBG_BLURAY, "Unable decrypt unit! (0x%08x)\n", bd);
if ((read_len = file_read(bd->fp, buf, len))) {
if (bd->h_libaacs && bd->aacs) {
// FIXME: calling dlsym for every read() call.
if ((bd->libaacs_decrypt_unit = dl_dlsym(bd->h_libaacs, "aacs_decrypt_unit"))) {
if (!bd->libaacs_decrypt_unit(bd->aacs, buf, len, bd->s_pos)) {
DEBUG(DBG_BLURAY, "Unable decrypt unit! (0x%08x)\n", bd);
return 0;
}
if (bd->h_libbdplus && bd->bdplus) {
fptr_p_void fptr = dlsym(bd->h_libbdplus, "bdplus_fixup");
fptr(bd->bdplus, bd->int_buf, read_len);
}
}
}
}
bd->int_buf_off = 0;
}
if (bd->bdplus_fixup && bd->bdplus)
bd->bdplus_fixup(bd->bdplus, len, buf);
} // decrypt
} // dlsym
} // aacs
bd->int_buf_off = 0;
bd->s_pos += len;
// bdplus fixup, if required.
if (bd->bdplus_fixup && bd->bdplus)
bd->bdplus_fixup(bd->bdplus, len, buf);
bd->s_pos += len;
bd->s_pos += len;
DEBUG(DBG_BLURAY, "%d bytes read OK! (0x%08x)\n", len, bd);
return len;
}
}
DEBUG(DBG_BLURAY, "%d bytes read OK! (0x%08x)\n", len, bd);
return len;
} // read
} // int_buf
} // while
} // s_size
} // if ->fp
DEBUG(DBG_BLURAY, "No valid title selected! (0x%08x)\n", bd->s_pos);
return 0;
......@@ -207,10 +197,6 @@ int bd_select_title(BLURAY *bd, uint32_t title)
if ((bd->fp = file_open(f_name, "rb"))) {
file_seek(bd->fp, 0, SEEK_END);
if ((bd->s_size = file_tell(bd->fp))) {
if (bd->h_libbdplus && bd->bdplus) {
fptr_p_void fptr = dlsym(bd->h_libbdplus, "bdplus_set_title");
fptr(bd->bdplus, title);
}
bd_seek(bd, 0);
......
......@@ -17,7 +17,6 @@ struct bluray {
uint64_t s_size;
uint64_t s_pos;
void *aacs, *bdplus;
void *bdplus; // bdplus container
fptr_p_void bdplus_seek; // frequently called
fptr_p_void bdplus_fixup; // frequently called
void *h_libaacs, *h_libbdplus, *h_libbdnav;
......
......@@ -20,7 +20,7 @@ enum debug_mask_enum {
DBG_DIR = 128,
DBG_NAV = 256,
DBG_BDPLUS = 512,
DBG_DLX = 1024
DBG_DLX = 1024,
DBG_CRIT = 2048 // this is libbluray's default debug mask so use this if you want to display critical info
};
......
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