使用 RSA 为 DTLSv1.0 证书验证消息签名的内容

What to sign for DTLSv1.0 Certificate Verify Message with RSA

我正在使用 DTLS v1.0 与服务器通信。我在弄清楚如何生成 certificate verify message 时遇到了一些麻烦。我一直在阅读 RFCsDTLSv1.0 and TLS1.1,它是 DTLS v1.0 的基础),但当涉及到此特定消息时,它们有些不明确。

我看到消息的结构如下,我知道签名类型是RSA

struct {
       Signature signature;   
} CertificateVerify;

The Signature type is defined in 7.4.3.

CertificateVerify.signature.md5_hash
      MD5(handshake_messages);

CertificateVerify.signature.sha_hash
      SHA(handshake_messages);

根据我读到的内容,它似乎是 sha1 散列和所有先前发送和接收的消息的 md5 散列的串联(包括这条消息)然后 RSA 签名。

让我有点困惑的是如何 assemble 对消息进行哈希处理。

它是使用每个片段还是使用重新assembled 消息?另外,它使用了消息的哪些部分?

TLS 1.1 的 RFC 说

starting at client hello up to but not including this message, including the type and length fields of the handshake messages

但是像 message_seqfragment_offsetfragment_length 这样的 DTLS 特定部分呢?我要包括它们吗?

更新: 我已经尝试按照 DTLS 1.2 的 RFC 显示进行操作(意味着保持消息碎片化,使用所有握手字段,包括 DTLS 特定字段,不包括初始 Client HelloHello Verify Request 消息),但我仍然收到“错误签名”。我确实相信我签名正确,所以我相信我不正确地连接数据以进行签名。

对于 DTLS 1.2 已定义。阅读 RFC 4347,我的印象是,RFC 6347 没有区别,它阐明了计算。

RFC 6347, 4.2.6. CertificateVerify and Finished Messages

RFC 4347, 4.2.6. Finished Messages