WinRAR加密算法

搜了一下,这方面的资料似乎很少,去了几个学术数据库也所获甚少。或许是我用的关键词不对?

把下面这篇文章整理了一下,作为资料先放在这里。

winrar密码无法秒破的个人看法 by 大漠雪花

用伪代码写算法吧:

加密:

CRC[] = CRC32( input_data[] );
pack_data[] = lz77_en( input_data[] );
salt = random string;  //  8 byte
( key, initVector ) = f( SHA-1( password+salt ) ); // (16 byte , 16 byte)
pack_block[ 1 ... n ] = divide( pack_data() , 16); // 16 byte
pack_block[1] ^= initVector;
encryt_block[1] = AES( pack_block[1] , key );
for ( i = 2; i <= n ; i++ )
{
    pack_block[i] ^= encrypt_block[i - 1];
    encrypt_block[i] = AES( pack_block[i] , key);
}
encrypt_data[] = combine( encrypt_block[1 ... n]);
output(CRC[], salt , encrypt_data[]);

解密:

input( password2 );
( key2, initVector2 ) = f( SHA-1( password2+salt ) ); // (16 byte , 16 byte)
encrypt_block[ 1 ... n ] = divide( encry_data() , 16); // 16 byte
pack_block[1] = AES( encrypt_block[1], key2 );
pack_block[1] ^= initVector2;
for ( i = 2; i <= n ; i++ )
{
    pack_block[i] = AES( encrypt_block[i] , key2 );
    pack_block[i] ^= encrypt_block[i - 1];
}
pack_data[] = combine( pack_block[1 ... n]);
output_data[] = lz77_de (pack_data);
if( CRC[] == CRC32( output_data[] ) )
    return SUCCESS;

关于攻击的文章,目前只看到一篇:

Gary S.-W. Yeo , Raphael C.-W. Phan . On the Security of the WinRAR Encryption Method . ISC 2005, LNCS 3650, pp. 402–416, 2005

2006年他们发了一篇题为On the Security of the WinRAR Encryption Feature的文章,内容大同小异。

最后,查看真正的实现代码,当然还是得去作者的开源项目里看了:

unrarlib:http://www.unrarlib.org/

Leave a Reply

Your email address will not be published. Required fields are marked *