Reputation: 458
I would like to implement TLS1.3 Certificate Verify functionality (without external library, openssl etc.).
I am a bit confused about the documentation. According to it I am believing, that the algorithm, using RSA-PSS-RSAE-SHA256 is the following:
Parsing and checking certificates received in the Certificate handshake is Ok. From here I can also get the public key (RSA n and e) for the Cerificate Verify
According to RFC8446/4.4.3, the content to sign consists of: 64 * 0x20 + "TLS 1.3, server CertificateVerify" + 0x00 + transcript-hash of messages (in our case, sha256 hash of concatenating all handshakes ClientHello...Certificate). I consider content to be message M
in the followings.
RSASSA-PPS with EMSA-PSS (for the selected signature algorithm) is described in RFC8017/8.1.2, 9.1.2. There are two main steps: The signature has to be RSA-decrypted (8.1.2); EMSA-PSS verification has to be done (9.1.2):
EM
H
), and salt
can be extracted from that one. Details are in the RFC documentmHash = sha256(M)
H'
can be calculated by sha256 hash of (8 * 0x00 + mHash + salt)
If H == H'
, then verification is successful.
At least this is how I interpret this. But it does not work:
M
of RSASSA-PPS is not the same as the content of TLS Certificate Verify content.H
and salt
using the signature and the public key (there are good checking opportunities for this, so this is surely Ok in my case)But as a result H != H'
.
So I probably misunderstand something with this algorithm. Maybe the message M
should be something different, or something else is missing. Is there any good description somewhere, which leads through this process step by step? Or a source which can be run part by part, so that I can check where my implementation deviates? (Pyhton or perl is preferred, but any major languages can be good)
Upvotes: 0
Views: 280
Reputation: 57
I think the problem is that you use publicKey instead of privateKey. Signature is created using privateKey which is paired with publicKey inside certificate.
revised:
Inside EMSA_PSS there are several step including salting, concatenate, hashing, merging, and masking using MGF1 function.
The formula above descripted in RFC8017. Hope the made you clear.
Upvotes: 0