软件名称:WinRAR
![svg-20 svg-20](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
WinRAR-压缩软件使用了基于ECC的签名算法来生成 rarreg.key
文件,其使用的签名算法是中国SM2数字签名算法的变体。与各种标准ECDSA不同的是,xxx使用的椭圆曲线是一个基于复合域 上的曲线。
1. 复合域
![svg-21 svg-21](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
基域 采用标准基(多项式基)来表达,采用的不可约多项式为:
![svg-22 svg-22](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-23 svg-23](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
各项系数全部位于 。设基域的标准基为:
![svg-24 svg-24](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-21 svg-21](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-25 svg-25](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
则位于基域 上的元素 可以用如下方式表达:
![svg-26 svg-26](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-20 svg-20](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
复合域 的不可约多项式为:
![svg-27 svg-27](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-21 svg-21](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
各项系数全部位于 。设复合域的标准基为:
![svg-28 svg-28](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-20 svg-20](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-29 svg-29](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
则位于复合域 上的元素 可以用如下方式表达:
![svg svg](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-1 svg-1](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-20 svg-20](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-29 svg-29](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
为了方便表述我们用255比特的大数 来表示位于复合域 上的元素 。它们的对应关系为:
![svg-2 svg-2](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
2. 复合域 上的椭圆曲线
曲线方程为:
![svg-3 svg-3](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-4 svg-4](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
基点 为:
![svg-5 svg-5](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-4 svg-4](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-6 svg-6](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
基点 的阶 为:
![svg-7 svg-7](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
3. 消息哈希算法
![svg-8 svg-8](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
设长度为 的消息为:
![svg-9 svg-9](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-10 svg-10](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
则消息 的SHA1值为:
![svg-11 svg-11](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-12 svg-12](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-13 svg-13](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
其中 为SHA1算法输出时的5个状态值;将这5个状态值按照大端字节序依次输出,即为的SHA1哈希值 。
![svg-14 svg-14](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
WinRAR-压缩软件在做完SHA1计算后,采用大数 作为ECC签名时消息的哈希:
![svg-15 svg-15](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
4. ECC签名算法
![svg-16 svg-16](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-17 svg-17](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
设私钥为 ,公钥为 ,即:
![svg-18 svg-18](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-14 svg-14](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-19 svg-19](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
消息哈希为 ,则签名 为:
- 生成随机数 ,满足 。
- 计算 其中 表示取 的X坐标,同时将X坐标从 转换为大数。若 或者 则回到步骤1。
- 计算 若 则回到步骤1。
- 输出 。
5. WinRAR压缩软件的私钥生成算法
![svg-8 svg-8](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
该算法会利用长度为 的数据
![svg.latex_ WinRAR- 压缩软件的注册算法](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg-16 svg-16](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
来生成私钥 。
- 设6个32位整数为 ,则有
- 令 。
- 如果 则计算 的SHA1值,并将状态值 赋值给 :否则,即 时,令:
- 把 作为计数器,自增1。计算SHA1值:取 的低16位并记为 。
- 步骤4再重复14次。
- 重复执行完后会得到 ,则输出私钥
6. WinRAR-压缩软件的公钥和私钥
![svg-16 svg-16](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
xxx压缩软件的私钥 为:
![svg.latex_-1 WinRAR- 压缩软件的注册算法](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
![svg.latex_-2 WinRAR- 压缩软件的注册算法](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
该私钥是通过算法5生成的,其中数据 的长度为0。
![svg-17 svg-17](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
公钥 为:
![svg.latex_-3 WinRAR- 压缩软件的注册算法](https://stgod.com/wp-content/themes/suntao/img/blank.gif)
7. 授权文件"rarreg.key"的生成
授权文件的生成需要两个参数:
- 用户名的ANSI字符串,不包括null-terminator;记为
- 授权类型的ANSI字符串,不包括null-terminator;记为
rarreg.key
的生成算法如下:
- 使用用户名 通过算法5计算出私钥 以及公钥 ,并将公钥 按照SM2压缩公钥格式以Hex字符串(ASCII编码)的形式输出。得到的Hex字符串记为临时值 。 的长度应该为64;若长度不足,则在前面补字符
'0'
,直到长度为64。 - 令字符串 为
- 使用 通过算法5计算出私钥 以及公钥 ,并将公钥 按照SM2压缩公钥格式以Hex字符串(ASCII编码)的形式输出。得到的Hex字符串记为 。 的长度应该为64;若长度不足,则在前面补字符
'0'
,直到长度为64。 - 令字符串 为
- 对授权类型 使用算法4得到签名 ,其中私钥见第6节。要求 和 的长度都不得超过240比特,否则重复该步骤。
- 将 和 以16进制形式输出(无
"0x"
前缀),分别记为 和 。若长度不满60,则在前面补字符'0'
,直到长度为60。 - 令字符串 为
- 令字符串 为对 使用算法4得到签名 ,其中私钥见第6节。要求 和 的长度都不得超过240比特,否则重复该步骤。
- 将 和 以16进制形式输出(无
"0x"
前缀),分别记为 和 。若长度不满60,则在前面补字符'0'
,直到长度为60。 - 令字符串 为
- 对计算CRC32值,最终校验和为CRC32值的反。将校验和以10进制形式输出,若长度不满10,则在前面补字符
'0'
,直到长度为10,记为 。 - 令字符串 为
- 格式化输出。
转载请注明出处:https://stgod.com/4265/