/*****************************************************************************
* css.c: Functions for DVD authentication and descrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id$
*
* Author: Stéphane Borel <stef@via.ecp.fr>
* Håkan Hjort <d95hjort@dtek.chalmers.se>
*
* based on:
* - css-auth by Derek Fawcus <derek@spider.com>
* - DVD CSS ioctls example program by Andrew T. Veliath <andrewtv@usa.net>
* - The Divide and conquer attack by Frank A. Stevenson <frank@funcom.com>
* - DeCSSPlus by Ethan Hawke
* - DecVOB
* see http://www.lemuria.org/DeCSS/ by Tom Vogt for more information.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "dvdcss.h"
#include "common.h"
#include "css.h"
#include "libdvdcss.h"
#include "csstables.h"
#include "ioctl.h"
#include "device.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int GetBusKey ( dvdcss_t );
static int GetASF ( dvdcss_t );
static void CryptKey ( int, int, u8 const *, u8 * );
static void DecryptKey ( u8, u8 const *, u8 const *, u8 * );
static int DecryptDiscKey ( u8 const *, dvd_key_t );
static int CrackDiscKey ( dvdcss_t, u8 * );
static void DecryptTitleKey ( dvd_key_t, dvd_key_t );
static int RecoverTitleKey ( int, u8 const *, u8 const *, u8 const *, u8 * );
static int CrackTitleKey ( dvdcss_t, int, int, dvd_key_t );
static int AttackPattern ( u8 const[], int, u8 * );
#if 0
static int AttackPadding ( u8 const[], int, u8 * );
#endif
/*****************************************************************************
* _dvdcss_test: check if the disc is encrypted or not
*****************************************************************************/
int _dvdcss_test( dvdcss_t dvdcss )
{
int i_ret, 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 */
_dvdcss_error( dvdcss, "css error: ioctl_ReadCopyright failed, "
"make sure there is a DVD in the drive, and that "
"you have used the correct device node."
#if defined( WIN32 )
"\nAlso note that if you are using Windows NT/2000/XP "
"you need to have administrator priviledges to be able "
"to use ioctls."
#endif
);
return i_ret;
|