WO2023151171A1 - 抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置 - Google Patents

抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置 Download PDF

Info

Publication number
WO2023151171A1
WO2023151171A1 PCT/CN2022/085702 CN2022085702W WO2023151171A1 WO 2023151171 A1 WO2023151171 A1 WO 2023151171A1 CN 2022085702 W CN2022085702 W CN 2022085702W WO 2023151171 A1 WO2023151171 A1 WO 2023151171A1
Authority
WO
WIPO (PCT)
Prior art keywords
parameter
random number
value
register
ciphertext
Prior art date
Application number
PCT/CN2022/085702
Other languages
English (en)
French (fr)
Inventor
王伟
付裕
林璟锵
宋利
王琼霄
Original Assignee
中国科学院信息工程研究所
中国科学院数据与通信保护研究教育中心
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中国科学院信息工程研究所, 中国科学院数据与通信保护研究教育中心 filed Critical 中国科学院信息工程研究所
Priority to US18/024,851 priority Critical patent/US20230254160A1/en
Publication of WO2023151171A1 publication Critical patent/WO2023151171A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • H04L63/0435Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply symmetric encryption, i.e. same key used for encryption and decryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/30Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy
    • H04L9/3066Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy involving algebraic varieties, e.g. elliptic or hyper-elliptic curves
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures

