Coder Social home page Coder Social logo

Comments (10)

guanzhi avatar guanzhi commented on May 16, 2024

目前GmSSL在签名时默认不加入Z值,因此无法验证国密标准的证书。

from gmssl.

mrpre avatar mrpre commented on May 16, 2024

@guanzhi 老师您好,不知道您说的Z值指的是什么?
在SM2算法规范中,看到了在计算签名时,首先需要将 id_len+id+a+b+xg+yg+xa+ya 计算出一个hash,您的Z值是否指的是这个?但是 我看GMSSL 代码,SM2_compute_message_digest 函数中 这个hash值加进去了的。

from gmssl.

guanzhi avatar guanzhi commented on May 16, 2024

Z值是这个。证书所用的上层API没有将这个值加入计算。

from gmssl.

mrpre avatar mrpre commented on May 16, 2024

应该不是这个问题。

应该是人行服务器 或者 360浏览器 约定了自己的ID值,导致我验证错误。

有谁知道ECC算法发送server key exchange时,
1:被签名message data 是否 是 {client random + server random + sign cert}?
2:计算哈希值时,id是否用的是默认的"1234567812345678"?

from gmssl.

Jkinglyf avatar Jkinglyf commented on May 16, 2024

@mrpre 1)message data 是:“双方随机数 + 加密证书”的签名值;
2 ) 默认 id是:"1234567812345678"。

from gmssl.

mrpre avatar mrpre commented on May 16, 2024

@Jkinglyf
想确认一下, message data 是:“双方随机数 + 加密证书”的签名值;
是否是 “32字节的客户端随机数 + 32字节的服务器端随机数 + 二进制(DER编码)加密证书的”
三者拼接起来的?
然后再拿 Z + message data 拼接起来,使用sm3哈希出结果,对结果进行签名?

from gmssl.

Jkinglyf avatar Jkinglyf commented on May 16, 2024

@mrpre 利用SM3计算出 H值,再用签名私钥对 H 值进行签名。

from gmssl.

mrpre avatar mrpre commented on May 16, 2024

@Jkinglyf
H值??我在规范中没有找到H相关的啊。。
M = “32字节的客户端随机数 + 32字节的服务器端随机数 + 二进制(DER编码)加密证书”
M' = Z || M (M' 总长度:32字节的Z + 32字节随机数 + 32 字节随机数 + 加密证书长度)
你说的H指的是 sm3(M')吗?
我也是这么发送server key exchange,可惜360不认。

from gmssl.

conezxy avatar conezxy commented on May 16, 2024

请注意看国密规范0024-2014关于ServerKeyExchange的部分
image

这里的加密证书表示是 opaque ASN.1Cert<1..2^24-1>,这是一个变长向量,因此在证书之前需要有3字节的长度(有关变长向量的定义,在国密规范中的6.2.2章节;在TLS中是4.3章节:https://tools.ietf.org/html/rfc5246#section-4.3

这里的表示方法与Server Certificate中的证书表示是一样的,
你可以对比一下抓到的Server Certificate包,在每张证书之前,是不是有3字节的长度?

这3字节的长度也需要参与ServerKeyExchange的签名计算。

from gmssl.

mrpre avatar mrpre commented on May 16, 2024

@conezxy 多谢指教!验证成功了。

from gmssl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.