Commit 60626f42 authored by Sam Hocevar's avatar Sam Hocevar

* modules/demux/mp4: added more comments and debug information to the DRMS

    code.
parent 2b1bac2b
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
# include <limits.h> # include <limits.h>
#endif #endif
#ifdef SYS_DARWIN #ifdef __APPLE__
# include <mach/mach.h> # include <mach/mach.h>
# include <IOKit/IOKitLib.h> # include <IOKit/IOKitLib.h>
# include <CoreFoundation/CFNumber.h> # include <CoreFoundation/CFNumber.h>
...@@ -284,6 +284,13 @@ void drms_decrypt( void *_p_drms, uint32_t *p_buffer, uint32_t i_bytes ) ...@@ -284,6 +284,13 @@ void drms_decrypt( void *_p_drms, uint32_t *p_buffer, uint32_t i_bytes )
/***************************************************************************** /*****************************************************************************
* drms_init: initialise a DRMS structure * drms_init: initialise a DRMS structure
*****************************************************************************
* Return values:
* 0: success
* -1: unimplemented
* -2: invalid argument
* -3: failed to get user key
* -4: invalid user key
*****************************************************************************/ *****************************************************************************/
int drms_init( void *_p_drms, uint32_t i_type, int drms_init( void *_p_drms, uint32_t i_type,
uint8_t *p_info, uint32_t i_len ) uint8_t *p_info, uint32_t i_len )
...@@ -296,7 +303,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -296,7 +303,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
case FOURCC_user: case FOURCC_user:
if( i_len < sizeof(p_drms->i_user) ) if( i_len < sizeof(p_drms->i_user) )
{ {
i_ret = -1; i_ret = -2;
break; break;
} }
...@@ -306,7 +313,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -306,7 +313,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
case FOURCC_key: case FOURCC_key:
if( i_len < sizeof(p_drms->i_key) ) if( i_len < sizeof(p_drms->i_key) )
{ {
i_ret = -1; i_ret = -2;
break; break;
} }
...@@ -316,7 +323,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -316,7 +323,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
case FOURCC_iviv: case FOURCC_iviv:
if( i_len < sizeof(p_drms->p_key) ) if( i_len < sizeof(p_drms->p_key) )
{ {
i_ret = -1; i_ret = -2;
break; break;
} }
...@@ -328,7 +335,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -328,7 +335,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
if( p_drms->p_name == NULL ) if( p_drms->p_name == NULL )
{ {
i_ret = -1; i_ret = -2;
} }
break; break;
...@@ -339,7 +346,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -339,7 +346,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
if( i_len < 64 ) if( i_len < 64 )
{ {
i_ret = -1; i_ret = -2;
break; break;
} }
...@@ -358,7 +365,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -358,7 +365,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
{ {
if( GetUserKey( p_drms, p_drms->p_key ) ) if( GetUserKey( p_drms, p_drms->p_key ) )
{ {
i_ret = -1; i_ret = -3;
break; break;
} }
} }
...@@ -372,7 +379,7 @@ int drms_init( void *_p_drms, uint32_t i_type, ...@@ -372,7 +379,7 @@ int drms_init( void *_p_drms, uint32_t i_type,
if( p_priv[ 0 ] != 0x6e757469 ) /* itun */ if( p_priv[ 0 ] != 0x6e757469 ) /* itun */
{ {
i_ret = -1; i_ret = -4;
break; break;
} }
...@@ -1956,7 +1963,7 @@ static int GetiPodID( int64_t *p_ipod_id ) ...@@ -1956,7 +1963,7 @@ static int GetiPodID( int64_t *p_ipod_id )
return 0; return 0;
} }
#ifdef SYS_DARWIN #ifdef __APPLE__
CFTypeRef value; CFTypeRef value;
mach_port_t port; mach_port_t port;
io_object_t device; io_object_t device;
......
/***************************************************************************** /*****************************************************************************
* drmstables.h : AES/Rijndael block cipher and miscellaneous tables * drmstables.h : AES/Rijndael block cipher and miscellaneous tables
***************************************************************************** *****************************************************************************
* Copyright (C) 2004 the VideoLAN team * Copyright (C) 2004, 2006 the VideoLAN team
* $Id$ * $Id$
* *
* Author: Jon Lech Johansen <jon-vl@nanocrew.net> * Author: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/*****************************************************************************
* p_aes_table, p_aes_encrypt, p_aes_itable, p_aes_decrypt: AES tables
*****************************************************************************
* The following tables and macros are used for the AES (Rijndael) cypher.
*****************************************************************************/
#define AES_ROR( x, n ) (((x) << (32-(n))) | ((x) >> (n))) #define AES_ROR( x, n ) (((x) << (32-(n))) | ((x) >> (n)))
#define AES_XOR_ROR( p_table, p_tmp ) \ #define AES_XOR_ROR( p_table, p_tmp ) \
...@@ -178,6 +183,12 @@ static uint32_t const p_aes_decrypt[ 256 ] = ...@@ -178,6 +183,12 @@ static uint32_t const p_aes_decrypt[ 256 ] =
0x55000000, 0x21000000, 0x0c000000, 0x7d000000 0x55000000, 0x21000000, 0x0c000000, 0x7d000000
}; };
/*****************************************************************************
* p_shuffle_xor, p_shuffle_sub, p_shuffle_add: iTMS drms v1
*****************************************************************************
* The following tables are used for the first version of the iTMS drms key
* scrambling algorithm.
*****************************************************************************/
static uint16_t const p_shuffle_xor[ 256 ] = static uint16_t const p_shuffle_xor[ 256 ] =
{ {
0x00d1, 0x0315, 0x1a32, 0x19ec, 0x1bbb, 0x1d6f, 0x14fe, 0x0e9e, 0x00d1, 0x0315, 0x1a32, 0x19ec, 0x1bbb, 0x1d6f, 0x14fe, 0x0e9e,
......
...@@ -2035,11 +2035,23 @@ static int MP4_ReadBox_drms( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -2035,11 +2035,23 @@ static int MP4_ReadBox_drms( stream_t *p_stream, MP4_Box_t *p_box )
if( p_drms_box && p_drms_box->data.p_sample_soun->p_drms ) if( p_drms_box && p_drms_box->data.p_sample_soun->p_drms )
{ {
if( drms_init( p_drms_box->data.p_sample_soun->p_drms, int i_ret = drms_init( p_drms_box->data.p_sample_soun->p_drms,
p_box->i_type, p_peek, i_read ) ) p_box->i_type, p_peek, i_read );
if( i_ret )
{ {
msg_Err( p_stream, "drms_init( %4.4s ) failed", char *psz_error;
(char *)&p_box->i_type );
switch( i_ret )
{
case -1: psz_error = "unimplemented"; break;
case -2: psz_error = "invalid argument"; break;
case -3: psz_error = "could not get user key"; break;
case -4: psz_error = "invalid user key"; break;
default: psz_error = "unknown error"; break;
}
msg_Err( p_stream, "drms_init(%4.4s) failed (%s)",
(char *)&p_box->i_type, psz_error );
drms_free( p_drms_box->data.p_sample_soun->p_drms ); drms_free( p_drms_box->data.p_sample_soun->p_drms );
p_drms_box->data.p_sample_soun->p_drms = NULL; p_drms_box->data.p_sample_soun->p_drms = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment