Discussion:
[libdvdcss-devel] cache: use libxdg-basedir and save cache into XDG-compliant location.
Diego Elio Pettenò
2013-02-26 13:57:15 UTC
Permalink
libdvdcss | branch: xdgcache | Diego Elio Pettenò <***@flameeyes.eu> | Tue Feb 26 14:55:48 2013 +0100| [8af8d2d561721af6eb30a7e8d26a94063c18c5d1] | committer: Diego Elio Pettenò

cache: use libxdg-basedir and save cache into XDG-compliant location.

For most users, this means that ~/.dvdcss is replaced by
~/.cache/dvdcss, but now it follows XDG_CACHE_HOME instead of
DVDCSS_CACHE to know where to store it.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=8af8d2d561721af6eb30a7e8d26a94063c18c5d1
---

Makefile.am | 3 +-
configure.ac | 2 +
src/libdvdcss.c | 126 +++++++++++++------------------------------------------
3 files changed, 32 insertions(+), 99 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8ff1727..2902b10 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,7 +31,8 @@ libdvdcss_la_SOURCES = \
src/common.h

libdvdcss_la_LDFLAGS = -version-info $(DVDCSS_LTVERSION) $(DVDCSS_LDFLAGS)
-libdvdcss_la_LIBADD =
+libdvdcss_la_CFLAGS = $(XDG_CFLAGS)
+libdvdcss_la_LIBADD = $(XDG_LIBS)

if !SYS_MSVC
libdvdcss_la_LDFLAGS += = -no-undefined
diff --git a/configure.ac b/configure.ac
index 5125197..a59428e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -196,6 +196,8 @@ AC_CHECK_HEADERS(sys/ioctl.h,[
Define if FreeBSD-like dvd_struct is defined.)
fi
fi
+
+ PKG_CHECK_MODULES([XDG], [libxdg-basedir])
])

CC_CHECK_CFLAGS_APPEND([-Wall -Wsign-compare])
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 961f072..e481f2e 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -132,6 +132,12 @@
#define mkdir(a, b) _mkdir(a)
#endif

+#if defined(_WIN32_IE) && _WIN32_IE >= 0x401
+# define DVDCSS_CACHE_WIN32
+#else
+# include <basedir.h>
+#endif
+
/**
* \brief Symbol for version checks.
*
@@ -160,12 +166,12 @@ char * dvdcss_interface_2 = VERSION;
*/
LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
{
- char psz_buffer[PATH_MAX];
+ char psz_cache[PATH_MAX];
+ char psz_home[PATH_MAX];
int i_ret;

char *psz_method = getenv( "DVDCSS_METHOD" );
char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
- char *psz_cache = getenv( "DVDCSS_CACHE" );
#ifdef DVDCSS_RAW_OPEN
char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" );
#endif
@@ -233,20 +239,15 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
}
}

- /*
- * If DVDCSS_CACHE was not set, try to guess a default value
- */
- if( psz_cache == NULL || psz_cache[0] == '\0' )
+#if DVDCSS_CACHE_WIN32
{
-#if defined(_WIN32_IE) && _WIN32_IE >= 0x401
- typedef HRESULT( WINAPI *SHGETFOLDERPATH )
+ typedef HRESULT( WINAPI *SHGETFOLDERPATH )
( HWND, int, HANDLE, DWORD, LPTSTR );

# define CSIDL_FLAG_CREATE 0x8000
# define CSIDL_APPDATA 0x1A
# define SHGFP_TYPE_CURRENT 0

- char psz_home[MAX_PATH];
HINSTANCE p_dll;
SHGETFOLDERPATH p_getpath;

@@ -275,78 +276,27 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )

