Commit 92253518 authored by Stéphane Borel's avatar Stéphane Borel

*With DVDCSS_METHOD=disc or key, the keys are no longer buffered on start.
The title key is still read at each block but it is checked for change
before decryption.
parent 9cb8a115
......@@ -2,7 +2,7 @@
* css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: css.c,v 1.19 2002/01/04 14:01:34 sam Exp $
* $Id: css.c,v 1.20 2002/01/14 22:06:57 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
* Hkan Hjort <d95hjort@dtek.chalmers.se>
......@@ -475,16 +475,22 @@ int CSSGetTitleKey( dvdcss_handle dvdcss, int i_pos )
_dvdcss_error( dvdcss, "ioctl_ReadTitleKey failed" );
return -1;
}
if( memcmp( p_key, dvdcss->css.p_unenc_key, KEY_SIZE ) )
{
memcpy( dvdcss->css.p_unenc_key, p_key, KEY_SIZE );
/* Unencrypt title key using bus key */
for( i = 0 ; i < KEY_SIZE ; i++ )
{
p_key[ i ] ^= dvdcss->css.disc.p_key_check[ 4 - (i % KEY_SIZE) ];
p_key[ i ] ^= dvdcss->css.disc.p_key_check[ 4 - (i % KEY_SIZE ) ];
}
/* Title key decryption needs one inversion 0xff */
CSSDecryptKey( p_key, dvdcss->css.disc.p_disc_key, 0xff );
memcpy( dvdcss->css.p_title_key, p_key, sizeof(dvd_key_t) );
memcpy( dvdcss->css.p_title_key, p_key, KEY_SIZE );
}
return 0;
} // (dvdcss->i_method == DVDCSS_METHOD_TITLE) || (dvdcss->b_ioctls == 0)
......
......@@ -2,7 +2,7 @@
* css.h: Structures for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: css.h,v 1.6 2001/10/13 15:34:21 stef Exp $
* $Id: css.h,v 1.7 2002/01/14 22:06:57 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -51,7 +51,8 @@ typedef struct css_s
{
int i_agid;
disc_t disc;
dvd_key_t p_title_key;
dvd_key_t p_unenc_key; /* title key before decryption */
dvd_key_t p_title_key; /* title key after decryption */
} css_t;
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* libdvdcss.c: DVD reading library.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: libdvdcss.c,v 1.26 2001/12/30 07:09:54 sam Exp $
* $Id: libdvdcss.c,v 1.27 2002/01/14 22:06:57 stef Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -184,6 +184,8 @@ extern dvdcss_handle dvdcss_open ( char *psz_target )
}
}
memset( dvdcss->css.p_unenc_key, 0, KEY_SIZE );
#ifndef WIN32
if( psz_raw_device != NULL )
{
......@@ -209,8 +211,25 @@ extern int dvdcss_seek ( dvdcss_handle dvdcss, int i_blocks, int i_flags )
{
/* title cracking method is too slow to be used at each seek */
if( ( ( i_flags & DVDCSS_SEEK_MPEG )
&& ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) )
|| ( i_flags & DVDCSS_SEEK_KEY ) )
&& ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) ) )
{
int i_ret;
/* Crack or decrypt CSS title key for current VTS */
i_ret = CSSGetTitleKey( dvdcss, i_blocks );
if( i_ret < 0 )
{
_dvdcss_error( dvdcss, "fatal error in vts css key" );
return i_ret;
}
else if( i_ret > 0 )
{
_dvdcss_error( dvdcss, "decryption unavailable" );
return -1;
}
}
else if( i_flags & DVDCSS_SEEK_KEY )
{
/* check the title key */
if( dvdcss_title( dvdcss, i_blocks ) )
......
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