comparison dvdauth.c @ 546:22ed5f5821e2

command line requested DVD key support for Arpi :)
author lgb
date Fri, 20 Apr 2001 14:32:09 +0000
parents 888a85621f50
children 6fbd39309b87
comparison
equal deleted inserted replaced
545:142dd5a2631f 546:22ed5f5821e2
21 #include "dvdauth.h" 21 #include "dvdauth.h"
22 22
23 char *dvd_device=NULL; 23 char *dvd_device=NULL;
24 unsigned char key_disc[2048]; 24 unsigned char key_disc[2048];
25 unsigned char key_title[5]; 25 unsigned char key_title[5];
26 unsigned char *dvdimportkey=NULL;
27 int descrambling=0;
26 28
27 29
28 #include <linux/fs.h> 30 #include <linux/fs.h>
29 31
30 #ifndef FIBMAP 32 #ifndef FIBMAP
56 ai.lsa.agid = i; 58 ai.lsa.agid = i;
57 ioctl(fd, DVD_AUTH, &ai); 59 ioctl(fd, DVD_AUTH, &ai);
58 } 60 }
59 } 61 }
60 62
63
64 int dvd_import_key ( unsigned char *hexkey )
65 {
66 unsigned char *t=key_title;
67 int digit=4,len;
68 bzero(key_title,sizeof(key_title));
69 // printf("DVD key: %s\n",hexkey);
70 for (len=0;len<10;len++) {
71 // printf("-> %c\n",*hexkey);
72 if (!*hexkey) return 1;
73 if (*hexkey>='A'&&*hexkey<='F') *t|=(*hexkey-'A'+10)<<digit;
74 else if (*hexkey>='0'&&*hexkey<='9') *t|=(*hexkey-'0')<<digit;
75 else return 1;
76 if (digit) digit=0; else {
77 digit=4;
78 t++;
79 }
80 hexkey++;
81 }
82 if (*hexkey) return 1;
83 printf("DVD key (requested): %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]);
84 descrambling=1;
85 return 0;
86 }
61 87
62 88
63 int dvd_auth ( char *dev , int fd ) 89 int dvd_auth ( char *dev , int fd )
64 { 90 {
65 int devfd; /* FD of DVD device */ 91 int devfd; /* FD of DVD device */
97 fprintf(stderr,"DVD: CSSDecryptTitleKey() failed.\n"); 123 fprintf(stderr,"DVD: CSSDecryptTitleKey() failed.\n");
98 return 1; 124 return 1;
99 } 125 }
100 126
101 close(devfd); 127 close(devfd);
128 printf("DVD title key is: %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]);
129 descrambling=1;
102 return 0; 130 return 0;
103 } 131 }
104 132
105 133
106 #endif 134 #endif