Commit 051ce627 authored by Jon Lech Johansen's avatar Jon Lech Johansen

* ./modules/demux/mp4: DRMS support.

parent d7dce911
# $Id: AUTHORS,v 1.100 2004/01/05 12:24:51 jlj Exp $
# $Id: AUTHORS,v 1.101 2004/01/05 12:37:52 jlj Exp $
#
# The format of this file was inspired by the Linux kernel CREDITS file.
# Authors are listed alphabetically.
......@@ -198,6 +198,7 @@ D: Win32 DVD input port
D: QNX RTOS plug-in
D: MacOS X port
D: norwegian translation
D: MP4 DRMS support
S: France
N: Michel Kaempf
......
......@@ -3,4 +3,7 @@ SOURCES_mp4 = \
mp4.h \
libmp4.c \
libmp4.h \
drms.c \
drms.h \
drmstables.h \
$(NULL)
/*****************************************************************************
* drms.c : DRMS
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: drms.c,v 1.1 2004/01/05 12:37:52 jlj Exp $
*
* Author: Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#ifdef WIN32
#include <tchar.h>
#include <shlobj.h>
#include <windows.h>
#endif
#include "drms.h"
#include "drmstables.h"
#define TAOS_INIT( tmp, i ) \
memset( tmp, 0, sizeof(tmp) ); \
tmp[ i + 0 ] = 0x67452301; \
tmp[ i + 1 ] = 0xEFCDAB89; \
tmp[ i + 2 ] = 0x98BADCFE; \
tmp[ i + 3 ] = 0x10325476;
#define ROR( x, n ) (((x) << (32-(n))) | ((x) >> (n)))
static void init_ctx( uint32_t *p_ctx, uint32_t *p_input )
{
uint32_t i;
uint32_t p_tmp[ 6 ];
p_ctx[ 0 ] = sizeof(*p_input);
memset( &p_ctx[ 1 + 4 ], 0, sizeof(*p_input) * 4 );
memcpy( &p_ctx[ 1 + 0 ], p_input, sizeof(*p_input) * 4 );
p_tmp[ 0 ] = p_ctx[ 1 + 3 ];
for( i = 0; i < sizeof(p_drms_tab1)/sizeof(p_drms_tab1[ 0 ]); i++ )
{
p_tmp[ 0 ] = ROR( p_tmp[ 0 ], 8 );
p_tmp[ 5 ] = p_drms_tab2[ (p_tmp[ 0 ] >> 24) & 0xFF ]
^ ROR( p_drms_tab2[ (p_tmp[ 0 ] >> 16) & 0xFF ], 8 )
^ ROR( p_drms_tab2[ (p_tmp[ 0 ] >> 8) & 0xFF ], 16 )
^ ROR( p_drms_tab2[ p_tmp[ 0 ] & 0xFF ], 24 )
^ p_drms_tab1[ i ]
^ p_ctx[ 1 + ((i + 1) * 4) - 4 ];
p_ctx[ 1 + ((i + 1) * 4) + 0 ] = p_tmp[ 5 ];
p_tmp[ 5 ] ^= p_ctx[ 1 + ((i + 1) * 4) - 3 ];
p_ctx[ 1 + ((i + 1) * 4) + 1 ] = p_tmp[ 5 ];
p_tmp[ 5 ] ^= p_ctx[ 1 + ((i + 1) * 4) - 2 ];
p_ctx[ 1 + ((i + 1) * 4) + 2 ] = p_tmp[ 5 ];
p_tmp[ 5 ] ^= p_ctx[ 1 + ((i + 1) * 4) - 1 ];
p_ctx[ 1 + ((i + 1) * 4) + 3 ] = p_tmp[ 5 ];
p_tmp[ 0 ] = p_tmp[ 5 ];
}
memcpy( &p_ctx[ 1 + 64 ], &p_ctx[ 1 ], sizeof(*p_ctx) * 4 );
for( i = 4; i < sizeof(p_drms_tab1); i++ )
{
p_tmp[ 2 ] = p_ctx[ 1 + 4 + (i - 4) ];
p_tmp[ 0 ] = (((p_tmp[ 2 ] >> 7) & 0x01010101) * 27)
^ ((p_tmp[ 2 ] & 0xFF7F7F7F) << 1);
p_tmp[ 1 ] = (((p_tmp[ 0 ] >> 7) & 0x01010101) * 27)
^ ((p_tmp[ 0 ] & 0xFF7F7F7F) << 1);
p_tmp[ 4 ] = (((p_tmp[ 1 ] >> 7) & 0x01010101) * 27)
^ ((p_tmp[ 1 ] & 0xFF7F7F7F) << 1);
p_tmp[ 2 ] ^= p_tmp[ 4 ];
p_tmp[ 3 ] = ROR( p_tmp[ 1 ] ^ p_tmp[ 2 ], 16 )
^ ROR( p_tmp[ 0 ] ^ p_tmp[ 2 ], 8 )
^ ROR( p_tmp[ 2 ], 24 );
p_ctx[ 1 + 4 + 64 + (i - 4) ] = p_tmp[ 3 ] ^ p_tmp[ 4 ]
^ p_tmp[ 1 ] ^ p_tmp[ 0 ];
}
}
static void ctx_xor( uint32_t *p_ctx, uint32_t *p_in, uint32_t *p_out,
uint32_t p_table1[ 256 ], uint32_t p_table2[ 256 ] )
{
uint32_t i, x, y;
uint32_t p_tmp1[ 4 ];
uint32_t p_tmp2[ 4 ];
i = p_ctx[ 0 ] * 4;
p_tmp1[ 0 ] = p_ctx[ 1 + i + 24 ] ^ p_in[ 0 ];
p_tmp1[ 1 ] = p_ctx[ 1 + i + 25 ] ^ p_in[ 1 ];
p_tmp1[ 2 ] = p_ctx[ 1 + i + 26 ] ^ p_in[ 2 ];
p_tmp1[ 3 ] = p_ctx[ 1 + i + 27 ] ^ p_in[ 3 ];
i += 84;
#define XOR_ROR( p_table, p_tmp, i_ctx ) \
p_table[ (p_tmp[ y > 2 ? y - 3 : y + 1 ] >> 24) & 0xFF ] \
^ ROR( p_table[ (p_tmp[ y > 1 ? y - 2 : y + 2 ] >> 16) & 0xFF ], 8 ) \
^ ROR( p_table[ (p_tmp[ y > 0 ? y - 1 : y + 3 ] >> 8) & 0xFF ], 16 ) \
^ ROR( p_table[ p_tmp[ y ] & 0xFF ], 24 ) \
^ p_ctx[ i_ctx ]
for( x = 0; x < 1; x++ )
{
memcpy( p_tmp2, p_tmp1, sizeof(p_tmp1) );
for( y = 0; y < 4; y++ )
{
p_tmp1[ y ] = XOR_ROR( p_table1, p_tmp2, 1 + i - x + y );
}
}
for( ; x < 9; x++ )
{
memcpy( p_tmp2, p_tmp1, sizeof(p_tmp1) );
for( y = 0; y < 4; y++ )
{
p_tmp1[ y ] = XOR_ROR( p_table1, p_tmp2,
1 + i - x - ((x * 3) - y) );
}
}
for( y = 0; y < 4; y++ )
{
p_out[ y ] = XOR_ROR( p_table2, p_tmp1,
1 + i - x - ((x * 3) - y) );
}
#undef XOR_ROR
}
static void taos( uint32_t *p_buffer, uint32_t *p_input )
{
uint32_t i;
uint32_t x = 0;
uint32_t p_tmp1[ 4 ];
uint32_t p_tmp2[ 4 ];
memcpy( p_tmp1, p_buffer, sizeof(p_tmp1) );
p_tmp2[ 0 ] = ((~p_tmp1[ 1 ] & p_tmp1[ 3 ])
| (p_tmp1[ 2 ] & p_tmp1[ 1 ])) + p_input[ x ];
p_tmp1[ 0 ] = p_tmp2[ 0 ] + p_tmp1[ 0 ] + p_drms_tab_taos[ x++ ];
for( i = 0; i < 4; i++ )
{
p_tmp2[ 0 ] = ((p_tmp1[ 0 ] >> 0x19)
| (p_tmp1[ 0 ] << 0x7)) + p_tmp1[ 1 ];
p_tmp2[ 1 ] = ((~p_tmp2[ 0 ] & p_tmp1[ 2 ])
| (p_tmp1[ 1 ] & p_tmp2[ 0 ])) + p_input[ x ];
p_tmp2[ 1 ] += p_tmp1[ 3 ] + p_drms_tab_taos[ x++ ];
p_tmp1[ 3 ] = ((p_tmp2[ 1 ] >> 0x14)
| (p_tmp2[ 1 ] << 0xC)) + p_tmp2[ 0 ];
p_tmp2[ 1 ] = ((~p_tmp1[ 3 ] & p_tmp1[ 1 ])
| (p_tmp1[ 3 ] & p_tmp2[ 0 ])) + p_input[ x ];
p_tmp2[ 1 ] += p_tmp1[ 2 ] + p_drms_tab_taos[ x++ ];
p_tmp1[ 2 ] = ((p_tmp2[ 1 ] >> 0xF)
| (p_tmp2[ 1 ] << 0x11)) + p_tm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1[ 3 ]) ^ p_tmp2[ 0 ])
+ p_input[ p_table[ i ][ 1 ] ];
p_tmp2[ 1 ] += p_tmp1[ 2 ] + p_drms_tab_taos[ x++ ];
p_tmp1[ 2 ] = ((p_tmp2[ 1 ] >> 0x11)
| (p_tmp2[ 1 ] << 0xF)) + p_tmp1[ 3 ];
p_tmp2[ 1 ] = ((~p_tmp2[ 0 ] | p_tmp1[ 2 ]) ^ p_tmp1[ 3 ])
+ p_input[ p_table[ i ][ 2 ] ];
p_tmp2[ 1 ] += p_tmp1[ 1 ] + p_drms_tab_taos[ x++ ];
p_tmp1[ 1 ] = ((p_tmp2[ 1 ] << 0x15)
| (p_tmp2[ 1 ] >> 0xB)) + p_tmp1[ 2 ];
if( i < 3 )
{
p_tmp2[ 1 ] = ((~p_tmp1[ 3 ] | p_tmp1[ 1 ]) ^ p_tmp1[ 2 ])
+ p_input[ p_table[ i ][ 3 ] ];
p_tmp1[ 0 ] = p_tmp2[ 0 ] + p_tmp2[ 1 ] + p_drms_tab_taos[ x++ ];
}
}
p_buffer[ 0 ] += p_tmp2[ 0 ];
p_buffer[ 1 ] += p_tmp1[ 1 ];
p_buffer[ 2 ] += p_tmp1[ 2 ];
p_buffer[ 3 ] += p_tmp1[ 3 ];
}
static void taos_add1( uint32_t *p_buffer,
uint8_t *p_in, uint32_t i_len )
{
uint32_t i;
uint32_t x, y;
uint32_t p_tmp[ 16 ];
uint32_t i_offset = 0;
x = p_buffer[ 6 ] & 63;
y = 64 - x;
p_buffer[ 6 ] += i_len;
if( i_len < y )
{
memcpy( &((uint8_t *)p_buffer)[ 48 + x ], p_in, i_len );
}
else
{
if( x )
{
memcpy( &((uint8_t *)p_buffer)[ 48 + x ], p_in, y );
taos( &p_buffer[ 8 ], &p_buffer[ 12 ] );
i_offset = y;
i_len -= y;
}
if( i_len >= 64 )
{
for( i = 0; i < i_len / 64; i++ )
{
memcpy( p_tmp, &p_in[ i_offset ], sizeof(p_tmp) );
taos( &p_buffer[ 8 ], p_tmp );
i_offset += 64;
i_len -= 64;
}
}
if( i_len )
{
memcpy( &p_buffer[ 12 ], &p_in[ i_offset ], i_len );
}
}
}
static void taos_end1( uint32_t *p_buffer, uint32_t *p_out )
{
uint32_t x, y;
x = p_buffer[ 6 ] & 63;
y = 63 - x;
((uint8_t *)p_buffer)[ 48 + x++ ] = 128;
if( y < 8 )
{
memset( &((uint8_t *)p_buffer)[ 48 + x ], 0, y );
taos( &p_buffer[ 8 ], &p_buffer[ 12 ] );
y = 64;
x = 0;
}
memset( &((uint8_t *)p_buffer)[ 48 + x ], 0, y );
p_buffer[ 26 ] = p_buffer[ 6 ] * 8;
p_buffer[ 27 ] = p_buffer[ 6 ] >> 29;
taos( &p_buffer[ 8 ], &p_buffer[ 12 ] );
memcpy( p_out, &p_buffer[ 8 ], sizeof(*p_out) * 4 );
}
static void taos_add2( uint32_t *p_buffer, uint8_t *p_in, uint32_t i_len )
{
uint32_t i, x;
uint32_t p_tmp[ 16 ];
x = (p_buffer[ 0 ] / 8) & 63;
i = p_buffer[ 0 ] + i_len * 8;
if( i < p_buffer[ 0 ] )
{
p_buffer[ 1 ] += 1;
}
p_buffer[ 0 ] = i;
p_buffer[ 1 ] += i_len >> 29;
for( i = 0; i < i_len; i++ )
{
((uint8_t *)p_buffer)[ 24 + x++ ] = p_in[ i ];
if( x != 64 )
continue;
memcpy( p_tmp, &p_buffer[ 6 ], sizeof(p_tmp) );
taos( &p_buffer[ 2 ], p_tmp );
}
}
static void taos_add2e( uint32_t *p_buffer, uint32_t *p_in, uint32_t i_len )
{
uint32_t i, x, y;
uint32_t p_tmp[ 32 ];
if( i_len )
{
for( x = i_len; x; x -= y )
{
y = x > 32 ? 32 : x;
for( i = 0; i < y; i++ )
{
p_tmp[ i ] = U32_AT(&p_in[ i ]);
}
}
}
taos_add2( p_buffer, (uint8_t *)p_tmp, i_len * sizeof(p_tmp[ 0 ]) );
}
static void taos_end2( uint32_t *p_buffer )
{
uint32_t x;
uint32_t p_tmp[ 16 ];
p_tmp[ 14 ] = p_buffer[ 0 ];
p_tmp[ 15 ] = p_buffer[ 1 ];
x = (p_buffer[ 0 ] / 8) & 63;
taos_add2( p_buffer, p_drms_tab_tend, 56 - x );
memcpy( p_tmp, &p_buffer[ 6 ], 56 );
taos( &p_buffer[ 2 ], p_tmp );
memcpy( &p_buffer[ 22 ], &p_buffer[ 2 ], sizeof(*p_buffer) * 4 );
}
static void taos_add3( uint32_t *p_buffer, uint8_t *p_key, uint32_t i_len )
{
uint32_t x, y;
uint32_t i = 0;
x = (p_buffer[ 4 ] / 8) & 63;
p_buffer[ 4 ] += i_len * 8;
if( p_buffer[ 4 ] < i_len * 8 )
p_buffer[ 5 ] += 1;
p_buffer[ 5 ] += i_len >> 29;
y = 64 - x;
if( i_len >= y )
{
memcpy( &((uint8_t *)p_buffer)[ 24 + x ], p_key, y );
taos( p_buffer, &p_buffer[ 6 ] );
i = y;
y += 63;
if( y < i_len )
{
for( ; y < i_len; y += 64, i += 64 )
{
taos( p_buffer, (uint32_t *)&p_key[y - 63] );
}
}
else
{
x = 0;
}
}
memcpy( &((uint8_t *)p_buffer)[ 24 + x ], &p_key[ i ], i_len - i );
}
static int taos_osi( uint32_t *p_buffer )
{
int i_ret = 0;
#ifdef WIN32
HKEY i_key;
uint32_t i;
DWORD i_size;
DWORD i_serial;
LPBYTE p_reg_buf;
static LPCTSTR p_reg_keys[ 3 ][ 2 ] =
{
{
_T("HARDWARE\\DESCRIPTION\\System"),
_T("SystemBiosVersion")
},
{
_T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"),
_T("ProcessorNameString")
},
{
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"),
_T("ProductId")
}
};
taos_add1( p_buffer, "cache-control", 13 );
taos_add1( p_buffer, "Ethernet", 8 );
GetVolumeInformation( _T("C:\\"), NULL, 0, &i_serial,
NULL, NULL, NULL, 0 );
taos_add1( p_buffer, (uint8_t *)&i_serial, 4 );
for( i = 0; i < sizeof(p_reg_keys)/sizeof(p_reg_keys[ 0 ]); i++ )
{
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, p_reg_keys[ i ][ 0 ],
0, KEY_READ, &i_key ) == ERROR_SUCCESS )
{
if( RegQueryValueEx( i_key, p_reg_keys[ i ][ 1 ],
NULL, NULL, NULL,
&i_size ) == ERROR_SUCCESS )
{
p_reg_buf = malloc( i_size );
if( p_reg_buf != NULL )
{
if( RegQueryValueEx( i_key, p_reg_keys[ i ][ 1 ],
NULL, NULL, p_reg_buf,
&i_size ) == ERROR_SUCCESS )
{
taos_add1( p_buffer, (uint8_t *)p_reg_buf,
i_size );
}
free( p_reg_buf );
}
}
RegCloseKey( i_key );
}
}
#else
i_ret = -1;
#endif
return( i_ret );
}
static int get_sci_data( uint32_t p_sci[ 11 ][ 4 ] )
{
int i_ret = -1;
#ifdef WIN32
HANDLE i_file;
DWORD i_size, i_read;
TCHAR p_path[ MAX_PATH ];
TCHAR *p_filename = _T("\\Apple Computer\\iTunes\\SC Info\\SC Info.sidb");
if( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA,
NULL, 0, p_path ) ) )
{
_tcsncat( p_path, p_filename, min( _tcslen( p_filename ),
(MAX_PATH-1) - _tcslen( p_path ) ) );
i_file = CreateFile( p_path, GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, NULL );
if( i_file != INVALID_HANDLE_VALUE )