Commit 495436e7 authored by Sam Hocevar's avatar Sam Hocevar

  * Exported the CSS part of the dvd plugin into a library.
parent 106079bc
......@@ -249,6 +249,9 @@ snapshot: Makefile.opts
cp share/$$icon.xpm share/$$icon.png \
/tmp/vlc-${PROGRAM_VERSION}/share/ ; done
# make distclean
(cd /tmp/vlc-${PROGRAM_VERSION} ; ./configure ; make distclean )
# build css-enabled archives
(cd /tmp ; tar cf vlc-${PROGRAM_VERSION}.tar vlc-${PROGRAM_VERSION} ; \
bzip2 -f -9 < vlc-${PROGRAM_VERSION}.tar \
......@@ -348,3 +351,9 @@ builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
$(BUILTIN_OBJ): FORCE
cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:lib/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:%=../../%)
#
# libdvdcss target
#
libdvdcss:
cd extras/libdvdcss && $(MAKE)
......@@ -62,6 +62,7 @@ libdir = @libdir@
LIB_ALSA = @LIB_ALSA@
LIB_BEOS = @LIB_BEOS@
LIB_DARWIN = @LIB_DARWIN@
LIB_DVD = @LIB_DVD@
LIB_ESD = @LIB_ESD@
LIB_GGI = @LIB_GGI@
LIB_GLIDE = @LIB_GLIDE@
......@@ -81,6 +82,7 @@ LIB_YUV = @LIB_YUV@
#
# CFLAGS for special cases
#
CFLAGS_DVD = @CFLAGS_DVD@
CFLAGS_GTK = @CFLAGS_GTK@
CFLAGS_SDL = @CFLAGS_SDL@
CFLAGS_X11 = @CFLAGS_X11@
......
......@@ -3357,21 +3357,23 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
EOF
BUILTINS="${BUILTINS} dvd"
LIB_DVD="${LIB_DVD} -Llib -L../../lib -ldvdcss"
CFLAGS_DVD="${CFLAGS_DVD} -I../../extras/libdvdcss"
for ac_hdr in sys/cdio.h sys/dvdio.h linux/cdrom.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3365: checking for $ac_hdr" >&5
echo "configure:3367: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3370 "configure"
#line 3372 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3375: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3377: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3399,7 +3401,7 @@ done
BSD_DVD_STRUCT=0
cat > conftest.$ac_ext <<EOF
#line 3403 "configure"
#line 3405 "configure"
#include "confdefs.h"
#include <sys/dvdio.h>
EOF
......@@ -3417,7 +3419,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
#line 3421 "configure"
#line 3423 "configure"
#include "confdefs.h"
#include <sys/cdio.h>
EOF
......@@ -3441,7 +3443,7 @@ EOF
fi
cat > conftest.$ac_ext <<EOF
#line 3445 "configure"
#line 3447 "configure"
#include "confdefs.h"
#include <linux/cdrom.h>
EOF
......@@ -3593,7 +3595,7 @@ if test "${enable_esd+set}" = set; then
# Extract the first word of "esd-config", so it can be a program name with args.
set dummy esd-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:3597: checking for $ac_word" >&5
echo "configure:3599: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_ESD_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -3658,17 +3660,17 @@ else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3662: checking for $ac_hdr" >&5
echo "configure:3664: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3667 "configure"
#line 3669 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3672: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3674: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3739,17 +3741,17 @@ if test "${with_sdl+set}" = set; then
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3743: checking for $ac_hdr" >&5
echo "configure:3745: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3748 "configure"
#line 3750 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3753: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3787,17 +3789,17 @@ fi
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3791: checking for $ac_hdr" >&5
echo "configure:3793: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3796 "configure"
#line 3798 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3801: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3803: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3841,17 +3843,17 @@ if test "${with_directx+set}" = set; then
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3845: checking for $ac_hdr" >&5
echo "configure:3847: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3850 "configure"
#line 3852 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3855: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3857: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3889,17 +3891,17 @@ fi
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:3893: checking for $ac_hdr" >&5
echo "configure:3895: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 3898 "configure"
#line 3900 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3903: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3905: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -3999,7 +4001,7 @@ if test x$enable_gtk != xno; then
# Extract the first word of "gtk-config", so it can be a program name with args.
set dummy gtk-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:4003: checking for $ac_word" >&5
echo "configure:4005: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -4059,17 +4061,17 @@ if test x$enable_x11 != xno; then
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:4063: checking for $ac_hdr" >&5
echo "configure:4065: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4068 "configure"
#line 4070 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -4121,17 +4123,17 @@ if test x$enable_xvideo != xno; then
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:4125: checking for $ac_hdr" >&5
echo "configure:4127: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4130 "configure"
#line 4132 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4135: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4137: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -4169,17 +4171,17 @@ if test "${enable_alsa+set}" = set; then
enableval="$enable_alsa"
if test x$enable_alsa = xyes; then ac_safe=`echo "sys/asoundlib.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/asoundlib.h""... $ac_c" 1>&6
echo "configure:4173: checking for sys/asoundlib.h" >&5
echo "configure:4175: checking for sys/asoundlib.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4178 "configure"
#line 4180 "configure"
#include "confdefs.h"
#include <sys/asoundlib.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4185: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -4196,7 +4198,7 @@ fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
echo $ac_n "checking for main in -lasound""... $ac_c" 1>&6
echo "configure:4200: checking for main in -lasound" >&5
echo "configure:4202: checking for main in -lasound" >&5
ac_lib_var=`echo asound'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -4204,14 +4206,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lasound $LIBS"
cat > conftest.$ac_ext <<EOF
#line 4208 "configure"
#line 4210 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
if { (eval echo configure:4215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
......@@ -4284,6 +4286,8 @@ fi
......@@ -4456,6 +4460,7 @@ s%@LIB@%$LIB%g
s%@LIB_ALSA@%$LIB_ALSA%g
s%@LIB_BEOS@%$LIB_BEOS%g
s%@LIB_DARWIN@%$LIB_DARWIN%g
s%@LIB_DVD@%$LIB_DVD%g
s%@LIB_ESD@%$LIB_ESD%g
s%@LIB_GGI@%$LIB_GGI%g
s%@LIB_GLIDE@%$LIB_GLIDE%g
......@@ -4472,6 +4477,7 @@ s%@LIB_X11@%$LIB_X11%g
s%@LIB_XVIDEO@%$LIB_XVIDEO%g
s%@LIB_YUV@%$LIB_YUV%g
s%@CFLAGS_VLC@%$CFLAGS_VLC%g
s%@CFLAGS_DVD@%$CFLAGS_DVD%g
s%@CFLAGS_GTK@%$CFLAGS_GTK%g
s%@CFLAGS_SDL@%$CFLAGS_SDL%g
s%@CFLAGS_X11@%$CFLAGS_X11%g
......@@ -4696,20 +4702,27 @@ test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
echo "
global configuration
--------------------
system : ${SYS}
architecture : ${ARCH}
optimizations : ${OPTIMS}
vlc configuration
-----------------
vlc version : ${VLC_VERSION}
system : ${SYS}
architecture : ${ARCH}
debug mode : ${DEBUG}
statistics : ${STATS}
trace mode : ${TRACE}
optimizations : ${OPTIMS}
CSS decryption : ${CSS}
need builtin getopt : ${GETOPT}
built-in modules :${BUILTINS}
plugin modules :${PLUGINS}
vlc aliases :${ALIASES}
You may now tune Makefile.opts at your convenience."
libdvdcss configuration
-----------------------
CSS decryption : ${CSS}
You may now tune Makefile.opts at your convenience. To build vlc, type
\`make vlc'. To build libdvdcss only, type \`make libdvdcss'."
......@@ -180,6 +180,8 @@ dnl DVD module: check for DVD ioctls
dnl
AC_CHECK_HEADERS(sys/ioctl.h,[
BUILTINS="${BUILTINS} dvd"
LIB_DVD="${LIB_DVD} -Llib -L../../lib -ldvdcss"
CFLAGS_DVD="${CFLAGS_DVD} -I../../extras/libdvdcss"
AC_CHECK_HEADERS(sys/cdio.h sys/dvdio.h linux/cdrom.h)
BSD_DVD_STRUCT=0
dnl
......@@ -592,6 +594,7 @@ AC_SUBST(LIB)
AC_SUBST(LIB_ALSA)
AC_SUBST(LIB_BEOS)
AC_SUBST(LIB_DARWIN)
AC_SUBST(LIB_DVD)
AC_SUBST(LIB_ESD)
AC_SUBST(LIB_GGI)
AC_SUBST(LIB_GLIDE)
......@@ -609,6 +612,7 @@ AC_SUBST(LIB_XVIDEO)
AC_SUBST(LIB_YUV)
AC_SUBST(CFLAGS_VLC)
AC_SUBST(CFLAGS_DVD)
AC_SUBST(CFLAGS_GTK)
AC_SUBST(CFLAGS_SDL)
AC_SUBST(CFLAGS_X11)
......@@ -616,20 +620,27 @@ AC_SUBST(CFLAGS_X11)
AC_OUTPUT([Makefile.opts include/config.h])
echo "
global configuration
--------------------
system : ${SYS}
architecture : ${ARCH}
optimizations : ${OPTIMS}
vlc configuration
-----------------
vlc version : ${VLC_VERSION}
system : ${SYS}
architecture : ${ARCH}
debug mode : ${DEBUG}
statistics : ${STATS}
trace mode : ${TRACE}
optimizations : ${OPTIMS}
CSS decryption : ${CSS}
need builtin getopt : ${GETOPT}
built-in modules :${BUILTINS}
plugin modules :${PLUGINS}
vlc aliases :${ALIASES}
You may now tune Makefile.opts at your convenience."
libdvdcss configuration
-----------------------
CSS decryption : ${CSS}
You may now tune Makefile.opts at your convenience. To build vlc, type
\`make vlc'. To build libdvdcss only, type \`make libdvdcss'."
###############################################################################
# vlc (VideoLAN Client) dvd module Makefile
# (c)2001 VideoLAN
###############################################################################
include ../../Makefile.opts
#
# Objects
#
LIBDVDCSS_O = libdvdcss.o css.o ioctl.o
ALL_OBJ = $(LIBDVDCSS_O)
include ../../Makefile.modules
$(LIBDVDCSS_O): %.o: .dep/%.d
$(LIBDVDCSS_O): %.o: %.c
$(CC) $(CFLAGS) $(PCFLAGS) -c -o $@ $<
../../lib/libdvdcss.so: $(LIBDVDCSS_O)
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS)
../../lib/libdvdcss.a: $(LIBDVDCSS_O)
ar r $@ $^
$(RANLIB) $@
#all: ../../lib/libdvdcss.so ../../lib/libdvdcss.a
all: ../../lib/libdvdcss.a
/*****************************************************************************
* dvd_css.c: Functions for DVD authentification and unscrambling
* css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.c,v 1.33 2001/06/07 22:25:42 sam Exp $
* $Id: css.c,v 1.1 2001/06/12 22:14:44 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -47,27 +47,20 @@
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "intf_msg.h"
#include "videolan/dvdcss.h"
#include "libdvdcss.h"
#include "input_dvd.h"
#include "dvd_css.h"
#ifdef HAVE_CSS
# include "dvd_csstables.h"
# include "csstables.h"
#endif /* HAVE_CSS */
#include "dvd_ioctl.h"
#include "modules.h"
#include "modules_export.h"
#include "ioctl.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
#ifdef HAVE_CSS
static int CSSGetASF ( int i_fd );
static int CSSGetASF ( dvdcss_handle dvdcss );
static void CSSCryptKey ( int i_key_type, int i_varient,
u8 const * pi_challenge, u8* pi_key );
static int CSSCracker ( int i_start, unsigned char * p_crypted,
......@@ -78,17 +71,17 @@ static int CSSCracker ( int i_start, unsigned char * p_crypted,
/*****************************************************************************
* CSSTest : check if the disc is encrypted or not
*****************************************************************************/
int CSSTest( int i_fd )
int CSSTest( dvdcss_handle dvdcss )
{
int i_ret, i_copyright;
i_ret = ioctl_ReadCopyright( i_fd, 0 /* i_layer */, &i_copyright );
i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright );
if( i_ret < 0 )
{
/* Since it's the first ioctl we try to issue, we add a notice */
intf_ErrMsg( "css error: ioctl_ReadCopyright failed, "
"make sure DVD ioctls were compiled in" );
_dvdcss_error( dvdcss, "css error: ioctl_ReadCopyright failed, "
"make sure DVD ioctls were compiled in" );
return i_ret;
}
......@@ -103,35 +96,37 @@ int CSSTest( int i_fd )
* Since we don't need the disc key to find the title key, we just run the
* basic unavoidable commands to authenticate device and disc.
*****************************************************************************/
int CSSInit( int i_fd, css_t * p_css )
int CSSInit( dvdcss_handle dvdcss )
{
#ifdef HAVE_CSS
/* structures defined in cdrom.h or dvdio.h */
char p_buffer[2048 + 4 + 1];
char psz_warning[32];
int i_agid = 0;
int i_ret = -1;
int i;
/* Test authentication success */
switch( CSSGetASF( i_fd ) )
switch( CSSGetASF( dvdcss ) )
{
case -1:
return -1;
case 1:
intf_WarnMsg( 2, "css info: already authenticated" );
_dvdcss_debug( dvdcss, "already authenticated" );
return 0;
case 0:
intf_WarnMsg( 2, "css info: need to authenticate" );
_dvdcss_debug( dvdcss, "need to authenticate" );
}
/* Init sequence, request AGID */
for( i = 1; i < 4 ; ++i )
{
intf_WarnMsg( 2, "css info: requesting AGID %d", i );
sprintf( psz_warning, "requesting AGID %d", i );
_dvdcss_debug( dvdcss, psz_warning );
i_ret = ioctl_ReportAgid( i_fd, &i_agid );
i_ret = ioctl_ReportAgid( dvdcss->i_fd, &i_agid );
if( i_ret != -1 )
{
......@@ -139,108 +134,113 @@ int CSSInit( int i_fd, css_t * p_css )
break;
}
intf_ErrMsg( "css error: ioctl_ReportAgid failed, invalidating" );
_dvdcss_error( dvdcss, "ioctl_ReportAgid failed, invalidating" );
i_agid = 0;
ioctl_InvalidateAgid( i_fd, &i_agid );
ioctl_InvalidateAgid( dvdcss->i_fd, &i_agid );
}
/* Unable to authenticate without AGID */
if( i_ret == -1 )
{
intf_ErrMsg( "css error: ioctl_ReportAgid failed, fatal" );
_dvdcss_error( dvdcss, "ioctl_ReportAgid failed, fatal" );
return -1;
}
for( i = 0 ; i < 10; ++i )
{
p_css->disc.pi_challenge[i] = i;
dvdcss->css.disc.pi_challenge[i] = i;
}
/* Get challenge from host */
for( i = 0 ; i < 10 ; ++i )
{
p_buffer[9-i] = p_css->disc.pi_challenge[i];
p_buffer[9-i] = dvdcss->css.disc.pi_challenge[i];
}
/* Send challenge to LU */
if( ioctl_SendChallenge( i_fd, &i_agid, p_buffer ) < 0 )
if( ioctl_SendChallenge( dvdcss->i_fd, &i_agid, p_buffer ) < 0 )
{
intf_ErrMsg( "css error: ioctl_SendChallenge failed" );
_dvdcss_error( dvdcss, "ioctl_SendChallenge failed" );
return -1;
}
/* Get key1 from LU */
if( ioctl_ReportKey1( i_fd, &i_agid, p_buffer ) < 0)
if( ioctl_ReportKey1( dvdcss->i_fd, &i_agid, p_buffer ) < 0)
{
intf_ErrMsg( "css error: ioctl_ReportKey1 failed" );
_dvdcss_error( dvdcss, "ioctl_ReportKey1 failed" );
return -1;
}
/* Send key1 to host */
for( i = 0 ; i < KEY_SIZE ; i++ )
{
p_css->disc.pi_key1[i] = p_buffer[4-i];
dvdcss->css.disc.pi_key1[i] = p_buffer[4-i];
}
for( i = 0 ; i < 32 ; ++i )
{
CSSCryptKey( 0, i, p_css->disc.pi_challenge,
p_css->disc.pi_key_check );
CSSCryptKey( 0, i, dvdcss->css.disc.pi_challenge,
dvdcss->css.disc.pi_key_check );
if( memcmp( p_css->disc.pi_key_check,
p_css->disc.pi_key1, KEY_SIZE ) == 0 )
if( memcmp( dvdcss->css.disc.pi_key_check,
dvdcss->css.disc.pi_key1, KEY_SIZE ) == 0 )
{
intf_WarnMsg( 2, "css info: drive authentic, using variant %d", i);
p_css->disc.i_varient = i;
sprintf( psz_warning, "drive authentic, using variant %d", i );
_dvdcss_debug( dvdcss, psz_warning );
dvdcss->css.disc.i_varient = i;
break;
}
}
if( i == 32 )
{
intf_ErrMsg( "css error: drive would not authenticate" );
_dvdcss_error( dvdcss, "drive would not authenticate" );
return -1;
}
/* Get challenge from LU */
if( ioctl_ReportChallenge( i_fd, &i_agid, p_buffer ) < 0 )
if( ioctl_ReportChallenge( dvdcss->i_fd, &i_agid, p_buffer ) < 0 )
{
intf_ErrMsg( "css error: ioctl_ReportKeyChallenge failed" );
_dvdcss_error( dvdcss, "ioctl_ReportKeyChallenge failed" );
return -1;
}
/* Send challenge to host */
for( i = 0 ; i < 10 ; ++i )
{
p_css->disc.pi_challenge[i] = p_buffer[9-i];
dvdcss->css.disc.pi_challenge[i] = p_buffer[9-i];
}