[libdvdcss-devel] [PATCH 08/12] css: Replace some magic numbers by proper #defines

Jean-Baptiste Kempf jb at videolan.org
Tue Nov 11 14:38:38 CET 2014


OK.

On 11 Nov, Diego Biurrun wrote :
> ---
>  src/css.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/css.c b/src/css.c
> index f5eac5e..d5585ce 100644
> --- a/src/css.c
> +++ b/src/css.c
> @@ -1135,8 +1135,11 @@ static void DecryptTitleKey( dvd_key p_disc_key, dvd_key p_titlekey )
>   * This function uses a big amount of memory to crack the disc key from the
>   * disc key hash, if player keys are not available.
>   *****************************************************************************/
> +#define K1TABLESIZE  65536
>  #define K1TABLEWIDTH 10
>  
> +#define BIGTABLESIZE 16777216
> +
>  /*
>   * Simple function to test if a candidate key produces the given hash
>   */
> @@ -1175,7 +1178,7 @@ static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key )
>       */
>  
>      /* initialize lookup tables for k[1] */
> -    K1table = calloc( 65536, K1TABLEWIDTH );
> +    K1table = calloc( K1TABLESIZE, K1TABLEWIDTH );
>      if( K1table == NULL )
>      {
>          return -1;
> @@ -1206,7 +1209,7 @@ static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key )
>      }
>  
>      /* Initializing our really big table */
> -    BigTable = calloc( 16777216, sizeof(*BigTable) );
> +    BigTable = calloc( BIGTABLESIZE, sizeof(*BigTable) );
>      if( BigTable == NULL )
>      {
>          free( K1table );
> @@ -1217,7 +1220,7 @@ static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key )
>  
>      print_debug( dvdcss, "initializing the big table" );
>  
> -    for( i = 0 ; i < 16777216 ; i++ )
> +    for( i = 0 ; i < BIGTABLESIZE ; i++ )
>      {
>          tmp = (( i + i ) & 0x1fffff0 ) | 0x8 | ( i & 0x7 );
>  
> @@ -1238,7 +1241,7 @@ static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key )
>       */
>      tmp5 = p_disc_key[0] ^ p_css_tab1[ p_disc_key[1] ];
>  
> -    for( nStepA = 0 ; nStepA < 65536 ; nStepA ++ )
> +    for( nStepA = 0 ; nStepA < K1TABLESIZE ; nStepA ++ )
>      {
>          lfsr1a = 0x100 | ( nStepA >> 8 );
>          lfsr1b = nStepA & 0xff;
> -- 
> 2.1.0
> 
> _______________________________________________
> libdvdcss-devel mailing list
> libdvdcss-devel at videolan.org
> https://mailman.videolan.org/listinfo/libdvdcss-devel

-- 
With my kindest regards,

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


More information about the libdvdcss-devel mailing list