Commit 32e82c69 authored by Stéphane Borel's avatar Stéphane Borel

*Some cleaning in the dvd authentification code

Now it generates a valid title key, but there is no sector descrambler
yet.
parent 7b3ed3ad
This diff is collapsed.
...@@ -21,21 +21,24 @@ ...@@ -21,21 +21,24 @@
*****************************************************************************/ *****************************************************************************/
#define KEY_SIZE 5 #define KEY_SIZE 5
typedef unsigned char DVD40bitKey[KEY_SIZE]; typedef u8 DVD_key_t[KEY_SIZE];
typedef struct drive_key_s typedef struct disc_s
{ {
u8 pi_challenge[2*KEY_SIZE]; u8 pi_challenge[2*KEY_SIZE];
u8 pi_key1[KEY_SIZE]; u8 pi_key1[KEY_SIZE];
u8 pi_key2[KEY_SIZE]; u8 pi_key2[KEY_SIZE];
u8 pi_key_check[KEY_SIZE]; u8 pi_key_check[KEY_SIZE];
u8 i_version; u8 i_varient;
} drive_key_t; } disc_t;
typedef struct title_key_s typedef struct title_key_s
{ {
u32 i_lba; u32 i; /* This signification of this parameter
u8 key[KEY_SIZE]; depends on the function it is called from :
*from DVDInit -> i == i_lba
*from CSSGetKeys -> i == i_occ */
DVD_key_t key;
} title_key_t; } title_key_t;
typedef struct css_s typedef struct css_s
...@@ -43,7 +46,7 @@ typedef struct css_s ...@@ -43,7 +46,7 @@ typedef struct css_s
int i_fd; int i_fd;
boolean_t b_error; boolean_t b_error;
int i_agid; int i_agid;
drive_key_t keys; disc_t disc;
u8 pi_disc_key[2048]; u8 pi_disc_key[2048];
int i_title_nb; int i_title_nb;
title_key_t* p_title_key; title_key_t* p_title_key;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_dvd.c: DVD reading * input_dvd.c: DVD reading
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.4 2001/01/20 20:59:44 stef Exp $ * $Id: input_dvd.c,v 1.5 2001/01/21 09:20:27 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -114,6 +114,7 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -114,6 +114,7 @@ static void DVDInit( input_thread_t * p_input )
{ {
thread_dvd_data_t * p_method; thread_dvd_data_t * p_method;
off64_t i_start; off64_t i_start;
int i;
if( (p_method = malloc( sizeof(thread_dvd_data_t) )) == NULL ) if( (p_method = malloc( sizeof(thread_dvd_data_t) )) == NULL )
{ {
...@@ -140,21 +141,24 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -140,21 +141,24 @@ static void DVDInit( input_thread_t * p_input )
fprintf(stderr, " CSS Init start\n" ); fprintf(stderr, " CSS Init start\n" );
p_method->css = CSSInit( p_input->i_handle ); p_method->css = CSSInit( p_input->i_handle );
fprintf(stderr, " CSS Init end\n" ); fprintf(stderr, " CSS Init end\n" );
p_method->css.i_title_nb = 1/*p_method->ifo.vmg.ptt_srpt.i_nb*/; p_method->css.i_title_nb = p_method->ifo.vmg.mat.i_tts_nb;
#if 0 if( (p_method->css.p_title_key =
if( (p_title_key = malloc( p_method->css.i_title_nb *
malloc( p_method->css.i_title_nb *sizeof(title_key_t) )) == NULL ) sizeof(p_method->css.p_title_key) ) ) == NULL )
{ {
intf_ErrMsg( "Out of memory" ); intf_ErrMsg( "Out of memory" );
p_input->b_error = 1; p_input->b_error = 1;
return; return;
} }
#endif for( i=0 ; i<p_method->css.i_title_nb ; i++ )
{
p_method->css.p_title_key[i].i =
p_method->ifo.p_vts[i].i_pos +
p_method->ifo.p_vts[i].mat.i_tt_vobs_ssector *DVD_LB_SIZE;
}
fprintf(stderr, " CSS Get start\n" ); fprintf(stderr, " CSS Get start\n" );
CSSGetKeys( &(p_method->css) ); CSSGetKeys( &(p_method->css) );
fprintf(stderr, " CSS Get end\n" ); fprintf(stderr, " CSS Get end\n" );
} }
i_start = p_method->ifo.p_vts[0].i_pos + i_start = p_method->ifo.p_vts[0].i_pos +
...@@ -162,6 +166,7 @@ fprintf(stderr, " CSS Get end\n" ); ...@@ -162,6 +166,7 @@ fprintf(stderr, " CSS Get end\n" );
i_start = lseek64( p_input->i_handle, i_start, SEEK_SET ); i_start = lseek64( p_input->i_handle, i_start, SEEK_SET );
fprintf(stderr, "Begin at : %lld\n", (long long)i_start ); fprintf(stderr, "Begin at : %lld\n", (long long)i_start );
#if 1 #if 1
input_InitStream( p_input, sizeof( stream_ps_data_t ) ); input_InitStream( p_input, sizeof( stream_ps_data_t ) );
input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) ); input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) );
...@@ -308,7 +313,16 @@ static __inline__ int SafeRead( input_thread_t * p_input, byte_t * p_buffer, ...@@ -308,7 +313,16 @@ static __inline__ int SafeRead( input_thread_t * p_input, byte_t * p_buffer,
int i_nb; int i_nb;
p_method = (thread_dvd_data_t *)p_input->p_plugin_data; p_method = (thread_dvd_data_t *)p_input->p_plugin_data;
// if( !p_method->b_encrypted )
// {
i_nb = read( p_input->i_handle, p_buffer, i_len ); i_nb = read( p_input->i_handle, p_buffer, i_len );
#if 0
}
else
{
i_nb = read( p_input->i_handle, p_buffer, 4096 );
CSSDescrambleSector( p_method->css.p_title_key.key, p_buffer );
}
switch( i_nb ) switch( i_nb )
{ {
case 0: case 0:
...@@ -320,14 +334,10 @@ static __inline__ int SafeRead( input_thread_t * p_input, byte_t * p_buffer, ...@@ -320,14 +334,10 @@ static __inline__ int SafeRead( input_thread_t * p_input, byte_t * p_buffer,
default: default:
break; break;
} }
#if 0
if( p_method->b_encrypted )
{
CSSDescrambleSector( p_method->css.p_title_key.key, p_buffer );
}
#endif #endif
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_tell += i_nb; p_input->stream.i_tell += i_nb; //lseek64( p_input->i_handle,
// p_input->stream.i_tell+i_len, SEEK_SET );
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
return( 0 ); return( 0 );
} }
......
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