Definitions

  • the invention belongs to the technical field of cryptography, and proposes an elliptic curve digital signature calculation method and device resistant to memory information leakage attacks, which provide protection for keys and effectively ensure the practicability of cryptographic algorithms.
  • Cryptographic software systems are widely used in various computer and network applications to provide protection for data security. But cryptographic software doesn't provide proprietary protection schemes for keys. The key is the prerequisite for cryptographic technology to function, and the leakage of the key will seriously threaten the security of the cryptosystem.
  • the key When cryptographic software is implemented, the key usually appears in the memory in plain text, which is easy to be obtained by the adversary through memory information leakage attacks.
  • Memory information disclosure attacks can be implemented through various means. Attackers can launch software-level memory information disclosure attacks through various vulnerabilities; they can also physically approach the target machine to launch cold boot attacks and DMA (Direct Memory Access) attacks. Therefore, it is urgent to provide an effective protection scheme for the key.
  • ECC Elliptic Curve Cryptography
  • SM2 signature algorithm ECDSA signature algorithm
  • EC-Schnorr signature algorithm One of the main uses of elliptic curve cryptography is to construct digital signature algorithms.
  • the specific ECC digital signature algorithms include SM2 signature algorithm, ECDSA signature algorithm or EC-Schnorr signature algorithm.
  • Signature algorithms rely on private keys to sign messages. Once the attacker obtains the private key information through the memory information leakage attack, he can forge the signature. Therefore, how to safely implement an ECC-based signature scheme so that it has the ability to resist memory information leakage is very critical.
  • the present invention proposes an elliptic curve digital signature calculation method and device that are resistant to memory information leakage attacks, so as to ensure key security.
  • the present invention does not rely on any hardware features, and does not implement all cryptographic operations inside the register, but splits the implementation of the ECC signature algorithm into two parts, only implements simple operations in the registers, and implements complex operations in the memory.
  • the attacker obtains all the data in the memory, the key of the ECC signature algorithm cannot be recovered. While resisting memory information leakage attacks, it greatly reduces the difficulty of development, reduces performance overhead, and improves the compatibility and scalability of the solution.
  • a method for calculating an elliptic curve digital signature against memory information leakage attacks the steps of which include:
  • the plaintext data used to generate the parameter s is calculated, wherein the plaintext data used to generate the parameter s includes: parameter r or based on the parameter r calculated data;
  • the register calculates the parameter s according to the plaintext data, the ciphertext of the random number k1 and the ciphertext of the private key;
  • the digital signature algorithm includes: SM2 signature algorithm, ECDSA signature algorithm or EC-Schnorr signature algorithm, and the symmetric encryption algorithm includes: AES algorithm or SM4 algorithm.
  • the plaintext data used to generate the parameter s is calculated through the following steps:
  • the parameter r and the random number k2 are used as plaintext data for generating the parameter s.
  • the parameter s is calculated in the register through the following steps:
  • the plaintext data used to generate the parameter s is calculated through the following steps:
  • the parameter z, the parameter r and the random number k2 are used as plaintext data for generating the parameter s.
  • the parameter s is calculated in the register through the following steps:
  • the plaintext data used to generate the parameter s is calculated through the following steps:
  • the parameter s is calculated in the register through the following steps:
  • the calculation is used to generate the plaintext data of the parameter s, which is performed in memory.
  • a storage medium in which a computer program is stored, wherein the computer program is configured to perform any one of the above-mentioned methods when running.
  • An electronic device is characterized by comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to perform any one of the methods described above.
  • registers are used to protect random numbers and private keys, which can effectively resist memory information leakage attacks and ensure the security of keys.
  • the present invention does not perform all the signature calculations in the registers, but proposes the idea of splitting the signature algorithm into two parts for the first time. Complicated calculations are implemented in memory, and simple calculations are implemented in registers, which greatly saves register space, provides better compatibility and scalability, and reduces development difficulty.
  • the invention ensures that even if an attacker obtains all memory data through a memory information leakage attack, the private key cannot be recovered.
  • the invention introduces only a small amount of performance overhead while ensuring security.
  • the invention has a wide range of applications, is universal for ECC-based signature algorithms, and perfectly fits mainstream ECC signature algorithms such as SM2, ECDSA, and EC-Schnorr.
  • Figure 1 is a schematic flow diagram of securely generating a digital signature.
  • the elliptic curve digital signature calculation method of the present invention is universal for ECC-based signature algorithms, such as SM2, ECDSA, EC-Schnorr, and the like.
  • the invention can effectively guarantee the security of the key in the signature process through algorithm modification and system design.
  • the most complex and time-consuming operation is the scalar multiplication operation k ⁇ G, where k is a scalar and G is a point on the elliptic curve.
  • the scalar multiplication operation calls the dot addition and doubling operations multiple times, and the dot addition and doubling operations are implemented by calling field operations.
  • Field operations include modular addition, modular multiplication, modular squaring, reduction, and inversion operations.
  • the signature consists of two parts, r and s. Among them, only a complex scalar multiplication needs to be calculated in the process of calculating r, and the process of calculating s from r only needs to calculate simple modular addition and modular multiplication, and sometimes an inverse operation may be required.
  • the present invention completely realizes the calculation of r in the memory, can directly call the existing cryptographic library interface, and only implements the calculation process of s in the register. Since the calculation of s is a simple operation, it only occupies a small amount of register resources and can be realized by a small amount of code modification.
  • the invention can ensure that the calculation in the memory will not leak any information related to the private key and the random number.
  • the core idea is to split the random number k into k1 and k2, k1 and k2 are two independent random numbers, only k2 will be exposed in the memory, and k1 in plain text will only appear in the register. Since the attacker cannot obtain k1, the attacker cannot obtain the random number k. Therefore, the attacker cannot use the random number k to recover the private key d.
  • the calculations related to the private key d are completed in the register, so the attacker cannot directly obtain the private key d from the memory.
  • the technical scheme of the present invention is as follows, which is universal for ECC-based signature algorithms:
  • the initialization phase is carried out before any signatures have started, and can be done in a dedicated offline device, which is considered safe.
  • the initialization phase only needs to be done once and can be reused for a large number of signatures.
  • Each signature is divided into two parts, which are unsafe calculations in memory and secure calculations in registers.
  • the operation to be performed is a scalar multiplication operation k2 ⁇ G, and a point addition operation.
  • the point addition operation needs to add the value of k2 ⁇ G to the value of k1 ⁇ G.
  • the introduced performance overhead is only one point addition operation, and the performance is about one percent of a scalar multiplication calculation, and the performance overhead is almost negligible.
  • the invention demonstrates in detail how to apply the technical solution to the SM2 signature.
  • the initialization phase is carried out before any signatures have started, and can be done in a dedicated offline device, which is considered safe.
  • the initialization phase only needs to be done once and can be reused for a large number of signatures.
  • Each SM2 signature is divided into two parts, which are unsafe calculations in memory and secure calculations in registers.
  • the introduced performance overhead is only one point addition operation, and the performance is about one percent of a scalar multiplication calculation, and the performance overhead is almost negligible.
  • the invention can be used not only for SM2 signature, but also for other ECC-based signature algorithms such as ECDSA and EC-Schnorr signature.
  • ECC-based signature algorithms such as ECDSA and EC-Schnorr signature.
  • the scheme keeps the initialization stage unchanged, calculates r in memory, and calculates s in registers, which can still resist memory information leakage attacks and have low performance overhead.
  • the in-memory computation consists of three steps at each signature.
  • the in-memory computation consists of two steps for each signature.
  • the second step is to calculate the value of H(Q
  • H(m)) is transferred to the register.
  • the k1 and d in ciphertext form are decrypted into plaintext inside the register.
  • the application of the elliptic curve digital signature calculation method of the present invention can sign the message m, as shown in Figure 1, the signing steps include:
  • the signer In the initialization phase, the signer generates plaintext parameters and ciphertext parameters for signing. (The initialization phase only needs to be executed once and can be reused by a large number of signatures)
  • the verifier uses the signature verification algorithm to verify the signature, and the signature verification algorithm does not need any changes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Physics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Algebra (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Storage Device Security (AREA)

Abstract

公开了一种抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置,属于密码技术领域。所述方法包括:在初始化可信环境下,将对称密码算法密钥置于特权寄存器,并使用对称密码算法密钥生成随机数k1的密文与私钥的密文,及计算标量乘k1×G的值;每次签名时,基于选取的签名算法与所述标量乘k1×G的值,计算用于生成参数s的明文数据,其中所述用于生成参数s的明文数据包括:参数r或基于参数r计算的数据;寄存器根据所述明文数据、随机数k1的密文与私钥的密文,计算参数s;输出(r,s)作为消息的数字签名。本发明保证内存中的计算不会泄露随机数和私钥的信息,敏感数据的计算都在寄存器中完成,并且降低性能开销,提高了适用范围,具体良好的兼容性和可扩展性。

Description

抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置 技术领域
本发明属于密码技术领域,提出一种抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置,对密钥提供保护,切实保证密码算法的实用性。
背景技术
密码软件系统被广泛应用到各种计算机和网络应用中,为数据安全提供保障。但是密码软件并没有为密钥提供专有的保护方案。密钥是密码技术发挥作用的前提,密钥泄露会严重威胁密码系统的安全。密码软件实现时,密钥通常以明文形式出现在内存中,容易通过内存信息泄露攻击被敌手获取。内存信息泄露攻击可以通过多种手段实施。攻击者可以通过各种漏洞发起软件级别的内存信息泄露攻击;也可以物理上接近目标机器,发起冷启动攻击和DMA(Direct Memory Access)攻击。因此,为密钥提供有效的保护方案刻不容缓。
公钥密码是现代密码学的重要组成部分,可以有效解决密钥的分发和管理以及签名和认证问题。椭圆曲线加密算法(ECC)是一类备受关注的公钥密码算法,具有密钥长度短,计算速度快,节省计算资源的优点。椭圆曲线密码的主要用途之一是构造数字签名算法,具体的ECC数字签名算法有SM2签名算法、ECDSA签名算法或EC-Schnorr签名算法等。签名算法依靠私钥对消息签名。攻击者一旦通过内存信息泄露攻击获取到私钥信息,就可以伪造签名。所以,如何安全地实现基于ECC的签名方案,使其具有抵抗内存信息泄露的能力非常关键。
为了抵抗内存信息泄露攻击,已经有一些方案提出。基于硬件特性的方案利用Intel SGX(Software Guard eXtensions)、MPK(Memory Protection Keys)保护密钥。但是,这些密钥保护方案需要专有的硬件支持。此外,SGX引入了额外的侧信道攻击,MPK只能抵抗软件级别的内存信息泄露攻击,无法抵抗冷启动攻击。基于软件的方案使用处理器内部的寄存器完成全部的密码计算,攻击者无法获取到寄存器中的数据。但是,由于寄存器资源的稀缺性,完全在寄存器内部实现密码运算会造成性能、可扩展性、兼容性方面的缺陷。此外,完全在寄存器内部实现密码运算设计到大量的代码重构,开发难度巨大。
发明内容
针对以上问题,本发明提出了一种抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置,用以保证密钥安全。本发明不依赖任何硬件特性,并且没有在寄存器内部实现全部的 密码运算,而是将ECC签名算法实现拆分为两部分,只在寄存器中实现简单的运算,复杂的运算放在内存中实现。但是,即使攻击者获取到内存中的全部数据,也无法恢复出ECC签名算法的密钥。在抵抗内存信息泄露攻击的同时,大幅度降低了开发难度,减少了性能开销,提高了方案的兼容性和可扩展性。
本发明的技术内容包括:
一种抗内存信息泄露攻击的椭圆曲线数字签名计算方法,其步骤包括:
在初始化可信环境下,将对称密码算法的密钥置于特权寄存器,并使用对称密码算法密钥生成随机数k1的密文与私钥的密文,及计算标量乘k1×G的值,其中k1∈[1,n-1],n为椭圆曲线的阶,G为椭圆曲线的基点;
每次签名时,基于选取的签名算法与所述标量乘k1×G的值,计算用于生成参数s的明文数据,其中所述用于生成参数s的明文数据包括:参数r或基于参数r计算的数据;
寄存器根据所述明文数据、随机数k1的密文与私钥的密文,计算参数s;
使用(r,s)对消息进行签名。
进一步地,所述数字签名算法包括:SM2签名算法、ECDSA签名算法或EC-Schnorr签名算法,所述对称密码算法包括:AES算法或SM4算法。
进一步地,选取SM2签名算法时,通过以下步骤计算用于生成参数s的明文数据:
1)基于SM2签名算法的已知参数
Figure PCTCN2022085702-appb-000001
计算参数e;
2)选择随机数k2,其中k2∈[1,n-1];
3)计算标量乘k2×G的值;
4)将标量乘k1×G的值与标量乘k2×G的值相加,得到k×G的值,其中k为随机数;
5)根据k×G的值,计算参数r;
6)将参数r与随机数k2作为用于生成参数s的明文数据。
进一步地,选取SM2签名算法时,通过以下步骤在寄存器中计算参数s:
1)在寄存器内部使用对称密码算法密钥解密随机数k1的密文与私钥的密文,得到随机数k1与私钥;
2)根据随机数k1、随机数k2及椭圆曲线的阶n,在寄存器中恢复随机数k;
3)基于随机数k、参数r、私钥及椭圆曲线的阶n,在寄存器中计算参数s。
进一步地,选取ECDSA签名算法时,通过以下步骤计算用于生成参数s的明文数据:
1)对消息m进行哈希计算,得到参数z;
2)选择随机数k2,其中k2∈[1,n-1];
3)计算标量乘k2×G的值;
4)将标量乘k1×G的值与标量乘k2×G的值相加,得到k×G的值,其中k为随机数;
5)根据k×G的值,计算参数r;
6)将参数z、参数r与随机数k2作为用于生成参数s的明文数据。
进一步地,选取ECDSA签名算法时,通过以下步骤在寄存器中计算参数s:
1)在寄存器内部使用对称密码算法密钥解密随机数k1的密文与私钥的密文,得到随机数k1与私钥;
2)根据随机数k1、随机数k2及椭圆曲线的阶n,在寄存器中恢复随机数k;
3)基于参数z、随机数k、参数r、私钥及椭圆曲线的阶n,在寄存器中计算参数s。
进一步地,选取EC-Schnorr签名算法时,通过以下步骤计算用于生成参数s的明文数据:
1)对消息m进行哈希计算,得到消息摘要H(m);
2)选择随机数k2,其中k2∈[1,n-1];
3)计算标量乘k2×G的值;
4)将标量乘k1×G的值与标量乘k2×G的值相加,得到k×G的值,其中k为随机数;
5)根据k×G的值,得到参数r;
6)通过消息摘要H(m)、参数r与公钥Q,计算H(Q||r||H(m))的值;
7)将H(Q||r||H(m))的值与随机数k2作为用于生成参数s的明文数据。
进一步地,选取EC-Schnorr签名算法时,通过以下步骤在寄存器中计算参数s:
1)在寄存器内部使用对称密码算法密钥解密随机数k1的密文与私钥的密文,得到随机数k1与私钥;
2)根据随机数k1、随机数k2及椭圆曲线的阶n,在寄存器中恢复随机数k;
3)基于随机数k、私钥及H(Q||r||H(m))的值,在寄存器中计算参数s。
进一步地,所述计算用于生成参数s的明文数据,是在内存中进行。
一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一所述方法。
一种电子设备,其特征在于,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一所述方法。
本发明的有益效果和优点是:
1)针对基于ECC的签名算法,使用寄存器对随机数和私钥进行保护,可以有效抵抗内存信息泄露攻击,保证密钥的安全。
2)为了提高方案的实用性,本发明没有在寄存器中进行全部的签名运算,而是首次提出将签名算法拆分为两部分的思想。复杂的计算在内存中实现,简单的计算在寄存器中实现,大幅度节省了寄存器空间,提供了更好的兼容性和可扩展性,同时降低开发难度。通过算法修改和系统设计,该发明保证即使攻击者通过内存信息泄露攻击获取到全部的内存数据,也无法恢复私钥。此外,该发明在保证安全的同时只会引入少量的性能开销。
3)该发明的适用范围广,对于基于ECC的签名算法具有通用性,完美契合SM2、ECDSA、EC-Schnorr等主流的ECC签名算法。
附图说明
图1为安全地生成数字签名的流程示意图。
具体实施方式
为了使本发明的目的、特征和优点更加清楚明白,以下结合附图和发明内容中的技术方案做进一步说明。
本发明的椭圆曲线数字签名计算方法,对于基于ECC的签名算法,比如SM2、ECDSA、EC-Schnorr等,具有通用性。本发明通过算法修改和系统设计,能够有效保证签名过程中的密钥安全。
在基于ECC的签名运算中,最复杂、耗时的运算是标量乘运算k×G,其中k为一个标量,G为椭圆曲线上的点。标量乘运算会多次调用点加和倍点运算,点加和倍点运算通过调用域运算实现。域运算包括模加、模乘、模平方、约减和求逆运算。签名由r和s两部分构成。其中,只有在计算r的过程中需要计算一次复杂的标量乘,从r计算出s的过程只需要计算简单的模加、模乘,有时可能需要一次求逆运算。因此,本发明将r的计算完全在内存中实现,可以直接调用已有的密码库接口,只把s的计算过程放在寄存器中实现。由于s的计算都是简单运算,所以只会占据少量的寄存器资源,通过少量的代码修改即可实现。
对于基于ECC的签名运算,目前攻击者获取私钥的方法有两种,一种是通过获得签名过程中使用的随机数k恢复私钥d,另一种是直接获取私钥d。本发明通过对签名算法的计算过程进行修改,可以保证内存中的计算不会泄露任何跟私钥和随机数相关的信息。核心思路是 将随机数k拆分为k1和k2,k1和k2是独立无关的两个随机数,内存中只会暴露k2,而明文形式的k1只会出现在寄存器中。由于攻击者无法获取k1,所以攻击者无法获取随机数k。因此攻击者不能利用随机数k恢复私钥d。同时私钥d相关的计算都在寄存器中完成,因此攻击者不能直接从内存中获得私钥d。
具体来说,本发明的技术方案如下,对于基于ECC的签名算法具有通用性:
初始化阶段:
1)生成AES密钥,将AES密钥置于具有Ring 0特权的寄存器中,例如调试寄存器。由于攻击者无法访问特权寄存器,所以无法获取AES密钥。
2)选择k1∈[1,n-1],其中n为椭圆曲线的阶。使用AES密钥加密k1和私钥d,以密文形式进行存储,比如存储在USB或者本地磁盘中。由于攻击者无法获取AES密钥,所以攻击者无法获取k1和私钥d的明文。密文形式的k1和d作为输入参与签名运算。
3)计算出标量乘k1×G的值,其中G为曲线的基点。k1×G的值以明文形式作为输入,参与签名运算。由于椭圆曲线离散对数难题,即使攻击者获取到k1×G的值也无法得到k1。
初始化阶段是在任何签名都没有开始前进行的,可以在专门的离线设备中完成,被认为是安全的。初始化阶段只需要进行一次,可以供大量的签名重复使用。
签名阶段:
每次签名分为两部分,分别为内存中的不安全计算和寄存器中的安全计算。
首先进行内存中的不安全计算,得到r的过程可以分为三步:
1)内存中选择密码学安全随机数k2∈[1,n-1]。
2)内存中计算k×G=(k1+k2)×G=k1×G+k2×G。此时,ECC签名算法实际的随机数k为k1和k2模加运算的结果,即k=(k1+k2)mod n。由于攻击者无法获取k1的值,即使攻击者通过内存信息泄露攻击成功获取到k2,也没有办法恢复出随机数k。第二步中,需要进行的运算为一次标量乘运算k2×G,以及一次点加运算。点加运算需要将k2×G的值与k1×G的值相加。由于k1×G的值已知,所以不需要额外计算。因此,与原有的签名方案相比,引入的性能开销只有一次点加运算,性能约为一次标量乘计算的百分之一,性能开销几乎可以忽略不计。
3)内存中由k×G的值得到r。
至此,内存中的不安全运算完成,内存中计算出r。
然后进行寄存器中的安全运算,随机数k的恢复和私钥d的运算都在寄存器中完成。
4)将内存中明文形式的k2,r传入寄存器。
5)将密文形式的私钥d和k1传入寄存器。寄存器内部使用AES密钥解密恢复明文状态。
6)在寄存器中恢复出实际的随机数k=(k1+k2)mod n。
7)在寄存器中由k、r和d恢复出s。
至此,寄存器中的安全运算完成,寄存器中得到s。
从技术方案中可以看出,明文形式的随机数k和私钥d不会出现在内存中。因此,一次成功的内存信息泄露攻击无法恢复私钥。
对于一些基于ECC的签名方案,如果由r得到s的过程中,有一部分计算不涉及敏感数据,则也可以放在内存中完成。比如EC-Schnorr签名中,内存中计算得到r后,由于公钥Q和消息m都为公开参数,所以可以进一步在内存中计算得到z=H(Q||r||H(m))。寄存器中只需要计算s=k+z×d即可。
以SM2签名算法为示例,该发明详细展示了如何将技术方案应用于SM2签名中。
初始化阶段:
1)生成SM4密钥,将SM4密钥置于具有Ring 0特权的寄存器中,例如调试寄存器。由于攻击者无法访问特权寄存器,所以无法获取SM4密钥。
2)选择k1∈[1,n-1],其中n为椭圆曲线的阶。使用SM4密钥加密k1和私钥d,以密文形式进行存储,比如存储在USB或者本地磁盘中。由于攻击者无法获取SM4密钥,所以攻击者无法获取k1和私钥d的明文。密文形式的k1和d作为输入参与签名运算。
3)计算出标量乘k1×G的值,其中G为曲线的基点。消息m和k1×G的值以明文形式作为输入,参与签名运算。由于椭圆曲线离散对数难题,即使攻击者获取到k1×G的值也无法得到k1。
初始化阶段是在任何签名都没有开始前进行的,可以在专门的离线设备中完成,被认为是安全的。初始化阶段只需要进行一次,可以供大量的签名重复使用。
签名阶段:
每次SM2签名分为两部分,分别为内存中的不安全计算和寄存器中的安全计算。
首先进行内存中的不安全计算:
1)内存中计算
Figure PCTCN2022085702-appb-000002
Figure PCTCN2022085702-appb-000003
为已知参数。
2)内存中产生随机数k2∈[1,n-1],n为曲线的阶。
3)内存中计算(x1,y1)=k×G=(k1+k2)×G=k1×G+k2×G。第三步中,实际的随机数k为k1和k2模加运算的结果,即k=(k1+k2)mod n。由于攻击者无法获取k1的值,即使攻击者通过内存信息泄露攻击成功获取到k2,也没有办法恢复出随机数k。第三步中,需要进行的运算为一次标量乘运算k2×G,以及一次点加运算。点加运算需要将k2×G的值与k1×G的值相加。由于k1×G的值已知,所以不需要额外计算。因此,与原有的签名方案相比,引入的性能开销只有一次点加运算,性能约为一次标量乘计算的百分之一,性能开销几乎可以忽略不计。
4)内存中计算r=(e+x1)mod n,r=0时返回步骤2重新选择k2。
至此,内存中的不安全运算全部完成,内存中计算得到r。
然后进行寄存器中的安全运算。
5)将内存中明文形式的k2,r传入寄存器。
6)将密文形式的私钥d和k1传入寄存器。寄存器内部使用SM4密钥解密恢复明文状态。
7)在寄存器中计算k=(k1+k2)mod n。
8)在寄存器中计算s=(1+d) -1×(k-r×d)mod n。
至此,寄存器中的安全运算全部完成,寄存器中得到s。
从技术方案中可以看出,明文形式的随机数k和私钥d不会出现在内存中。因此,一次成功的内存信息泄露攻击无法恢复私钥。
本发明既可用于SM2签名,也适合ECDSA、EC-Schnorr签名等其他基于ECC的签名算法。对于这些基于ECC的签名算法,方案保持初始化阶段不变,在内存中计算r,在寄存器中计算s,依旧可以抵抗内存信息泄露攻击,同时具有较低的性能开销。
在ECDSA签名中,初始化阶段不变。每次签名时内存中的计算包括三步。第一步,内存中计算z=Hash(m),即对消息m做哈希后,取前n位,n为曲线的阶。第二步,内存中选择密码学安全随机数k2∈[1,n-1]并计算出(x,y)=k×G=(k1+k2)×G=k1×G+k2×G,其中k1×G的值已知,只需要计算k2×G。第三步,内存中计算r=x mod n。内存中的计算完成后将z,k2,r传入寄存器。密文形式的k1和d在寄存器内部被解密成明文。寄存器中的操作包括两步。第一步,寄存器内恢复出随机数k=(k1+k2)mod n。第二步,寄存器中计算得到s=k -1(z+r×d)mod n。
在EC-Schnorr签名中,初始化阶段不变。每次签名时内存中的计算包括两步。第一步,内存中选择k2并计算出r=k×G=(k1+k2)×G=k1×G+k2×G,其中k1×G的值已知,只需要计算k2×G。第二步,内存中计算H(Q||r||H(m))的值,其中Q为公钥,H(m) 为消息的摘要,均为公开参数。内存中的计算完成后将k2,H(Q||r||H(m))传入寄存器。密文形式的k1和d在寄存器内部被解密成明文。寄存器中的操作包括两步。第一步,寄存器内恢复出随机数k=(k1+k2)mod n。第二步,寄存器中计算得到s=k+H(Q||r||H(m))×d。
综上所述,应用本发明的椭圆曲线数字签名计算方法,可以对消息m进行签名,如图1所示,签名步骤包括:
1)初始化阶段,签名方生成用于签名的明文参数和密文参数。(初始化阶段只需要执行一次,可以被大量签名重复使用)
2)签名时,首先在内存中依据明文参数计算得到r。
3)内存计算完成后,在寄存器内部依据明文参数和密文参数计算得到s。
4)将签名结果(m,(r,s))发送给验证方。
5)验证方使用验签算法验证签名,验签算法无需任何更改。
以上实例仅用以说明本发明的技术方案而非对其进行限制,本领域的普通技术人员可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明的精神和范围,本发明的保护范围应以权利要求所述为准。