/* Cache our keys in
* C:\Documents and Settings\$USER\Application Data\dvdcss\ */
- if( *psz_home )
- {
- snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home );
- psz_buffer[PATH_MAX-1] = '\0';
- psz_cache = psz_buffer;
- }
+ }
#else
- char *psz_home = NULL;
-# ifdef HAVE_PWD_H
- struct passwd *p_pwd;
-
- /* Try looking in password file for home dir. */
- p_pwd = getpwuid(getuid());
- if( p_pwd )
- {
- psz_home = p_pwd->pw_dir;
- }
-# endif
-
- if( psz_home == NULL )
- {
- psz_home = getenv( "HOME" );
- }
- if( psz_home == NULL )
- {
- psz_home = getenv( "USERPROFILE" );
- }
-
- /* Cache our keys in ${HOME}/.dvdcss/ */
- if( psz_home )
- {
- int home_pos = 0;
-
-#ifdef __OS2__
- if( *psz_home == '/' || *psz_home == '\\')
- {
- char *psz_unixroot = getenv("UNIXROOT");
-
- if( psz_unixroot &&
- psz_unixroot[0] &&
- psz_unixroot[1] == ':' &&
- psz_unixroot[2] == '\0')
- {
- strcpy( psz_buffer, psz_unixroot );
- home_pos = 2;
- }
- }
-#endif
- snprintf( psz_buffer + home_pos, PATH_MAX - home_pos,
- "%s/.dvdcss", psz_home );
- psz_buffer[PATH_MAX-1] = '\0';
- psz_cache = psz_buffer;
- }
-#endif
+ {
+ static xdgHandle xdg;
+ xdgInitHandle(&xdg);
+ strncpy(psz_home, xdgCacheHome(&xdg), sizeof(psz_home)-1);
+ xdgWipeHandle(&xdg);
}
+#endif

- /*
- * Find cache dir from the DVDCSS_CACHE environment variable
- */
- if( psz_cache != NULL )
+ if( *psz_home )
{
- if( psz_cache[0] == '\0' || !strcmp( psz_cache, "off" ) )
- {
- psz_cache = NULL;
- }
- /* Check that we can add the ID directory and the block filename */
- else if( strlen( psz_cache ) + 1 + 32 + 1 + (KEY_SIZE * 2) + 10 + 1
- > PATH_MAX )
- {
- print_error( dvdcss, "cache directory name is too long" );
- psz_cache = NULL;
- }
+ /* Check that we can add the ID directory and the block filename */
+ if( strlen( psz_home ) + strlen("/dvdcss") + 1 + 32 + 1 + (KEY_SIZE * 2) + 10 + 1
+ > PATH_MAX )
+ {
+ print_error( dvdcss, "cache directory name is too long" );
+ } else {
+ snprintf( psz_cache, PATH_MAX, "%s/dvdcss", psz_home );
+ psz_cache[PATH_MAX-1] = '\0';
+ }
}

/*
@@ -401,28 +351,8 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
}
}

- /* If the cache is enabled, write the cache directory tag */
- if( psz_cache )
- {
- static const char psz_tag[] =
- "Signature: 8a477f597d28d172789f06886806bc55\r\n"
- "# This file is a cache directory tag created by libdvdcss.\r\n"
- "# For information about cache directory tags, see:\r\n"
- "# http://www.brynosaurus.com/cachedir/\r\n";
- char psz_tagfile[PATH_MAX + 1 + 12 + 1];
- int i_fd;
-
- sprintf( psz_tagfile, "%s/CACHEDIR.TAG", psz_cache );
- i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 );
- if( i_fd >= 0 )
- {
- write( i_fd, psz_tag, strlen(psz_tag) );
- close( i_fd );
- }
- }
-
/* If the cache is enabled, extract a unique disc ID */
- if( psz_cache )
+ if( *psz_cache )
{
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
char psz_key[1 + KEY_SIZE * 2 + 1];
Diego Elio Pettenò
2013-02-27 07:09:24 UTC
Permalink
libdvdcss | branch: xdgcache | Diego Elio Pettenò <***@flameeyes.eu> | Tue Feb 26 14:55:48 2013 +0100| [3acd327db65b39ce7b35a38f0e70c46a757ca4c0] | committer: Diego Elio Pettenò

cache: use libxdg-basedir and save cache into XDG-compliant location.

For most users, this means that ~/.dvdcss is replaced by
~/.cache/dvdcss, but now it follows XDG_CACHE_HOME instead of
DVDCSS_CACHE to know where to store it.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=3acd327db65b39ce7b35a38f0e70c46a757ca4c0
---

Makefile.am | 3 +-
configure.ac | 2 +
src/libdvdcss.c | 126 +++++++++++++------------------------------------------
3 files changed, 32 insertions(+), 99 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 25b08fd..4607945 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,7 +29,8 @@ libdvdcss_la_SOURCES = \
src/common.h

libdvdcss_la_LDFLAGS = -version-info $(DVDCSS_LTVERSION) $(DVDCSS_LDFLAGS)
-libdvdcss_la_LIBADD =
+libdvdcss_la_CFLAGS = $(XDG_CFLAGS)
+libdvdcss_la_LIBADD = $(XDG_LIBS)

if !SYS_MSVC
libdvdcss_la_LDFLAGS += = -no-undefined
diff --git a/configure.ac b/configure.ac
index a736aac..07e8321 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,6 +210,8 @@ AC_CHECK_HEADERS(sys/ioctl.h,[
Define if FreeBSD-like dvd_struct is defined.)
fi
fi
+
+ PKG_CHECK_MODULES([XDG], [libxdg-basedir])
])

CC_CHECK_CFLAGS_APPEND([-Wall -Wsign-compare])
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index dcb99c1..f7f81e5 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -132,6 +132,12 @@
#define mkdir(a, b) _mkdir(a)
#endif

+#if defined(_WIN32_IE) && _WIN32_IE >= 0x401
+# define DVDCSS_CACHE_WIN32
+#else
+# include <basedir.h>
+#endif
+
/**
* \brief Symbol for version checks.
*
@@ -160,12 +166,12 @@ char * dvdcss_interface_2 = VERSION;
*/
LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
{
- char psz_buffer[PATH_MAX];
+ char psz_cache[PATH_MAX];
+ char psz_home[PATH_MAX];
int i_ret;

char *psz_method = getenv( "DVDCSS_METHOD" );
char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
- char *psz_cache = getenv( "DVDCSS_CACHE" );
#ifdef DVDCSS_RAW_OPEN
char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" );
#endif
@@ -233,20 +239,15 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
}
}

- /*
- * If DVDCSS_CACHE was not set, try to guess a default value
- */
- if( psz_cache == NULL || psz_cache[0] == '\0' )
+#if DVDCSS_CACHE_WIN32
{
-#if defined(_WIN32_IE) && _WIN32_IE >= 0x401
- typedef HRESULT( WINAPI *SHGETFOLDERPATH )
+ typedef HRESULT( WINAPI *SHGETFOLDERPATH )
( HWND, int, HANDLE, DWORD, LPTSTR );

# define CSIDL_FLAG_CREATE 0x8000
# define CSIDL_APPDATA 0x1A
# define SHGFP_TYPE_CURRENT 0

- char psz_home[MAX_PATH];
HINSTANCE p_dll;
SHGETFOLDERPATH p_getpath;

@@ -275,78 +276,27 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )

/* Cache our keys in
* C:\Documents and Settings\$USER\Application Data\dvdcss\ */
- if( *psz_home )
- {
- snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home );
- psz_buffer[PATH_MAX-1] = '\0';
- psz_cache = psz_buffer;
- }
+ }
#else
- char *psz_home = NULL;
-# ifdef HAVE_PWD_H
- struct passwd *p_pwd;
-
- /* Try looking in password file for home dir. */
- p_pwd = getpwuid(getuid());
- if( p_pwd )
- {
- psz_home = p_pwd->pw_dir;
- }
-# endif
-
- if( psz_home == NULL )
- {
- psz_home = getenv( "HOME" );
- }
- if( psz_home == NULL )
- {
- psz_home = getenv( "USERPROFILE" );
- }
-
- /* Cache our keys in ${HOME}/.dvdcss/ */
- if( psz_home )
- {
- int home_pos = 0;
-
-#ifdef __OS2__
- if( *psz_home == '/' || *psz_home == '\\')
- {
- char *psz_unixroot = getenv("UNIXROOT");
-
- if( psz_unixroot &&
- psz_unixroot[0] &&
- psz_unixroot[1] == ':' &&
- psz_unixroot[2] == '\0')
- {
- strcpy( psz_buffer, psz_unixroot );
- home_pos = 2;
- }
- }
-#endif
- snprintf( psz_buffer + home_pos, PATH_MAX - home_pos,
- "%s/.dvdcss", psz_home );
- psz_buffer[PATH_MAX-1] = '\0';
- psz_cache = psz_buffer;
- }
-#endif
+ {
+ static xdgHandle xdg;
+ xdgInitHandle(&xdg);
+ strncpy(psz_home, xdgCacheHome(&xdg), sizeof(psz_home)-1);
+ xdgWipeHandle(&xdg);
}
+#endif

- /*
- * Find cache dir from the DVDCSS_CACHE environment variable
- */
- if( psz_cache != NULL )
+ if( *psz_home )
{
- if( psz_cache[0] == '\0' || !strcmp( psz_cache, "off" ) )
- {
- psz_cache = NULL;
- }
- /* Check that we can add the ID directory and the block filename */
- else if( strlen( psz_cache ) + 1 + 32 + 1 + (KEY_SIZE * 2) + 10 + 1
- > PATH_MAX )
- {
- print_error( dvdcss, "cache directory name is too long" );
- psz_cache = NULL;
- }
+ /* Check that we can add the ID directory and the block filename */
+ if( strlen( psz_home ) + strlen("/dvdcss") + 1 + 32 + 1 + (KEY_SIZE * 2) + 10 + 1
+ > PATH_MAX )
+ {
+ print_error( dvdcss, "cache directory name is too long" );
+ } else {
+ snprintf( psz_cache, PATH_MAX, "%s/dvdcss", psz_home );
+ psz_cache[PATH_MAX-1] = '\0';
+ }
}

/*
@@ -401,28 +351,8 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target )
}
}

- /* If the cache is enabled, write the cache directory tag */
- if( psz_cache )
- {
- static const char psz_tag[] =
- "Signature: 8a477f597d28d172789f06886806bc55\r\n"
- "# This file is a cache directory tag created by libdvdcss.\r\n"
- "# For information about cache directory tags, see:\r\n"
- "# http://www.brynosaurus.com/cachedir/\r\n";
- char psz_tagfile[PATH_MAX + 1 + 12 + 1];
- int i_fd;
-
- sprintf( psz_tagfile, "%s/CACHEDIR.TAG", psz_cache );
- i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 );
- if( i_fd >= 0 )
- {
- write( i_fd, psz_tag, strlen(psz_tag) );
- close( i_fd );
- }
- }
-
/* If the cache is enabled, extract a unique disc ID */
- if( psz_cache )
+ if( *psz_cache )
{
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
char psz_key[1 + KEY_SIZE * 2 + 1];
Reimar Döffinger
2013-02-27 07:19:38 UTC
Permalink
Post by Diego Elio Pettenò
cache: use libxdg-basedir and save cache into XDG-compliant location.
For most users, this means that ~/.dvdcss is replaced by
~/.cache/dvdcss, but now it follows XDG_CACHE_HOME instead of
DVDCSS_CACHE to know where to store it.
Since I've said it so often I don't know if there is a point, but XDG cache dir is completely inappropriate IMHO.
The data in it can _not_ generally be restored, just try e.g. installing a new drive and dvdcss will stop working completely until the use manually configures a region.
There are also cases where titles are too short for cracking and thus only manually created key files work (which btw. speaks against the binary format, also look at e.g. libaacs, they too use text format files).

Reimar
Diego Elio Pettenò
2013-02-27 07:24:25 UTC
Permalink
Post by Reimar Döffinger
Since I've said it so often I don't know if there is a point, but XDG
cache dir is completely inappropriate IMHO. The data in it can _not_
generally be restored, just try e.g. installing a new drive and
dvdcss will stop working completely until the use manually configures
a region.
Is it the case? I never set the region of DVD drives and they seem to
work just fine... including external USB drives.. I think most
manufacturers pre-set the region on the units they sell.
Post by Reimar Döffinger
There are also cases where titles are too short for cracking and thus
only manually created key files work (which btw. speaks against the
binary format, also look at e.g. libaacs, they too use text format
files).
Manually created how? If there is a way to "manually create" a key for
short titles, maybe it's a good idea to just fix libdvdcss so that it
can generate he same?

Also it's trivial to copy the key around with base64, even when it's
stored as binary.
--
Diego Elio Pettenò — Flameeyes
***@flameeyes.eu — http://blog.flameeyes.eu/
Jean-Baptiste Kempf
2013-02-27 07:26:54 UTC
Permalink
Post by Diego Elio Pettenò
Is it the case? I never set the region of DVD drives and they seem to
work just fine... including external USB drives.. I think most
manufacturers pre-set the region on the units they sell.
I know that some don't, actually.

Best regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Bernard Lang
2013-02-27 12:21:42 UTC
Permalink
Hi,

I am new to this list. I expect that some members already know me from
other places.
Post by Diego Elio Pettenò
Is it the case? I never set the region of DVD drives and they seem to
work just fine... including external USB drives.. I think most
manufacturers pre-set the region on the units they sell.
I know that some don't, actually.
I confirm that.
My drive has a RPC type II, and the region is not set.
It was like that when I bought the computer (ASRock).

I am not an expert on the coding libdvdcss, so I hesitated discussing
on this list. Please tell me if I am inappropriate.

However, I do have much experience using it, since I own a pretty
large collection of DVD which I watch on my computer. I also got
interested in the working of libdvdcss, since I occasionnaly encounter
problèms. But reading the code and understanding it is another matter.

Using my drive, with no region set, I found that about 25 to 30% of
the DVDs have a title that cannot be found by libdvdcss (though I am
not sure whether the region setting of the drive has a responsibility
in this). I guess it does not matter for most people, as these titles,
often (but not always) very short, are generally not part of the main
film. Actually, for many of them, I wonder whether they contain any
information at all (none that I could identify with a player or with
avidemux). But again, I have much to learn.
Post by Diego Elio Pettenò
There are also cases where titles are too short for cracking and thus
only manually created key files work (which btw. speaks against the
binary format, also look at e.g. libaacs, they too use text format
files).
Manually created how? If there is a way to "manually create" a key for
short titles, maybe it's a good idea to just fix libdvdcss so that it
can generate he same?
Some people actually use that in dvdcss?
I do.

Actually, I often managed to get the correct keys by other means, and
added them by hand in the cache. I confirm it is easier in text format.

This lead me to get interested in the patterns of use of CSS keys
which is probably an interesting glimpse of industrial sociology (or
some similar 'science'). I am toying with the idea of systematic
statistics on this topic.

However, I encounter a variety of problems, and not knowing enough
about libdvdcss (I found very little documentation on CSS itself) I am
not sure what is the best approach to some of the problems. I would
appreciate if some of the experts on this list could answer some
questions, even though I am not a contributor to the actual libdvdcss
code.


My first question is the following. Given a title and a CSS key, is
there a reliable way (other than viewing, which is not always
adequate) to check that it is the proper key to decode that title. My
experience is that some titles will be 'decoded' (?) without fuss by
many keys, and the bad keys will produce garbage without any
noticeable protest from the decoding software (libdvdcss, not always
within VLC).

I once had a key that decoded the title, but only for the upper half of
the screen.


Another question is the following. Given a coded title and a decoded
one. Is it possible to check that the first is an encoded version of
the second. Is it possible to identify more easily the key ? Can that
be somewhat easier than finding the key with only the encoded version
of the title. I have met that situation in practice.


My last question concerns my DVD player. I do not wish to change
the (absent) region setting, as I have DVDs from several different
regions (some films are just not published in region 2). Would
libdvdcss be able to discover more keys if the player were set to the
region corresponding to the DVD.

Thank you for reading

Bien cordialement

Bernard
Post by Diego Elio Pettenò
Post by Diego Elio Pettenò
Is it the case? I never set the region of DVD drives and they seem to
work just fine... including external USB drives.. I think most
manufacturers pre-set the region on the units they sell.
I know that some don't, actually.
Best regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
http://mailman.videolan.org/listinfo/libdvdcss-devel
--
Après la bulle Internet, la bulle financière ...
Et bientôt la bulle des brevets
http://www.strategie.gouv.fr/system/files/noteveille81.pdf
http://www.huffingtonpost.com/brian-kahin/the-patent-bubble_b_129232.html
la gestion des catastrophes comme principe de gouvernement

***@datcha.net ,_ /\o \o/ gsm +33 6 6206 1693
http://www.datcha.net/ ^^^^^^^^^^^^^^^^^ tel +33 1 3056 1693
Je n'exprime que mon opinion - I express only my opinion
CAGED BEHIND WINDOWS or FREE WITH LINUX
Reimar Döffinger
2013-02-27 19:00:24 UTC
Permalink
Post by Bernard Lang
Using my drive, with no region set, I found that about 25 to 30% of
the DVDs have a title that cannot be found by libdvdcss (though I am
not sure whether the region setting of the drive has a responsibility
in this).
When the region is not set, libdvdcss can't just ask the drive to
give it the keys.
Though I believe some drives cause even more trouble when the region
is not set, breaking even the fallback methods of cracking the keys -
though maybe I misremember.
Post by Bernard Lang
Post by Jean-Baptiste Kempf
Some people actually use that in dvdcss?
I do.
Actually, I often managed to get the correct keys by other means, and
added them by hand in the cache. I confirm it is easier in text format.
In the two cases I had that the keys were identical or simply increasing
by one between the titles.
Post by Bernard Lang
My first question is the following. Given a title and a CSS key, is
there a reliable way (other than viewing, which is not always
adequate) to check that it is the proper key to decode that title. My
experience is that some titles will be 'decoded' (?) without fuss by
many keys, and the bad keys will produce garbage without any
noticeable protest from the decoding software (libdvdcss, not always
within VLC).
If the video is long enough you should get decoding errors quite
reliably with the wrong keys. However I believe there is no really
certain way to detect if they key is correct (if there is, we definitely
should be using it in DVDCSS, I had issues where it came up with the
wrong key, though I think they were never reproducible enough to debug,
possibly related to drive read errors).
Post by Bernard Lang
Another question is the following. Given a coded title and a decoded
one. Is it possible to check that the first is an encoded version of
the second. Is it possible to identify more easily the key ? Can that
be somewhat easier than finding the key with only the encoded version
of the title. I have met that situation in practice.
As far as I can see the most problematic step of the cracking is to
figure out what the decoded data looks like, see the function
AttackPattern in the code.
Since they key is only 40 bit cracking it is fairly trivial if you
know what some encrypted data should decrypt to.
Post by Bernard Lang
My last question concerns my DVD player. I do not wish to change
the (absent) region setting, as I have DVDs from several different
regions (some films are just not published in region 2).
Setting the region should not make anything worse when it comes
to playing DVDs from a different region as far as I know.
For most drives there are also ways to either disable RPC or
at least allowing to change the region as often as you want.
Post by Bernard Lang
Would
libdvdcss be able to discover more keys if the player were set to the
region corresponding to the DVD.
In that case it should be able to easily get all keys, just like
a proper DVD player would.
Bernard Lang
2013-03-13 00:45:40 UTC
Permalink
belatedly ...

Thanks Reimar for your detailed answer.

I would have replied earlier, but I had to check a few thing, and then
was caught in travel. Sorry.

I understand from your reply that libdvdcss should encounter no CSS
decoding problem if the drive is set on the region of the DVD. If
that is the case, then not being able to identify a key should be a
rare event, and not such a major issue for most users ?

And then, having a drive with no region set should be an inconvenience
rather than an advantage as I believed. Since most of my collection is
region 2, setting the drive to region 2 would ensure perfect decoding
of all DVDs for that region, and would not make things any worse for
other regions. I actually wanted to check that ... but I run into
hardware problems.
Post by Reimar Döffinger
If the video is long enough you should get decoding errors quite
reliably with the wrong keys.
I had at least one long title that disproves that. Decoding that title
was strange in many respect. One key gave only the upper half of the
screen. Another decoding decoded correctly the last third
(approximately) of the title, but not the beginning.
I also have the correct key for decoding it fully.
I can retrieve the reference, as I write down nearly everything I do.
Post by Reimar Döffinger
Post by Bernard Lang
Actually, I often managed to get the correct keys by other means, and
added them by hand in the cache. I confirm it is easier in text format.
In the two cases I had that the keys were identical or simply increasing
by one between the titles.
These are the more common cases, but there are other cases when keys
can be guessed. Coming back to previous remarks ...
Post by Reimar Döffinger
Post by Bernard Lang
There are also cases where titles are too short for cracking and thus
only manually created key files work (which btw. speaks against the
binary format, also look at e.g. libaacs, they too use text format
files).
Manually created how? If there is a way to "manually create" a key for
short titles, maybe it's a good idea to just fix libdvdcss so that it
can generate he same?
There is a big difference, I believe. I assume that the keys
identified by libdvdcss are always the correct keys (am I right ?)

But the various tricks for guessing keys are only hints as to what the
correct key might be. Some of the tricks are fairly reliable (in a
social sense, more than in a mathematical sense), and some others have
a much weaker reliability.

This is why I raised the question of whether one can reliably check
the correctness of a key. And the answer seems to be no.

These tricks are mostly based on regularities in key patterns, for a
DVD or for a collection of DVDs.

But there are possibly other ways. The titles than cannot be decoded
are often short, sometimes no more than 5 sectors. And it is sometimes
the case that those titles are nearly or completely identical to
others that have been decoded. This knwledge could help decode those
for which the key could not be identified. Sometimes, this happens for
longer titles too. Hence my question about identifying the key when
the decoded version of the title is available.

I am currently embedding my knowledge in a program, with a double
purpose :
- to avoid having to repeat by hand what can be done automatically;
- to write down what I learned, in a very precise way;
- to be more systematic in identifying regular structures, because
they are not always obvious. I actually even look for structures
that are very plausible, but that I did not see so far (but would
probably not recognize it I saw them);
- to write down in a log what I do;
- to do statistics about the way CSS is used, even when I have no
decoding problem.

But this is still very experimental, and I am not sure how useful.

As I said, I have some titles that are not decoded by libdvdcss for
about 30% of the DVDs. These titles are often of lesser importance.
If that can be completely solved by a proper setting of the drive
zone, guessing the missing keys when the drive zone is not properly
set seems a minor problem.

I would appreciate opinions on this.

Cordialement

Bernard
Post by Reimar Döffinger
Post by Bernard Lang
Using my drive, with no region set, I found that about 25 to 30% of
the DVDs have a title that cannot be found by libdvdcss (though I am
not sure whether the region setting of the drive has a responsibility
in this).
When the region is not set, libdvdcss can't just ask the drive to
give it the keys.
Though I believe some drives cause even more trouble when the region
is not set, breaking even the fallback methods of cracking the keys -
though maybe I misremember.
Post by Bernard Lang
Post by Jean-Baptiste Kempf
Some people actually use that in dvdcss?
I do.
Actually, I often managed to get the correct keys by other means, and
added them by hand in the cache. I confirm it is easier in text format.
In the two cases I had that the keys were identical or simply increasing
by one between the titles.
Post by Bernard Lang
My first question is the following. Given a title and a CSS key, is
there a reliable way (other than viewing, which is not always
adequate) to check that it is the proper key to decode that title. My
experience is that some titles will be 'decoded' (?) without fuss by
many keys, and the bad keys will produce garbage without any
noticeable protest from the decoding software (libdvdcss, not always
within VLC).
If the video is long enough you should get decoding errors quite
reliably with the wrong keys. However I believe there is no really
certain way to detect if they key is correct (if there is, we definitely
should be using it in DVDCSS, I had issues where it came up with the
wrong key, though I think they were never reproducible enough to debug,
possibly related to drive read errors).
Post by Bernard Lang
Another question is the following. Given a coded title and a decoded
one. Is it possible to check that the first is an encoded version of
the second. Is it possible to identify more easily the key ? Can that
be somewhat easier than finding the key with only the encoded version
of the title. I have met that situation in practice.
As far as I can see the most problematic step of the cracking is to
figure out what the decoded data looks like, see the function
AttackPattern in the code.
Since they key is only 40 bit cracking it is fairly trivial if you
know what some encrypted data should decrypt to.
Post by Bernard Lang
My last question concerns my DVD player. I do not wish to change
the (absent) region setting, as I have DVDs from several different
regions (some films are just not published in region 2).
Setting the region should not make anything worse when it comes
to playing DVDs from a different region as far as I know.
For most drives there are also ways to either disable RPC or
at least allowing to change the region as often as you want.
Post by Bernard Lang
Would
libdvdcss be able to discover more keys if the player were set to the
region corresponding to the DVD.
In that case it should be able to easily get all keys, just like
a proper DVD player would.
--
Après la bulle Internet, la bulle financière ...
Et bientôt la bulle des brevets
http://www.strategie.gouv.fr/system/files/noteveille81.pdf
http://www.huffingtonpost.com/brian-kahin/the-patent-bubble_b_129232.html
la gestion des catastrophes comme principe de gouvernement

***@datcha.net ,_ /\o \o/ gsm +33 6 6206 1693
http://www.datcha.net/ ^^^^^^^^^^^^^^^^^ tel +33 1 3056 1693
Je n'exprime que mon opinion - I express only my opinion
CAGED BEHIND WINDOWS or FREE WITH LINUX
Reimar Döffinger
2013-03-13 07:03:13 UTC
Permalink
Post by Bernard Lang
I understand from your reply that libdvdcss should encounter no CSS
decoding problem if the drive is set on the region of the DVD. If
that is the case, then not being able to identify a key should be a
rare event, and not such a major issue for most users ?
Yes, however not everyone may know/be able to set the region.
I think players on Linux usually neither report that nor is there a GUI for it I believe.
Post by Bernard Lang
Post by Reimar Döffinger
If the video is long enough you should get decoding errors quite
reliably with the wrong keys.
I had at least one long title that disproves that. Decoding that title
was strange in many respect. One key gave only the upper half of the
screen.
Hard to know for sure without a sample, but it might be that the startcode for the second slice was corrupted.
It still seems likely the decoder discovered the file was broken, however e.g. FFmpeg until recently had the choice between either running error concealment or reporting an error, both was not possible. And the default behaviour was to run error concealment.
Post by Bernard Lang
This is why I raised the question of whether one can reliably check
the correctness of a key. And the answer seems to be no.
Unfortunately I think nowadays checking the key for correctness is the only thing that is difficult, since the key is "only" 48 bits and thus can be brute-forced (though it might take quite a few hours, so libdvdcss probably shouldn't use any dumb brute-forcing by default).
Jean-Baptiste Kempf
2013-03-14 11:43:29 UTC
Permalink
Post by Bernard Lang
I understand from your reply that libdvdcss should encounter no CSS
decoding problem if the drive is set on the region of the DVD. If
that is the case, then not being able to identify a key should be a
rare event, and not such a major issue for most users ?
Well, to me the question is:

"Why can libdvdcss fail when no region is set?"
And can we fix that?

Best regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Jean-Baptiste Kempf
2013-02-27 07:26:27 UTC
Permalink
Post by Reimar Döffinger
The data in it can _not_ generally be restored, just try e.g. installing a new drive and dvdcss will stop working completely until the use manually configures a region.
Shouldn't we fix that, btw?
Post by Reimar Döffinger
There are also cases where titles are too short for cracking and thus only manually created key files work (which btw. speaks against the binary format, also look at e.g. libaacs, they too use text format files).
Some people actually use that in dvdcss?


Best regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Reimar Döffinger
2013-02-27 21:17:07 UTC
Permalink
Post by Jean-Baptiste Kempf
Post by Reimar Döffinger
The data in it can _not_ generally be restored, just try e.g. installing a new drive and dvdcss will stop working completely until the use manually configures a region.
Shouldn't we fix that, btw?
How? I at least wouldn't want to be responsible for code that (semi-permanently) can "break" a user's device if there is a bug, if you mean by trying to set a region automatically.
If you meant that dvdcss should be working fine without setting the region: I have no test case for that.
Which also means it might actually work mostly fine even without setting a region, I just remember lots of trouble without it, but maybe that was just due to bugs in the key cracking code...
Jean-Baptiste Kempf
2013-02-28 06:28:49 UTC
Permalink
Post by Reimar Döffinger
Post by Jean-Baptiste Kempf
Post by Reimar Döffinger
The data in it can _not_ generally be restored, just try e.g. installing a new drive and dvdcss will stop working completely until the use manually configures a region.
Shouldn't we fix that, btw?
How? I at least wouldn't want to be responsible for code that (semi-permanently) can "break" a user's device if there is a bug, if you mean by trying to set a region automatically.
I did not meant that. Of course not.
Post by Reimar Döffinger
If you meant that dvdcss should be working fine without setting the region: I have no test case for that.
We need to buy drives...

Best regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Loading...