CN107800530B - 一种sms4的s盒掩码方法 - Google Patents
一种sms4的s盒掩码方法 Download PDFInfo
- Publication number
- CN107800530B CN107800530B CN201711248215.5A CN201711248215A CN107800530B CN 107800530 B CN107800530 B CN 107800530B CN 201711248215 A CN201711248215 A CN 201711248215A CN 107800530 B CN107800530 B CN 107800530B
- Authority
- CN
- China
- Prior art keywords
- mask
- rand
- calculating
- box
- sms4
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 30
- 230000000873 masking effect Effects 0.000 claims abstract description 15
- 238000004364 calculation method Methods 0.000 claims abstract description 11
- 238000006243 chemical reaction Methods 0.000 claims description 6
- 238000012795 verification Methods 0.000 claims description 6
- 230000009467 reduction Effects 0.000 claims description 5
- 238000004422 calculation algorithm Methods 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 238000002347 injection Methods 0.000 description 3
- 239000007924 injection Substances 0.000 description 3
- 230000004075 alteration Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/002—Countermeasures against attacks on cryptographic mechanisms
- H04L9/003—Countermeasures against attacks on cryptographic mechanisms for power analysis, e.g. differential power analysis [DPA] or simple power analysis [SPA]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0618—Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
本发明公开了一种SMS4的S盒掩码方法,其包含,设x为S盒的输入,为提高安全性加入随机掩码mask,所述的SMS4的S盒掩码方法包含以下步骤:S1、计算L1(mask),若为0,则重新选择掩码值mask直到L1(mask)的计算结果不为0;S2、计算data1=L1(x+mask)+c1;S3、对线性部分进行布尔掩码,对模逆部分I进行带假密钥的乘法掩码,计算I(data1)=I(L1(x)+L1(mask)),得到data2=I(L1(x))+L1(mask);S4、计算Sbox(x)=L1(data2)+L1(L1(mask))+c1。其优点是:可以实现SMS4的全掩码,并且比查表法所占面积较现有技术更小,而且也易于实现。
Description
技术领域
本发明涉及一种SMS4的S盒掩码方法。
背景技术
SMS4分组加密算法是中国无线标准中使用的分组加密算法,在2012年已经被国家商用密码管理局确定为国家密码行业标准。
SMS4的S盒是整个SMS4的非线性环节,S盒保证了整个算法的安全性,目前,在标准算法文档中只给出了S盒的查找表,并没有给出S盒的代数表达式,但是,已经有相关论文分析出了S盒在GF(28)的代数表达式:
其中:L1(x)=A1*x+c1;I为在GF(28)的模逆;
不可约多项式为:f(x)=x8+x7+x6+x5+x4+x2+1。
目前SMS4在S盒的实现上主要采用固定掩码方式,而固定掩码缺点是显而易见的:首先掩码值是固定的,因为一张表对应一个固定掩码值,所以采用全掩码方案时,查表法所占面积会很大。
发明内容
本发明的目的在于提供一种SMS4的S盒掩码方法,可以实现SMS4的全掩码,并且查表法所占面积较现有技术更小,而且也易于实现。
为了达到上述目的,本发明通过以下技术方案实现:
一种SMS4的S盒掩码方法,其特征是,设x为S盒的输入,为提高安全性加入随机掩码mask,所述的SMS4的S盒掩码方法包含以下步骤:
S1、计算L1(mask),若为0,则重新选择掩码值mask直到L1(mask)的计算结果不为0;
S2、计算data1=L1(x+mask)+c1;
S3、对线性部分进行布尔掩码,对模逆部分I进行带伪轮密钥FKEY的乘法掩码,计算I(data1)=I(L1(x)+L1(mask)),得到data2=I(L1(x))+L1(mask);
S4、计算Sbox(x)=L1(data2)+L1(L1(mask))+c1。
上述的SMS4的S盒掩码方法,其中,所述的步骤S3中通过乘法掩码与FKEY校验对于模逆部分I的掩码的过程具体包含:
S30、设计算模逆输入为x+rand,输出为x-1+rand,rand=L1(mask),rand为输入时加入的布尔掩码;
S31、计算(x+rand)×rand;
S32、计算(x+rand)×rand+rand2=x×rand;
S33、向后级电路传递x-1×rand-1;
S34、计算x-1×rand-1+1;
S35、计算(x-1×rand-1+1)×rand=x-1+rand。
上述的SMS4的S盒掩码方法,其中:所述的步骤S33中向后级电路传递x-1×rand-1前还包含FKEY校验,具体的:
判断x是否为0,如果不为0,运算x×rand的模逆值,并校验,如果校验出错,则报警;如果x为0,运算伪轮密钥FKEY的模逆值,并校验,如果校验出错,则报警。
上述的SMS4的S盒掩码方法,其中:
所述步骤S3中所运算的模逆通过有限域降域运算,从而降低硬件设计复杂度。
上述的SMS4的S盒掩码方法,其中:
所述的有限域降域运算是通过GF(28)转化为GF((24)2)上运算,再通过GF(24)转化为GF((22)2)上运算来实现的。
上述的SMS4的S盒掩码方法,其中:所述S盒在GF(28)的代数表达式为:
L1(x)=A1*x+c1;
I为在GF(28)的模逆;
不可约多项式为:f(x)=x8+x7+x6+x5+x4+x2+1。
本发明与现有技术相比具有以下优点:
1、可以实现SMS4的全掩码,并且查表法所占面积较现有技术更小,而且也易于实现;
2、本发明中的乘法掩码可以抵御零值攻击。
附图说明
图1为本发明的方法流程图;
图2为本发明的方法中对模逆部分的掩码过程的流程图。
具体实施方式
以下结合附图,通过详细说明一个较佳的具体实施例,对本发明做进一步阐述。
其中:L1(x)=A1*x+c1;I(inversion)为在GF(28)的模逆;
不可约多项式为:f(x)=x8+x7+x6+x5+x4+x2+1。
从S盒的上述代数表达式来看,除模逆部分,其余S盒的都是线性部分,完全可以采取异或掩码。
如图1所示,基于上述条件,本发明提出一种SMS4的S盒掩码方法,设x为S盒的输入,为提高安全性加入随机掩码mask,所述的SMS4的S盒掩码方法包含以下步骤:
S1、计算L1(mask),若为0,则重新选择掩码值mask直到L1(mask)的计算结果不为0;
S2、计算data1=L1(x+mask)+c1;
S3、对线性部分进行布尔掩码,对模逆部分I进行带伪轮密钥FKEY的乘法掩码,乘法掩码时同时可以进行FKEY校验,计算I(data1)=I(L1(x)+L1(mask)),得到data2=I(L1(x))+L1(mask);
S4、计算Sbox(x)=L1(data2)+L1(L1(mask))+c1。
如图2所示,所述的步骤S3中通过乘法掩码与FKEY校验对于模逆部分I的掩码的过程具体包含:
S30、设计算模逆输入为x+rand,输出为x-1+rand,rand=L1(mask),rand(randomnumber随机数)为输入时加入的布尔掩码;
S31、计算(x+rand)×rand;
S32、计算(x+rand)×rand+rand2=x×rand;
S33、向后级电路传递x-1×rand-1;在这之前,本实施例中还设置了校验过程以抵御零值攻击,可以通过判断x是否为0,如果不为0,运算x×rand的模逆值,并校验,如果校验出错,则报警;如果x为0,运算伪轮密钥FKEY(fake key)的模逆值,并校验,如果校验出错,则报警;所述的校验方式可以采用计算2次来比较结果或者以正向算模逆得到结果再将模拟结果与此时的输入值模乘得1来进行校验等等;
S34、计算x-1×rand-1+1;
S35、计算(x-1×rand-1+1)×rand=x-1+rand。
上述乘法掩码之所以可以抵御零值攻击,是因为当x=0时,rand为任何值其结果都为0,简单来讲,就是如果攻击者可以选择明文使x为0,那么可以根据明文来推取轮密钥,而加入伪轮密钥FKEY操作就可以避免攻击者在功耗分析上得到x为0的情况,而又由于伪轮密钥FKEY操作并不实际参与后级运算,那么为了防止攻击者通过注入故障(如果故障注入成功并且结果正确,那么就是伪轮密钥FKEY运算)来分析伪轮密钥FKEY运算,就要通过校验来抵御注入攻击分析。
所述步骤S3中所运算的模逆是先通过GF(28)转化为GF((24)2)上运算,再通过GF(24)转化为GF((22)2)上运算,即通过有限域降域运算从而降低硬件设计复杂度。
实施例
以S盒的输入x=10101010b(0xaa),掩码值mask=01010101b(0x55)为例:
计算L1(mask)=01111001b(0x79),此L1(mask)即为S30的rand,此步骤为计算S1
计算data1=L1(x+mask)+c1=00101100b(0x2c),此步骤为计算S2;
计算data1×L1(mask)=11111111b(0xff),此步骤为计算S31;
计算(L1(mask))^2=01110010b(0x72);
计算data1×L1(mask)+(L1(mask))^2=11011100b(0xdc),此步骤为计算S32;
计算(data1×L1(mask)+(L1(mask))^2)^(-1)=10111111b(0xdf),此步骤为S33,需判断L1(x)是否为0,若为0则进行伪轮密钥FKEY操作来干扰功耗,同时本步骤结果直接输出L1(mask);
计算
(data1×L1(mask)+(L1(mask))^2)^(-1)+1=10111110b(0xde),此步骤为计算S34;
计算((data1×L1(mask)+(L1(mask))^2)^(-1)+1)×L1(mask),即data2=00110010b(0x32),此步骤为计算S35;
计算L1(L1(mask))=01110001b(0x71);
计算L1(data2)=10000001b(0x81);
计算Sbox(x)=L1(L1(mask))+L1(data2)+c1=00100011b(0x23),此步骤为计算S4.
可以得到,当输入x=10101010b(0xaa)时,S盒的输出Sbox(x)=00100011b(0x23)。
尽管本发明的内容已经通过上述优选实施例作了详细介绍,但应当认识到上述的描述不应被认为是对本发明的限制。在本领域技术人员阅读了上述内容后,对于本发明的多种修改和替代都将是显而易见的。因此,本发明的保护范围应由所附的权利要求来限定。
Claims (4)
1.一种SMS4的S盒掩码方法,其特征在于,设x为S盒的输入,为提高安全性加入随机掩码mask,所述的SMS4的S盒掩码方法包含以下步骤:
S1、计算L1(mask),若为0,则重新选择掩码值mask直到L1(mask)的计算结果不为0;其中:L1(x)=A1*x+c1;
S2、计算data1=L1(x+mask)+c1;
S3、对线性部分进行布尔掩码;对模逆部分I进行带伪轮密钥FKEY的乘法掩码,具体包含:
S30、设计算模逆输入为x+rand,输出为x-1+rand,rand=L1(mask),rand为输入时加入的布尔掩码;
S31、计算(x+rand)×rand;
S32、计算(x+rand)×rand+rand2=x×rand;
S33、进行FKEY校验,具体的:
判断x是否为0,如果不为0,运算x×rand的模逆值,并校验,如果校验出错,则报警;如果x为0,运算伪轮密钥FKEY的模逆值,并校验,如果校验出错,则报警;
向后级电路传递x-1×rand-1;
S34、计算x-1×rand-1+1;
S35、计算(x-1×rand-1+1)×rand=x-1+rand;
计算I(data1)=I(L1(x)+L1(mask)),得到data2=I(L1(x))+L1(mask);
I为在GF(28)的模逆,不可约多项式为:f(x)=x8+x7+x6+x5+x4+x2+1;
S4、计算Sbox(x)=L1(data2)+L1(L1(mask))+c1。
2.如权利要求1所述的SMS4的S盒掩码方法,其特征在于:
所述步骤S3中所运算的模逆通过有限域降域运算,从而降低硬件设计复杂度。
3.如权利要求2所述的SMS4的S盒掩码方法,其特征在于:
所述的有限域降域运算是通过GF(28)转化为GF((24)2)上运算,再通过GF(24)转化为GF((22)2)上运算来实现的。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711248215.5A CN107800530B (zh) | 2017-11-28 | 2017-11-28 | 一种sms4的s盒掩码方法 |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711248215.5A CN107800530B (zh) | 2017-11-28 | 2017-11-28 | 一种sms4的s盒掩码方法 |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN107800530A CN107800530A (zh) | 2018-03-13 |
| CN107800530B true CN107800530B (zh) | 2020-09-18 |
Family
ID=61538129
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201711248215.5A Active CN107800530B (zh) | 2017-11-28 | 2017-11-28 | 一种sms4的s盒掩码方法 |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN107800530B (zh) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111931176B (zh) * | 2020-09-29 | 2021-01-22 | 网御安全技术(深圳)有限公司 | 防御侧信道攻击的方法、装置及可读存储介质 |
| CN116866038B (zh) * | 2023-07-12 | 2024-06-11 | 北京兆讯恒达技术有限公司 | 动态掩码加密方法及动态掩码加密装置 |
| CN120454976B (zh) * | 2025-05-14 | 2025-12-26 | 湖北大学 | 一种Bridge3,4,5结构S盒的2共享掩码方法 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103888247A (zh) * | 2014-03-10 | 2014-06-25 | 深圳华视微电子有限公司 | 抵抗差分功耗分析攻击的数据处理系统及其数据处理方法 |
| US20160248580A1 (en) * | 2007-03-28 | 2016-08-25 | Intel Corporation | Flexible architecture and instruction for advanced encryption standard (aes) |
| CN106357380A (zh) * | 2016-10-11 | 2017-01-25 | 中国信息安全测评中心 | Sm4算法的掩码方法及装置 |
| CN106788974A (zh) * | 2016-12-22 | 2017-05-31 | 深圳国微技术有限公司 | 掩码s盒、分组密钥计算单元、装置及对应的构造方法 |
| CN106936569A (zh) * | 2017-05-18 | 2017-07-07 | 北京万协通信息技术有限公司 | 一种抗功耗攻击的sm4算法掩码s盒的实现方法 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2009074728A1 (fr) * | 2007-12-13 | 2009-06-18 | Oberthur Technologies | Procede de traitement cryptographique de donnees, notamment a l'aide d'une boite s, dispositif et programme associes |
| CN104852795B (zh) * | 2015-05-05 | 2018-03-30 | 国家密码管理局商用密码检测中心 | 一种轮输出为布尔掩码的zuc序列密码算法掩码防护方法 |
| CN105049194B (zh) * | 2015-06-01 | 2018-05-08 | 北京时代民芯科技有限公司 | 一种流水线结构的sm4算法实现系统 |
-
2017
- 2017-11-28 CN CN201711248215.5A patent/CN107800530B/zh active Active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20160248580A1 (en) * | 2007-03-28 | 2016-08-25 | Intel Corporation | Flexible architecture and instruction for advanced encryption standard (aes) |
| CN103888247A (zh) * | 2014-03-10 | 2014-06-25 | 深圳华视微电子有限公司 | 抵抗差分功耗分析攻击的数据处理系统及其数据处理方法 |
| CN106357380A (zh) * | 2016-10-11 | 2017-01-25 | 中国信息安全测评中心 | Sm4算法的掩码方法及装置 |
| CN106788974A (zh) * | 2016-12-22 | 2017-05-31 | 深圳国微技术有限公司 | 掩码s盒、分组密钥计算单元、装置及对应的构造方法 |
| CN106936569A (zh) * | 2017-05-18 | 2017-07-07 | 北京万协通信息技术有限公司 | 一种抗功耗攻击的sm4算法掩码s盒的实现方法 |
Non-Patent Citations (1)
| Title |
|---|
| "一种专用指令集安全处理器的架构设计与VLSI实现";韩林,等,;《小型微型计算机系统 2009年4月第4期》;20090430;第3-4部分 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN107800530A (zh) | 2018-03-13 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Pereira et al. | Leakage-resilient authentication and encryption from symmetric cryptographic primitives | |
| Renauld et al. | Algebraic side-channel attacks on the AES: Why time also matters in DPA | |
| Rivain et al. | Higher-order masking and shuffling for software implementations of block ciphers | |
| Moradi et al. | Correlation-enhanced power analysis collision attack | |
| US9166789B2 (en) | Cryptographic processing apparatus | |
| US20200313850A1 (en) | Method and apparatus for implementing a white-box cipher | |
| CN107800530B (zh) | 一种sms4的s盒掩码方法 | |
| CN104639312B (zh) | 一种des算法抗能量攻击的方法及装置 | |
| Crocetti et al. | A simulated approach to evaluate side-channel attack countermeasures for the Advanced Encryption Standard | |
| Vliegen et al. | Maximizing the throughput of threshold-protected AES-GCM implementations on FPGA | |
| Yoshikawa et al. | Electromagnetic analysis attack for a lightweight block cipher TWINE | |
| Bokhari et al. | Cryptanalysis techniques for stream cipher: a survey | |
| Mazumdar et al. | Design for security of block cipher S-Boxes to resist differential power attacks | |
| Ming et al. | Optimizing higher-order correlation analysis against inner product masking scheme | |
| Kamoun et al. | Experimental Implementation of 2ODPA attacks on AES design with flash-based FPGA Technology | |
| US9083489B2 (en) | Block encryption method and apparatus | |
| Jin et al. | Breaking real-world COTS USIM cards with unknown side-channel countermeasures | |
| Zhou et al. | An improved AES masking method smartcard implementation for resisting DPA attacks | |
| Moradi et al. | Comprehensive evaluation of AES dual ciphers as a side-channel countermeasure | |
| Liu et al. | A real-time attack on the GMR-2 encryption algorithm in satellite phones | |
| Tang et al. | Power analysis based reverse engineering on the secret round function of block ciphers | |
| Kawai et al. | Practical power analysis on KCipher-2 software on low-end microcontrollers | |
| Li et al. | Reduction in the number of fault injections for blind fault attack on SPN block ciphers | |
| Benhadjyoussef et al. | A fault detection AES scheme for resource-constrained embedded systems | |
| Belaíd et al. | Differential power analysis of HMAC SHA-1 and HMAC SHA-2 in the hamming weight model |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| CB02 | Change of applicant information | ||
| CB02 | Change of applicant information |
Address after: 201203 No. 12, Lane 647, Songtao Road, China (Shanghai) Free Trade Pilot Area, Pudong New Area, Shanghai Applicant after: Juchen Semiconductor Co., Ltd. Address before: 201203 No. 12, Lane 647, Songtao Road, Zhangjiang High-tech Park, Pudong New Area, Shanghai Applicant before: Giantec Semiconductor Inc. |
|
| GR01 | Patent grant | ||
| GR01 | Patent grant |