Claims (10)

  1. 一种抗内存信息泄露攻击的椭圆曲线数字签名计算方法,其步骤包括:
    在初始化可信环境下,将对称密码算法密钥置于特权寄存器,并使用对称密码算法密钥生成随机数k1的密文与私钥的密文,及计算标量乘k1×G的值,其中k1∈[1,n-1],n为椭圆曲线的阶,G为椭圆曲线的基点;
    每次签名时,基于选取的签名算法与所述标量乘k1×G的值,计算用于生成参数s的明文数据,其中所述用于生成参数s的明文数据包括:参数r或基于参数r计算的数据;
    寄存器根据所述明文数据、随机数k1的密文与私钥的密文,计算参数s;
    输出(r,s)作为消息的数字签名。
  2. 如权利要求1所述的方法,其特征在于,所述数字签名算法包括:SM2签名算法、ECDSA签名算法或EC-Schnorr签名算法,所述对称密码算法包括:SM4算法或AES算法。
  3. 如权利要求2所述的方法,其特征在于,选取SM2签名算法时,通过以下步骤计算用于生成参数s的明文数据:
    1)基于SM2签名算法的已知参数
    Figure PCTCN2022085702-appb-100001
    计算参数e;
    2)选择随机数k2,其中k2∈[1,n-1];
    3)计算标量乘k2×G的值;
    4)将标量乘k1×G的值与标量乘k2×G的值相加,得到k×G的值,其中k为随机数;
    5)根据k×G的值,计算参数r;
    6)将参数r与随机数k2作为用于生成参数s的明文数据。
  4. 如权利要求3所述的方法,其特征在于,选取SM2签名算法时,通过以下步骤在寄存器中计算参数s:
    1)在寄存器内部使用对称密码算法密钥解密随机数k1的密文与私钥的密文,得到随机数k1与私钥;
    2)根据随机数k1、随机数k2及椭圆曲线的阶n,在寄存器中恢复随机数k;
    3)基于随机数k、参数r、私钥及椭圆曲线的阶n,在寄存器中计算参数s。
  5. 如权利要求2所述的方法,其特征在于,选取ECDSA签名算法时,通过以下步骤计算用于生成参数s的明文数据:
    1)对消息m进行哈希计算,得到参数z;
    2)选择随机数k2,其中k2∈[1,n-1];
    3)计算标量乘k2×G的值;
    4)将标量乘k1×G的值与标量乘k2×G的值相加,得到k×G的值,其中k为随机数;
    5)根据k×G的值,计算参数r;
    6)将参数z、参数r与随机数k2作为用于生成参数s的明文数据。
  6. 如权利要求5所述的方法,其特征在于,选取ECDSA签名算法时,通过以下步骤在寄存器中计算参数s:
    1)在寄存器内部使用对称密码算法密钥解密随机数k1的密文与私钥的密文,得到随机数k1与私钥;
    2)根据随机数k1、随机数k2及椭圆曲线的阶n,在寄存器中恢复随机数k;
    3)基于参数z、随机数k、参数r、私钥及椭圆曲线的阶n,在寄存器中计算参数s。
  7. 如权利要求2所述的方法,其特征在于,选取EC-Schnorr签名算法时,通过以下步骤计算用于生成参数s的明文数据:
    1)对消息m进行哈希计算,得到消息摘要H(m);
    2)选择随机数k2,其中k2∈[1,n-1];
    3)计算标量乘k2×G的值;
    4)将标量乘k1×G的值与标量乘k2×G的值相加,得到k×G的值,其中k为随机数;
    5)根据k×G的值,得到参数r;
    6)通过消息摘要H(m)、参数r与公钥Q,计算H(Q||r||H(m))的值;
    7)将H(Q||r||H(m))的值与随机数k2作为用于生成参数s的明文数据。
  8. 如权利要求7所述的方法,其特征在于,选取EC-Schnorr签名算法时,通过以下步骤在寄存器中计算参数s:
    1)在寄存器内部使用对称密码算法密钥解密随机数k1的密文与私钥的密文,得到随机数k1与私钥;
    2)根据随机数k1、随机数k2及椭圆曲线的阶n,在寄存器中恢复随机数k;
    3)基于随机数k、私钥及H(Q||r||H(m))的值,在寄存器中计算参数s。
  9. 如权利要求1所述的方法,其特征在于,所述计算用于生成参数s的明文数据,是在内存中进行。
  10. 一种电子设备,其特征在于,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行如权利要求1-9中任一所述方法。
