shithub: libdvdcss

Download patch

ref: d1f84a6a3d485c8b365a5a6a83a9b662dd02b987
parent: 3a49a3e5a981bf72234f96022fbfe2333fa636fd
author: Diego Biurrun <diego@biurrun.de>
date: Fri Oct 31 10:56:32 EDT 2014

Do not invade the _t namespace with (typedeffed) symbol names.

The _t namespace is reserved by POSIX.

--- a/src/css.c
+++ b/src/css.c
@@ -75,13 +75,13 @@
 static void DecryptKey      ( uint8_t,
                               const uint8_t *, const uint8_t *, uint8_t * );
 
-static int  DecryptDiscKey  ( dvdcss_t, const uint8_t *, dvd_key_t );
+static int  DecryptDiscKey  ( dvdcss_t, const uint8_t *, dvd_key );
 static int  CrackDiscKey    ( dvdcss_t, uint8_t * );
 
-static void DecryptTitleKey ( dvd_key_t, dvd_key_t );
+static void DecryptTitleKey ( dvd_key, dvd_key );
 static int  RecoverTitleKey ( int, const uint8_t *,
                               const uint8_t *, const uint8_t *, uint8_t * );
-static int  CrackTitleKey   ( dvdcss_t, int, int, dvd_key_t );
+static int  CrackTitleKey   ( dvdcss_t, int, int, dvd_key );
 
 static int  AttackPattern   ( const uint8_t[], uint8_t * );
 #if 0
@@ -88,7 +88,7 @@
 static int  AttackPadding   ( const uint8_t[] );
 #endif
 
-static int  dvdcss_titlekey    ( dvdcss_t, int , dvd_key_t );
+static int  dvdcss_titlekey ( dvdcss_t, int, dvd_key );
 
 /*****************************************************************************
  * dvdcss_test: check if the disc is encrypted or not
@@ -182,10 +182,10 @@
  *****************************************************************************/
 int dvdcss_title ( dvdcss_t dvdcss, int i_block )
 {
-    dvd_title_t *p_title;
-    dvd_title_t *p_newtitle;
-    dvd_key_t    p_title_key;
-    int          i_fd, i_ret = -1, b_cache = 0;
+    struct dvd_title *p_title;
+    struct dvd_title *p_newtitle;
+    dvd_key p_title_key;
+    int i_fd, i_ret = -1, b_cache = 0;
 
     if( ! dvdcss->b_scrambled )
     {
@@ -335,7 +335,7 @@
 int dvdcss_disckey( dvdcss_t dvdcss )
 {
     unsigned char p_buffer[ DVD_DISCKEY_SIZE ];
-    dvd_key_t p_disc_key;
+    dvd_key p_disc_key;
     int i;
 
     if( GetBusKey( dvdcss ) < 0 )
@@ -418,7 +418,7 @@
 /*****************************************************************************
  * dvdcss_titlekey: get title key.
  *****************************************************************************/
-static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
+static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key p_title_key )
 {
     static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ];  /* we never read it back */
     uint8_t p_key[ KEY_SIZE ];
@@ -536,7 +536,7 @@
  * sec : sector to unscramble
  * key : title key for this sector
  *****************************************************************************/
-int dvdcss_unscramble( dvd_key_t p_key, uint8_t *p_sec )
+int dvdcss_unscramble( dvd_key p_key, uint8_t *p_sec )
 {
     unsigned int    i_t1, i_t2, i_t3, i_t4, i_t5, i_t6;
     uint8_t        *p_end = p_sec + DVDCSS_BLOCK_SIZE;
@@ -592,9 +592,9 @@
 {
     uint8_t   p_buffer[10];
     uint8_t   p_challenge[2*KEY_SIZE];
-    dvd_key_t p_key1;
-    dvd_key_t p_key2;
-    dvd_key_t p_key_check;
+    dvd_key   p_key1;
+    dvd_key   p_key2;
+    dvd_key   p_key_check;
     uint8_t   i_variant = 0;
     int       i_ret = -1;
     int       i;
@@ -1037,7 +1037,7 @@
  * cracker. A copy of his article can be found here:
  * http://www-2.cs.cmu.edu/~dst/DeCSS/FrankStevenson/mail2.txt
  *****************************************************************************/
-static const dvd_key_t player_keys[] =
+static const dvd_key player_keys[] =
 {
     { 0x01, 0xaf, 0xe3, 0x12, 0x80 },
     { 0x12, 0x11, 0xca, 0x04, 0x3b },
@@ -1081,7 +1081,7 @@
  * p_disc_key: result, the 5 byte disc key
  *****************************************************************************/
 static int DecryptDiscKey( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
-                           dvd_key_t p_disc_key )
+                           dvd_key p_disc_key )
 {
     uint8_t p_verify[KEY_SIZE];
     unsigned int i, n = 0;
@@ -1123,7 +1123,7 @@
  * p_disc_key: result, the 5 byte disc key
  * p_titlekey: the encrypted title key, gets overwritten by the decrypted key
  *****************************************************************************/
-static void DecryptTitleKey( dvd_key_t p_disc_key, dvd_key_t p_titlekey )
+static void DecryptTitleKey( dvd_key p_disc_key, dvd_key p_titlekey )
 {
     DecryptKey( 0xff, p_disc_key, p_titlekey, p_titlekey );
 }
@@ -1488,7 +1488,7 @@
  * i_pos is the starting sector, i_len is the maximum number of sectors to read
  *****************************************************************************/
 static int CrackTitleKey( dvdcss_t dvdcss, int i_pos, int i_len,
-                          dvd_key_t p_titlekey )
+                          dvd_key p_titlekey )
 {
     uint8_t       p_buf[ DVDCSS_BLOCK_SIZE ];
     const uint8_t p_packstart[4] = { 0x00, 0x00, 0x01, 0xba };
--- a/src/css.h
+++ b/src/css.h
@@ -37,22 +37,22 @@
 
 #define KEY_SIZE 5
 
-typedef uint8_t dvd_key_t[KEY_SIZE];
+typedef uint8_t dvd_key[KEY_SIZE];
 
-typedef struct dvd_title_s
+typedef struct dvd_title
 {
-    int                 i_startlb;
-    dvd_key_t           p_key;
-    struct dvd_title_s *p_next;
-} dvd_title_t;
+    int               i_startlb;
+    dvd_key           p_key;
+    struct dvd_title *p_next;
+} dvd_title;
 
-typedef struct css_s
+typedef struct css
 {
     int             i_agid;      /* Current Authentication Grant ID. */
-    dvd_key_t       p_bus_key;   /* Current session key. */
-    dvd_key_t       p_disc_key;  /* This DVD disc's key. */
-    dvd_key_t       p_title_key; /* Current title key. */
-} css_t;
+    dvd_key         p_bus_key;   /* Current session key. */
+    dvd_key         p_disc_key;  /* This DVD disc's key. */
+    dvd_key         p_title_key; /* Current title key. */
+} css;
 
 /*****************************************************************************
  * Prototypes in css.c
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -763,7 +763,7 @@
  */
 LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
 {
-    dvd_title_t *p_title;
+    struct dvd_title *p_title;
     int i_ret;
 
     /* Free our list of keys */
@@ -770,7 +770,7 @@
     p_title = dvdcss->p_titles;
     while( p_title )
     {
-        dvd_title_t *p_tmptitle = p_title->p_next;
+        struct dvd_title *p_tmptitle = p_title->p_next;
         free( p_title );
         p_title = p_tmptitle;
     }
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -60,10 +60,10 @@
 
     /* Decryption stuff */
     enum dvdcss_method i_method;
-    css_t        css;
+    struct css   css;
     int          b_ioctls;
     int          b_scrambled;
-    dvd_title_t *p_titles;
+    struct dvd_title *p_titles;
 
     /* Key cache directory and pointer to the filename */
     char   psz_cachefile[PATH_MAX];