Commit 22899aa9 authored by Sam Hocevar's avatar Sam Hocevar

libdvdcss changes:

  * Support for REPORT_TITLE_KEY and RPC commands by H�kan Hjort
    <d95hjort@dtek.chalmers.se>.

vlc changes:
  * Minor coding style fixes (please avoid tabs).
parent 14047fa1
......@@ -4,6 +4,8 @@
HEAD
* Support for REPORT_TITLE_KEY and RPC commands by Håkan Hjort
<d95hjort@dtek.chalmers.se>.
* HP-UX port courtesy of David Siebörger <drs-videolan@rucus.ru.ac.za>.
1.0.1
......
......@@ -2,7 +2,7 @@
* ioctl.c: DVD ioctl replacement function
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ioctl.c,v 1.16 2001/12/11 14:43:38 sam Exp $
* $Id: ioctl.c,v 1.17 2001/12/16 18:00:18 sam Exp $
*
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
* Samuel Hocevar <sam@zoy.org>
......@@ -122,6 +122,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.type = DVD_STRUCT_COPYRIGHT;
dvd.copyright.layer_num = i_layer;
......@@ -132,6 +133,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.format = DVD_STRUCT_COPYRIGHT;
dvd.layer_num = i_layer;
......@@ -225,7 +227,7 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
&sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
&tmp, NULL ) ? 0 : -1;
*pi_copyright = p_buffer[4];
*pi_copyright = p_buffer[ 4 ];
}
else
{
......@@ -267,9 +269,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.type = DVD_STRUCT_DISCKEY;
dvd.disckey.agid = *pi_agid;
memset( dvd.disckey.value, 0, 2048 );
memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE );
i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
......@@ -278,14 +281,15 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, dvd.disckey.value, 2048 );
memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_struct dvd;
memset( &dvd, 0, sizeof( dvd ) );
dvd.format = DVD_STRUCT_DISCKEY;
dvd.agid = *pi_agid;
memset( dvd.data, 0, 2048 );
memset( dvd.data, 0, DVD_DISCKEY_SIZE );
i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
......@@ -294,10 +298,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, dvd.data, 2048 );
memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE );
#elif defined( SYS_BEOS )
INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
rdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
rdc.command[ 10 ] = *pi_agid << 6;
......@@ -309,10 +313,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, p_buffer + 4, 2048 );
memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
#elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY;
sctl_io.cdb[ 10 ] = *pi_agid << 6;
......@@ -324,10 +328,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, p_buffer + 4, 2048 );
memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
......@@ -340,7 +344,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, p_buffer + 4, 2048 );
memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
#elif defined( SYS_DARWIN )
dk_dvd_read_structure_t dvd;
......@@ -355,12 +359,12 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
dvd.grantID = *pi_agid;
/* 2048+2 ; maybe we should do bit shifts to value of (sizeof(dvddki)-2) */
dvddki.dataLength[0] = 0x04;
dvddki.dataLength[1] = 0x02;
dvddki.dataLength[ 0 ] = 0x04;
dvddki.dataLength[ 1 ] = 0x02;
i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
memcpy( p_key, dvddki.discKeyStructures, sizeof(dvddki.discKeyStructures) );
memcpy( p_key, dvddki.discKeyStructures, DVD_DISCKEY_SIZE );
#elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */
......@@ -384,11 +388,11 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, key->KeyData, 2048 );
memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE );
}
else
{
INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 2048 + 4 );
INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY;
ssc.CDBByte[ 10 ] = *pi_agid << 6;
......@@ -400,7 +404,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
return i_ret;
}
memcpy( p_key, p_buffer + 4, 2048 );
memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
}
#else
......@@ -419,34 +423,78 @@ int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
int i_ret;
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo dvd_ai;
memset( &dvd_ai, 0, sizeof(dvd_ai) );
dvd_ai.type = DVD_LU_SEND_TITLE_KEY;
dvd_ai.lstk.agid = *pi_agid;
dvd_ai.lstk.lba = i_pos;
dvd_authinfo auth_info;
i_ret = ioctl( i_fd, DVD_AUTH, &dvd_ai );
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_TITLE_KEY;
auth_info.lstk.agid = *pi_agid;
auth_info.lstk.lba = i_pos;
if( i_ret < 0 )
{
return i_ret;
}
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
memcpy( p_key, dvd_ai.lstk.title_key, 5 );
memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT )
i_ret = -1;
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_TITLE_KEY;
auth_info.agid = *pi_agid;
auth_info.lba = i_pos;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
#elif defined( SYS_BEOS )
i_ret = -1;
INIT_RDC( GPCMD_REPORT_KEY, 12 );
rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff;
rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff;
rdc.command[ 5 ] = ( i_pos ) & 0xff;
rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
#elif defined( HPUX_SCTL_IO )
i_ret = -1;
INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff;
sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff;
sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff;
sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff;
sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
#elif defined( SOLARIS_USCSI )
i_ret = -1;
INIT_USCSI( GPCMD_REPORT_KEY, 12 );
rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff;
rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff;
rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff;
rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff;
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = ioctl( i_fd, USCSICMD, &sc );
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
/* Do we want to return the cp_sec flag perhaps? */
/* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */
/* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */
/* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
#elif defined( SYS_DARWIN )
dk_dvd_report_key_t dvd;
DVDTitleKeyInfo dvdtki;
......@@ -461,19 +509,54 @@ int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; /* or this - this is memset 0x00 anyways */
/* dvdtki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdtki.dataLength[1] = 0x0a;
dvdtki.dataLength[ 1 ] = 0x0a;
/* What are DVDTitleKeyInfo.{CP_MOD,CGMS,CP_SEC,CPM} and do they need to be set? */
#warning "Correct title key reading for MacOSX / Darwin!"
/* hh: No that should be part of the result I belive.
* You do need to set the sector/lba/position somehow though! */
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_key, dvdtki.titleKeyValue, sizeof(dvdtki.titleKeyValue) );
memcpy( p_key, dvdtki.titleKeyValue, DVD_KEY_SIZE );
#elif defined( WIN32 )
i_ret = -1;
if( WIN2K ) /* NT/Win2000/Whistler */
{
DWORD tmp;
u8 buffer[DVD_BUS_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
#else
memset( &buffer, 0, sizeof( buffer ) );
key->KeyLength = DVD_BUS_KEY_LENGTH;
key->SessionId = *pi_agid;
key->KeyType = DvdTitleKey;
key->KeyFlags = 0;
key->Parameters.TitleOffset = i_pos; // is this ok?
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
}
else
{
INIT_SSC( GPCMD_REPORT_KEY, 12 );
ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff;
ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff;
ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff;
ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff;
ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
i_ret = WinSendSSC( i_fd, &ssc );
memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
}
#else
/* DVD ioctls unavailable - do as if the ioctl failed */
i_ret = -1;
#endif
......@@ -492,6 +575,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_AGID;
auth_info.lsa.agid = *pi_agid;
......@@ -502,6 +586,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_AGID;
auth_info.agid = *pi_agid;
......@@ -602,22 +687,24 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_CHALLENGE;
auth_info.lsc.agid = *pi_agid;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
memcpy( p_challenge, auth_info.lsc.chal, sizeof(dvd_challenge) );
memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_CHALLENGE;
auth_info.agid = *pi_agid;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
memcpy( p_challenge, auth_info.keychal, 10 );
memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE );
#elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 16 );
......@@ -626,7 +713,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
memcpy( p_challenge, p_buffer + 4, 12 );
memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
#elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 );
......@@ -635,7 +722,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
memcpy( p_challenge, p_buffer + 4, 12 );
memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 16 );
......@@ -649,7 +736,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = -1;
}
memcpy( p_challenge, p_buffer + 4, 12 );
memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
#elif defined( SYS_DARWIN )
dk_dvd_report_key_t dvd;
......@@ -664,11 +751,11 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
dvd.grantID = *pi_agid;
/* dvdcki.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdcki.dataLength[1] = 0x0e;
dvdcki.dataLength[ 1 ] = 0x0e;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_challenge, dvdcki.challengeKeyValue, sizeof(dvdcki.challengeKeyValue) );
memcpy( p_challenge, dvdcki.challengeKeyValue, DVD_CHALLENGE_SIZE );
#elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */
......@@ -692,7 +779,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
return i_ret;
}
memcpy( p_challenge, key->KeyData, 10 );
memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE );
}
else
{
......@@ -702,7 +789,7 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
i_ret = WinSendSSC( i_fd, &ssc );
memcpy( p_challenge, p_buffer + 4, 12 );
memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
}
#else
......@@ -716,15 +803,15 @@ int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
/*****************************************************************************
* ioctl_ReportASF: get ASF from the drive
*****************************************************************************/
int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
{
int i_ret;
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_ASF;
auth_info.lsasf.agid = *pi_agid;
auth_info.lsasf.asf = *pi_asf;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
......@@ -734,8 +821,8 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_ASF;
auth_info.agid = *pi_agid;
auth_info.asf = *pi_asf;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
......@@ -745,7 +832,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 8 );
rdc.command[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
rdc.command[ 10 ] = DVD_REPORT_ASF;
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
......@@ -754,7 +841,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 );
sctl_io.cdb[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
sctl_io.cdb[ 10 ] = DVD_REPORT_ASF;
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
......@@ -763,7 +850,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF;
i_ret = ioctl( i_fd, USCSICMD, &sc );
......@@ -784,11 +871,10 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
dvd.buffer = &dvdasfi;
dvd.bufferLength = sizeof(dvdasfi);
dvd.format = kDVDKeyFormatASF;
dvd.grantID = *pi_agid;
dvdasfi.successFlag = *pi_asf;
/* dvdasfi.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdasfi.dataLength[1] = 0x06;
dvdasfi.dataLength[ 1 ] = 0x06;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
......@@ -804,7 +890,6 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
memset( &buffer, 0, sizeof( buffer ) );
key->KeyLength = DVD_ASF_LENGTH;
key->SessionId = *pi_agid;
key->KeyType = DvdAsf;
key->KeyFlags = 0;
......@@ -824,7 +909,7 @@ int ioctl_ReportASF( int i_fd, int *pi_agid, int *pi_asf )
{
INIT_SSC( GPCMD_REPORT_KEY, 8 );
ssc.CDBByte[ 10 ] = DVD_REPORT_ASF | (*pi_agid << 6);
ssc.CDBByte[ 10 ] = DVD_REPORT_ASF;
i_ret = WinSendSSC( i_fd, &ssc );
......@@ -849,22 +934,24 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_LU_SEND_KEY1;
auth_info.lsk.agid = *pi_agid;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
memcpy( p_key, auth_info.lsk.key, sizeof(dvd_key) );
memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE );
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_REPORT_KEY1;
auth_info.agid = *pi_agid;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
memcpy( p_key, auth_info.keychal, 8 );
memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
#elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 12 );
......@@ -873,7 +960,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
memcpy( p_key, p_buffer + 4, 8 );
memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
#elif defined( HPUX_SCTL_IO )
INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 );
......@@ -882,7 +969,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
memcpy( p_key, p_buffer + 4, 8 );
memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 12 );
......@@ -896,7 +983,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = -1;
}
memcpy( p_key, p_buffer + 4, 8 );;
memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
#elif defined( SYS_DARWIN )
dk_dvd_report_key_t dvd;
......@@ -911,11 +998,11 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
dvd.grantID = *pi_agid;
/* dvdk1i.dataLength[0] = 0x00; */ /* dataLength[0] is already memset to 0 */
dvdk1i.dataLength[1] = 0x0a;
dvdk1i.dataLength[ 1 ] = 0x0a;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_key, dvdk1i.key1Value, sizeof(dvdk1i.key1Value) );
memcpy( p_key, dvdk1i.key1Value, DVD_KEY_SIZE );
#elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */
......@@ -934,7 +1021,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
memcpy( p_key, key->KeyData, 8 );
memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
}
else
{
......@@ -944,7 +1031,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
i_ret = WinSendSSC( i_fd, &ssc );
memcpy( p_key, p_buffer + 4, 8 );
memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
}
#else
......@@ -965,23 +1052,21 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_INVALIDATE_AGID;
auth_info.lsa.agid = *pi_agid;
i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
*pi_agid = auth_info.lsa.agid;
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_INVALIDATE_AGID;
auth_info.agid = *pi_agid;
i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
*pi_agid = auth_info.agid;
#elif defined( SYS_BEOS )
INIT_RDC( GPCMD_REPORT_KEY, 0 );
......@@ -1026,8 +1111,6 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
*pi_agid = dvdagid.grantID;
#elif defined( WIN32 )
if( WIN2K ) /* NT/Win2000/Whistler */
{
......@@ -1071,20 +1154,22 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
#if defined( HAVE_LINUX_DVD_STRUCT )
dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.type = DVD_HOST_SEND_CHALLENGE;
auth_info.hsc.agid = *pi_agid;
memcpy( auth_info.hsc.chal, p_challenge, sizeof(dvd_challenge) );
memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, DVD_AUTH, &auth_info );
#elif defined( HAVE_BSD_DVD_STRUCT )
struct dvd_authinfo auth_info;
memset( &auth_info, 0, sizeof( auth_info ) );
auth_info.format = DVD_SEND_CHALLENGE;
auth_info.agid = *pi_agid;
memcpy( auth_info.keychal, p_challenge, 12 );
memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
......@@ -1094,7 +1179,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 );
memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
......@@ -1104,7 +1189,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 );
memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
return ioctl( i_fd, SIOC_IO, &sctl_io );
......@@ -1114,7 +1199,7 @@ int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, 12 );
memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );