code.
# include <limits.h>
#endif
-#ifdef SYS_DARWIN
+#ifdef __APPLE__
# include <mach/mach.h>
# include <IOKit/IOKitLib.h>
# include <CoreFoundation/CFNumber.h>
/*****************************************************************************
* 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,
uint8_t *p_info, uint32_t i_len )
case FOURCC_user:
if( i_len < sizeof(p_drms->i_user) )
{
- i_ret = -1;
+ i_ret = -2;
break;
}
case FOURCC_key:
if( i_len < sizeof(p_drms->i_key) )
{
- i_ret = -1;
+ i_ret = -2;
break;
}
case FOURCC_iviv:
if( i_len < sizeof(p_drms->p_key) )
{
- i_ret = -1;
+ i_ret = -2;
break;
}
if( p_drms->p_name == NULL )
{
- i_ret = -1;
+ i_ret = -2;
}
break;
if( i_len < 64 )
{
- i_ret = -1;
+ i_ret = -2;
break;
}
{
if( GetUserKey( p_drms, p_drms->p_key ) )
{
- i_ret = -1;
+ i_ret = -3;
break;
}
}
if( p_priv[ 0 ] != 0x6e757469 ) /* itun */
{
- i_ret = -1;
+ i_ret = -4;
break;
}
return 0;
}
-#ifdef SYS_DARWIN
+#ifdef __APPLE__
CFTypeRef value;
mach_port_t port;
io_object_t device;
break;
}
}
- }
+ }
if( !i_ret ) break;
}
/*****************************************************************************
* drmstables.h : AES/Rijndael block cipher and miscellaneous tables
*****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004, 2006 the VideoLAN team
* $Id$
*
* Author: Jon Lech Johansen <jon-vl@nanocrew.net>
* 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_XOR_ROR( p_table, p_tmp ) \
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 ] =
{
0x00d1, 0x0315, 0x1a32, 0x19ec, 0x1bbb, 0x1d6f, 0x14fe, 0x0e9e,
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,
- p_box->i_type, p_peek, i_read ) )
+ int i_ret = drms_init( p_drms_box->data.p_sample_soun->p_drms,
+ p_box->i_type, p_peek, i_read );
+ if( i_ret )
{
- msg_Err( p_stream, "drms_init( %4.4s ) failed",
- (char *)&p_box->i_type );
+ char *psz_error;
+
+ 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 );
p_drms_box->data.p_sample_soun->p_drms = NULL;