[libdvdcss-devel] try again: patch for negative caching of keys

Marc Espie espie at nerim.net
Sun Aug 28 12:23:17 CEST 2011


I sent this a few weeks ago.  I haven't gotten any useful feedback from it.
(I'm french, if you really have trouble expressing yourself in english).

I really would like to see negative caching in dvdcss.

My goal was to make things as simple as possible: other keys are cached
in separate files. Doing negative caching should involve creating the exact
same files.

Possibly, the configure.ac part should be a separate patch. As it stands,
libdvdcss does not contain a proper configure script, since AC_INIT is
stumped.

I believe storing the PACKAGE_VERSION is the simplest thing to do, in case
someone figures out a bug that means key cracking was actually incorrect
later.

I'm willing to spend a bit more time working on that patch, but GIVE ME
CONCRETE DIRECTIONS, not some fuzzy things like "I would do that differently"
(with about NO INDICATION of what should be done differently) or "this
should be separate patches" (I'll make a wild guess at: configure.ac separated
from the css code proper).

--- configure.ac.orig	Fri Aug 29 20:59:00 2008
+++ configure.ac	Wed Aug 17 11:51:22 2011
@@ -1,4 +1,4 @@
-AC_INIT(src/libdvdcss.c)
+AC_INIT(libdvdcss, 1.2.10)
 
 AC_PREREQ(2.50)
 AC_CONFIG_AUX_DIR(.auto)
--- src/css.c.orig	Fri Aug 29 20:42:47 2008
+++ src/css.c	Wed Aug 17 11:52:49 2011
@@ -172,10 +172,13 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
         {
             char psz_key[KEY_SIZE * 3];
             unsigned int k0, k1, k2, k3, k4;
+	    int n;
 
-            psz_key[KEY_SIZE * 3 - 1] = '\0';
+	    memset(psz_key, 0, sizeof psz_key);
+	    n = read( i_fd, psz_key, KEY_SIZE * 3 - 1 );
+            close( i_fd );
 
-            if( read( i_fd, psz_key, KEY_SIZE * 3 - 1 ) == KEY_SIZE * 3 - 1
+            if( n == KEY_SIZE * 3 - 1
                  && sscanf( psz_key, "%x:%x:%x:%x:%x",
                             &k0, &k1, &k2, &k3, &k4 ) == 5 )
             {
@@ -189,9 +192,15 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
                 /* Don't try to save it again */
                 b_cache = 0;
                 i_ret = 1;
-            }
+            } 
+#if defined PACKAGE_VERSION
+	    else if (n > 0 && strcmp(psz_key, PACKAGE_VERSION "\n") == 0) 
+	    {
+	    	/* didn't crack it, negative caching */
+		return -1;
+	    }
+#endif
 
-            close( i_fd );
         }
     }
 
@@ -203,6 +212,17 @@ int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
         if( i_ret < 0 )
         {
             print_error( dvdcss, "fatal error in vts css key" );
+#if defined PACKAGE_VERSION 
+	    i_fd = open( dvdcss->psz_cachefile, O_RDWR|O_CREAT, 0644 );
+	    if( i_fd >= 0 )
+	    {
+		char message[sizeof(PACKAGE_VERSION) + 3];
+
+		sprintf( message, "%s\n", PACKAGE_VERSION);
+		write( i_fd, message, strlen(message) );
+		close( i_fd );
+	    }
+#endif
             return i_ret;
         }
 


More information about the libdvdcss-devel mailing list