PCT/CN2022/085702 2022-02-10 2022-04-08 抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置 WO2023151171A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/024,851 US20230254160A1 (en) 2022-02-10 2022-04-28 A calculation method and device for elliptic curve digital signature to resist memory disclosure attacks

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210124541.X 2022-02-10
CN202210124541.XA CN114928438A (zh) 2022-02-10 2022-02-10 抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置

Publications (1)

Publication Number Publication Date
WO2023151171A1 true WO2023151171A1 (zh) 2023-08-17

Family

ID=82804918

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/085702 WO2023151171A1 (zh) 2022-02-10 2022-04-08 抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置

Country Status (2)

Country Link
CN (1) CN114928438A (zh)
WO (1) WO2023151171A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103427997A (zh) * 2013-08-16 2013-12-04 西安西电捷通无线网络通信股份有限公司 一种生成数字签名的方法及装置
CN104852805A (zh) * 2015-05-11 2015-08-19 中国科学院软件研究所 一种抵抗基于格的错误攻击的sm2签名算法防护方法
CN107147488A (zh) * 2017-03-24 2017-09-08 广东工业大学 一种基于sm2加解密算法的签名验签系统和方法
CN109600232A (zh) * 2018-12-05 2019-04-09 北京智慧云测科技有限公司 针对sm2签名算法的攻击验证、防护方法及装置
US20210028946A1 (en) * 2019-07-25 2021-01-28 EMC IP Holding Company LLC Blinding Techniques for Protection of Private Keys in Message Signing Based on Elliptic Curve Cryptography

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103427997A (zh) * 2013-08-16 2013-12-04 西安西电捷通无线网络通信股份有限公司 一种生成数字签名的方法及装置
CN104852805A (zh) * 2015-05-11 2015-08-19 中国科学院软件研究所 一种抵抗基于格的错误攻击的sm2签名算法防护方法
CN107147488A (zh) * 2017-03-24 2017-09-08 广东工业大学 一种基于sm2加解密算法的签名验签系统和方法
CN109600232A (zh) * 2018-12-05 2019-04-09 北京智慧云测科技有限公司 针对sm2签名算法的攻击验证、防护方法及装置
US20210028946A1 (en) * 2019-07-25 2021-01-28 EMC IP Holding Company LLC Blinding Techniques for Protection of Private Keys in Message Signing Based on Elliptic Curve Cryptography

