Mercurial > mplayer.hg
comparison libmpdvdkit2/css.c @ 8637:0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
patch by Andreas Hess <jaska@gmx.net>
author | arpi |
---|---|
date | Sun, 29 Dec 2002 15:32:56 +0000 |
parents | 9fc45fe0d444 |
children | f0f0f176d298 |
comparison
equal
deleted
inserted
replaced
8636:db4a1b1254cb | 8637:0211de3039eb |
---|---|
39 #include <stdlib.h> | 39 #include <stdlib.h> |
40 #include <string.h> | 40 #include <string.h> |
41 #include <sys/types.h> | 41 #include <sys/types.h> |
42 #include <sys/stat.h> | 42 #include <sys/stat.h> |
43 #include <fcntl.h> | 43 #include <fcntl.h> |
44 #include <unistd.h> | |
44 | 45 |
45 #include "dvdcss.h" | 46 #include "dvdcss.h" |
46 | 47 |
47 #include "common.h" | 48 #include "common.h" |
48 #include "css.h" | 49 #include "css.h" |
79 { | 80 { |
80 int i_ret, i_copyright; | 81 int i_ret, i_copyright; |
81 | 82 |
82 i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright ); | 83 i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright ); |
83 | 84 |
85 #ifdef WIN32 | |
86 if( i_ret < 0 ) | |
87 { | |
88 /* Maybe we didn't have enough priviledges to read the copyright | |
89 * (see ioctl_ReadCopyright comments). | |
90 * Apparently, on unencrypted DVDs _dvdcss_disckey() always fails, so | |
91 * we can check this as a work-around. */ | |
92 i_ret = 0; | |
93 if( _dvdcss_disckey( dvdcss ) < 0 ) | |
94 i_copyright = 0; | |
95 else | |
96 i_copyright = 1; | |
97 } | |
98 #endif | |
99 | |
84 if( i_ret < 0 ) | 100 if( i_ret < 0 ) |
85 { | 101 { |
86 /* Since it's the first ioctl we try to issue, we add a notice */ | 102 /* Since it's the first ioctl we try to issue, we add a notice */ |
87 _dvdcss_error( dvdcss, "css error: ioctl_ReadCopyright failed, " | 103 _dvdcss_error( dvdcss, "css error: ioctl_ReadCopyright failed, " |
88 "make sure there is a DVD in the drive, and that " | 104 "make sure there is a DVD in the drive, and that " |
89 "you have used the correct device node." | 105 "you have used the correct device node." ); |
90 #if defined( WIN32 ) | |
91 "\nAlso note that if you are using Windows NT/2000/XP " | |
92 "you need to have administrator priviledges to be able " | |
93 "to use ioctls." | |
94 #endif | |
95 ); | |
96 | 106 |
97 return i_ret; | 107 return i_ret; |
98 } | 108 } |
99 | 109 |
100 return i_copyright; | 110 return i_copyright; |
262 } | 272 } |
263 | 273 |
264 /***************************************************************************** | 274 /***************************************************************************** |
265 * _dvdcss_title: crack or decrypt the current title key if needed | 275 * _dvdcss_title: crack or decrypt the current title key if needed |
266 ***************************************************************************** | 276 ***************************************************************************** |
267 * This function should only be called by dvdcss_seek and should eventually | 277 * This function should only be called by dvdcss->pf_seek and should eventually |
268 * not be external if possible. | 278 * not be external if possible. |
269 *****************************************************************************/ | 279 *****************************************************************************/ |
270 int _dvdcss_title ( dvdcss_t dvdcss, int i_block ) | 280 int _dvdcss_title ( dvdcss_t dvdcss, int i_block ) |
271 { | 281 { |
272 dvd_title_t *p_title; | 282 dvd_title_t *p_title; |
425 { | 435 { |
426 PrintKey( dvdcss, "decrypted disc key is ", p_disc_key ); | 436 PrintKey( dvdcss, "decrypted disc key is ", p_disc_key ); |
427 break; | 437 break; |
428 } | 438 } |
429 _dvdcss_debug( dvdcss, "failed to decrypt the disc key, " | 439 _dvdcss_debug( dvdcss, "failed to decrypt the disc key, " |
430 "trying to crack it instead" ); | 440 "faulty drive/kernel? " |
431 | 441 "cracking title keys instead" ); |
432 /* Fallback */ | 442 |
443 /* Fallback, but not to DISC as the disc key might be faulty */ | |
444 dvdcss->i_method = DVDCSS_METHOD_TITLE; | |
445 break; | |
433 | 446 |
434 case DVDCSS_METHOD_DISC: | 447 case DVDCSS_METHOD_DISC: |
435 | 448 |
436 /* Crack Disc key to be able to use it */ | 449 /* Crack Disc key to be able to use it */ |
437 _dvdcss_debug( dvdcss, "cracking disc key from key hash ..." | 450 _dvdcss_debug( dvdcss, "cracking disc key from key hash ..." |
441 { | 454 { |
442 PrintKey( dvdcss, "cracked disc key is ", p_disc_key ); | 455 PrintKey( dvdcss, "cracked disc key is ", p_disc_key ); |
443 break; | 456 break; |
444 } | 457 } |
445 _dvdcss_debug( dvdcss, "failed to crack the disc key" ); | 458 _dvdcss_debug( dvdcss, "failed to crack the disc key" ); |
459 memset( p_disc_key, 0, KEY_SIZE ); | |
446 dvdcss->i_method = DVDCSS_METHOD_TITLE; | 460 dvdcss->i_method = DVDCSS_METHOD_TITLE; |
447 break; | 461 break; |
448 | 462 |
449 default: | 463 default: |
450 | 464 |
549 | 563 |
550 /* The title key request failed */ | 564 /* The title key request failed */ |
551 _dvdcss_debug( dvdcss, "resetting drive and cracking title key" ); | 565 _dvdcss_debug( dvdcss, "resetting drive and cracking title key" ); |
552 | 566 |
553 /* Read an unscrambled sector and reset the drive */ | 567 /* Read an unscrambled sector and reset the drive */ |
554 _dvdcss_seek( dvdcss, 0 ); | 568 dvdcss->pf_seek( dvdcss, 0 ); |
555 _dvdcss_read( dvdcss, p_garbage, 1 ); | 569 dvdcss->pf_read( dvdcss, p_garbage, 1 ); |
556 _dvdcss_seek( dvdcss, 0 ); | 570 dvdcss->pf_seek( dvdcss, 0 ); |
557 _dvdcss_disckey( dvdcss ); | 571 _dvdcss_disckey( dvdcss ); |
558 | 572 |
559 /* Fallback */ | 573 /* Fallback */ |
560 } | 574 } |
561 | 575 |
976 * 'disc key' encrypted with it self. Using this we | 990 * 'disc key' encrypted with it self. Using this we |
977 * can check if we decrypted the correct key. */ | 991 * can check if we decrypted the correct key. */ |
978 DecryptKey( 0, p_disc_key, p_struct_disckey, p_verify ); | 992 DecryptKey( 0, p_disc_key, p_struct_disckey, p_verify ); |
979 | 993 |
980 /* If the position / player key pair worked then return. */ | 994 /* If the position / player key pair worked then return. */ |
981 if( memcmp( p_disc_key, p_verify, 5 ) == 0 ) | 995 if( memcmp( p_disc_key, p_verify, KEY_SIZE ) == 0 ) |
982 { | 996 { |
983 return 0; | 997 return 0; |
984 } | 998 } |
985 } | 999 } |
986 n++; | 1000 n++; |
987 } | 1001 } |
988 | 1002 |
989 /* Have tried all combinations of positions and keys, | 1003 /* Have tried all combinations of positions and keys, |
990 * and we still didn't succeed. */ | 1004 * and we still didn't succeed. */ |
1005 memset( p_disc_key, 0, KEY_SIZE ); | |
991 return -1; | 1006 return -1; |
992 } | 1007 } |
993 | 1008 |
994 /***************************************************************************** | 1009 /***************************************************************************** |
995 * DecryptTitleKey | 1010 * DecryptTitleKey |
1381 i_tries = 0; | 1396 i_tries = 0; |
1382 i_success = 0; | 1397 i_success = 0; |
1383 | 1398 |
1384 do | 1399 do |
1385 { | 1400 { |
1386 i_ret = _dvdcss_seek( dvdcss, i_pos ); | 1401 i_ret = dvdcss->pf_seek( dvdcss, i_pos ); |
1387 | 1402 |
1388 if( i_ret != i_pos ) | 1403 if( i_ret != i_pos ) |
1389 { | 1404 { |
1390 _dvdcss_error( dvdcss, "seek failed" ); | 1405 _dvdcss_error( dvdcss, "seek failed" ); |
1391 } | 1406 } |