Commit 37f33561 authored by gates's avatar gates
Browse files

Make libaacs it's own standalone library.

Leaving in source tree for now.
parent 255800f2
......@@ -51,42 +51,24 @@ elif [[ $use_dlopen = "yes" ]]; then
AC_DEFINE([USING_DLOPEN], [1], ["Define to 1 if using dlopen"])],
[AC_MSG_ERROR($library_not_found)])
else
AC_CHECK_LIB([aacs], [aacs_open],,
[AC_MSG_ERROR($library_not_found)])
AC_MSG_NOTICE($using_normal_linking)
fi
AM_CONDITIONAL([USING_DLOPEN],
[test $use_dlopen = "auto" || test $use_dlopen = "yes"])
# libaacs checks
if [[ -d src/libaacs ]]; then
# libbdplus checks
if [[ -d src/libbdplus ]]; then
PKG_CHECK_MODULES([OPENSSL], [openssl],
[OPENSSL_INCLUDES="$INCLUDES $OPENSSL_CFLAGS";
OPENSSL_LDFLAGS="$LIBS $OPENSSL_LIBS"],
OPENSSL_LDFLAGS="$LIBS $OPENSSL_LIBS"],
AC_MSG_ERROR($library_not_found))
# Make sure OpenSSL is cool enough to play with the big boys.
AC_CHECK_HEADERS([openssl/ecdsa.h], [], [
AC_MSG_ERROR([Version of OpenSSL does not feature openssl/ecdsa.h, please
upgrade]) ]
, [])
libaacs_src_available=1
else
libaacs_src_available=0
fi
AM_CONDITIONAL([HAVE_LIBAACS_SRC], [test $libaacs_src_available = "1"])
# libbdplus checks
if [[ -d src/libbdplus ]]; then
# Don't check openssl again if already checked before
if [[ libaacs_src_available != "1" ]]; then
PKG_CHECK_MODULES([OPENSSL], [openssl],
[OPENSSL_INCLUDES="$INCLUDES $OPENSSL_CFLAGS";
OPENSSL_LDFLAGS="$LIBS $OPENSSL_LIBS"],
AC_MSG_ERROR($library_not_found))
# Make sure OpenSSL is cool enough to play with the big boys.
AC_CHECK_HEADERS([openssl/ecdsa.h], [], [
AC_MSG_ERROR([Version of OpenSSL does not feature openssl/ecdsa.h, please
upgrade]) ]
, [])
fi
libbdplus_src_available=1
else
libbdplus_src_available=0
......
......@@ -4,15 +4,6 @@ AM_CFLAGS = -I$(top_builddir)/src
lib_LTLIBRARIES=
if HAVE_LIBAACS_SRC
LIBAACS_LIBADD = libaacs.la
lib_LTLIBRARIES += $(LIBAACS_LIBADD)
libaacs_la_SOURCES=libaacs/aacs.c libaacs/crypto.c libaacs/mkb.c libaacs/mmc.c \
file/configfile.c file/file_posix.c util/logging.c
libaacs_la_CFLAGS=@OPENSSL_INCLUDES@
libaacs_la_LDFLAGS=@OPENSSL_LDFLAGS@
endif
if HAVE_LIBBDPLUS_SRC
LIBBDPLUS_LIBADD = libbdplus.la
lib_LTLIBRARIES += $(LIBBDPLUS_LIBADD)
......@@ -29,7 +20,7 @@ endif
if USING_DLOPEN
LIBBLURAY_LDFLAGS=@DLOPEN_LDFLAGS@
else
LIBBLURAY_LIBADD=$(LIBAACS_LIBADD) $(LIBBDPLUS_LIBADD)
LIBBLURAY_LIBADD=$(LIBBDPLUS_LIBADD)
endif
lib_LTLIBRARIES+=libbluray.la
......
SUBDIRS=src
ACLOCAL_AMFLAGS=-I m4
#!/bin/sh
autoreconf -vif
# initilization
AC_INIT([libaacs],[0.1.0], [http://bd.videolan.org/])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER(config.h)
# messages
library_not_found="Could not find required library!"
function_not_found="Could not find required function!"
# required programs
AC_PROG_CC
AC_PROG_LIBTOOL
# required types
AC_TYPE_SIGNAL
# required headers
AC_CHECK_HEADERS([stdarg.h sys/types.h dirent.h errno.h libgen.h malloc.h])
AC_CHECK_HEADERS([stdlib.h mntent.h linux/cdrom.h inttypes.h])
AC_CHECK_HEADERS([sys/time.h time.h])
# required structures
AC_STRUCT_DIRENT_D_TYPE
# required system services
AC_SYS_LARGEFILE
# required functions
AC_CHECK_FUNC([snprintf],, [AC_MSG_ERROR($function_not_found)])
# openssl check
PKG_CHECK_MODULES([OPENSSL], [openssl],
[INCLUDES="$INCLUDES $OPENSSL_CFLAGS";
LIBS="$LIBS $OPENSSL_LIBS"],
AC_MSG_ERROR($library_not_found))
# Make sure OpenSSL is cool enough to play with the big boys.
AC_CHECK_HEADERS([openssl/ecdsa.h], [], [
AC_MSG_ERROR([Version of OpenSSL does not feature openssl/ecdsa.h, please
upgrade]) ]
, [])
# generate output files
AC_CONFIG_FILES([Makefile src/Makefile src/libaacs.pc])
AC_OUTPUT
Please do not remove this file.
It is used to help those using other VCS's like git and hg.
AM_CFLAGS = -I$(top_srcdir)
lib_LTLIBRARIES = libaacs.la
libaacs_la_SOURCES=libaacs/aacs.c libaacs/crypto.c libaacs/mkb.c libaacs/mmc.c \
file/configfile.c file/file_posix.c util/logging.c
libaacs_ladir= $(includedir)/libaacs
libaacs_la_HEADERS= libaacs/aacs.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libaacs.pc
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "configfile.h"
#include "file.h"
#include "../util/macro.h"
#include "../util/logging.h"
uint8_t *configfile_record(CONFIGFILE *kf, enum configfile_types type, uint16_t *entries, size_t *entry_len)
{
size_t pos = 0, len = 0;
if (entries) {
*entries = 0;
}
while (pos + 4 <= kf->size) {
len = MKINT_BE24(kf->buf + pos + 1);
if (entries) {
*entries = MKINT_BE16(kf->buf + pos + 4);
}
if (entry_len) {
*entry_len = MKINT_BE32(kf->buf + pos + 6);
}
if (kf->buf[pos] == type) {
DEBUG(DBG_CONFIGFILE, "Retrieved CONFIGFILE record 0x%02x (%p)\n", type, kf->buf + pos + 10);
return kf->buf + pos + 10; // only return ptr to first byte of entry
}
pos += len;
}
return NULL;
}
CONFIGFILE *configfile_open(const char *path)
{
FILE_H *fp = NULL;
CONFIGFILE *kf = malloc(sizeof(CONFIGFILE));
DEBUG(DBG_CONFIGFILE, "Opening configfile %s... (%p)\n", path, kf);
if ((fp = file_open(path, "rb"))) {
file_seek(fp, 0, SEEK_END);
kf->size = file_tell(fp);
file_seek(fp, 0, SEEK_SET);
kf->buf = malloc(kf->size);
file_read(fp, kf->buf, kf->size);
file_close(fp);
return kf;
}
return NULL;
}
void configfile_close(CONFIGFILE *kf)
{
DEBUG(DBG_CONFIGFILE, "configfile closed (%p)\n", kf);
X_FREE(kf->buf);
X_FREE(kf);
}
#ifndef CONFIGFILE_H_
#define CONFIGFILE_H_
#include <stdint.h>
#include <unistd.h>
typedef struct configfile CONFIGFILE;
struct configfile {
size_t size;
uint8_t *buf;
};
enum configfile_types {
KF_DK_ARRAY = 0x01,
KF_PK_ARRAY,
KF_HOST_PRIV_KEY,
KF_HOST_CERT,
KF_HOST_NONCE,
KF_HOST_KEY_POINT,
KF_VUK_ARRAY
};
CONFIGFILE *configfile_open(const char *path);
void configfile_close(CONFIGFILE *kf);
uint8_t *configfile_record(CONFIGFILE *kf, enum configfile_types type, uint16_t *entries, size_t *entry_len);
/* Keys are stored in a binary file in a record format which is queried from this code
*
* Record format:
* 0 | type
* 1-3 | length
* 4-5 | num entries
* 6-9 | entry length
* 10-(9+entry_length) | entry 1
* .
* .
* length-1 | end
*
*/
#endif /* CONFIGFILE_H_ */
#ifndef FILE_H_
#define FILE_H_
#include <stdint.h>
#include <unistd.h>
//#ifdef __LINUX__
#define file_open file_open_linux
#define DIR_SEP "/"
//#endif
#define file_close(X) X->close(X)
#define file_seek(X,Y,Z) X->seek(X,Y,Z)
#define file_tell(X) X->tell(X)
#define file_eof(X) X->eof(X)
#define file_read(X,Y,Z) X->read(X,Y,Z)
#define file_write(X,Y,Z) X->write(X,Y,Z)
typedef struct file FILE_H;
struct file
{
void* internal;
void (*close)(FILE_H *file);
int64_t (*seek)(FILE_H *file, int64_t offset, int32_t origin);
int64_t (*tell)(FILE_H *file);
int (*eof)(FILE_H *file);
int (*read)(FILE_H *file, uint8_t *buf, int64_t size);
int (*write)(FILE_H *file, uint8_t *buf, int64_t size);
};
extern FILE_H *file_open_linux(const char* filename, const char *mode);
#endif /* FILE_H_ */
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <stdio.h>
#include "file.h"
#include "../util/macro.h"
#include "../util/logging.h"
FILE_H *file_open_linux(const char* filename, const char *mode);
void file_close_linux(FILE_H *file);
int64_t file_seek_linux(FILE_H *file, int64_t offset, int32_t origin);
int64_t file_tell_linux(FILE_H *file);
int file_eof_linux(FILE_H *file);
int file_read_linux(FILE_H *file, uint8_t *buf, int64_t size);
int file_write_linux(FILE_H *file, uint8_t *buf, int64_t size);
void file_close_linux(FILE_H *file)
{
if (file) {
fclose((FILE *)file->internal);
DEBUG(DBG_FILE, "Closed LINUX file (%p)\n", file);
X_FREE(file);
}
}
int64_t file_seek_linux(FILE_H *file, int64_t offset, int32_t origin)
{
return fseeko((FILE *)file->internal, offset, origin);
}
int64_t file_tell_linux(FILE_H *file)
{
return ftello((FILE *)file->internal);
}
int file_eof_linux(FILE_H *file)
{
return feof((FILE *)file->internal);
}
int file_read_linux(FILE_H *file, uint8_t *buf, int64_t size)
{
return fread(buf, 1, size, (FILE *)file->internal);
}
int file_write_linux(FILE_H *file, uint8_t *buf, int64_t size)
{
return fwrite(buf, 1, size, (FILE *)file->internal);
}
FILE_H *file_open_linux(const char* filename, const char *mode)
{
FILE *fp = NULL;
FILE_H *file = malloc(sizeof(FILE_H));
DEBUG(DBG_FILE, "Opening LINUX file %s... (%p)\n", filename, file);
file->close = file_close_linux;
file->seek = file_seek_linux;
file->read = file_read_linux;
file->write = file_write_linux;
file->tell = file_tell_linux;
file->eof = file_eof_linux;
if ((fp = fopen(filename, mode))) {
file->internal = fp;
return file;
}
DEBUG(DBG_FILE, "Error opening file! (%p)\n", file);
X_FREE(file);
return NULL;
}
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libaacs
Description: AACS decryption support library for Blu-ray playback
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -laacs
Cflags: -I${includedir}
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