Also Published As

Publication number Publication date
CN114928438A (zh) 2022-08-19

Similar Documents

Publication Publication Date Title
US20220141038A1 (en) Method of rsa signature or decryption protected using a homomorphic encryption
CN109510708B (zh) 一种基于Intel SGX机制的公钥密码计算方法和系统
Abroshan A hybrid encryption solution to improve cloud computing security using symmetric and asymmetric cryptography algorithms
US10367637B2 (en) Modular exponentiation with transparent side channel attack countermeasures
US11184164B2 (en) Secure crypto system attributes
CN109039640B (zh) 一种基于rsa密码算法的加解密硬件系统及方法
US10826694B2 (en) Method for leakage-resilient distributed function evaluation with CPU-enclaves
EP3596876B1 (en) Elliptic curve point multiplication device and method for signing a message in a white-box context
JP2008252299A (ja) 暗号処理システム及び暗号処理方法
US20210152331A1 (en) Protecting polynomial hash functions from external monitoring attacks
US11902432B2 (en) System and method to optimize generation of coprime numbers in cryptographic applications
JP7155173B2 (ja) 外部監視攻撃からモジュラーインバージョン演算を保護すること
Shim et al. A high-speed public-key signature scheme for 8-b IoT-constrained devices
Meng et al. Fast secure and anonymous key agreement against bad randomness for cloud computing
US20220085999A1 (en) System and method to optimize decryption operations in cryptographic applications
JP2006259735A (ja) Simd処理を用いた楕円曲線点8倍化
US20230254160A1 (en) A calculation method and device for elliptic curve digital signature to resist memory disclosure attacks
CN110798313B (zh) 基于秘密动态共享的包含秘密的数的协同生成方法及系统
WO2023151171A1 (zh) 抗内存信息泄露攻击的椭圆曲线数字签名计算方法及装置
CN112769539B (zh) 一种生成rsa密钥并协同rsa签名和解密的方法及系统
US20220085998A1 (en) System and method to generate prime numbers in cryptographic applications
CN114637995A (zh) 具有多种异构tee实施的方法和系统
Jagadeesh et al. Hybrid AES-Modified ECC Algorithm for Improved Data Security over Cloud Storage
Njuki et al. Enhancing user data and VM security using the efficient hybrid of encrypting techniques
CN115865531B (zh) 一种代理重加密数字资产授权方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22925532

Country of ref document: EP

Kind code of ref document: A1