Skip to content

Commit

Permalink
Bug 1377618 - Simplify handling of CertificateVerify, r=kaie
Browse files Browse the repository at this point in the history
--HG--
extra : amend_source : 4d7963ae3e96a2d17ee6491d8672c4a1a8515a18
  • Loading branch information
martinthomson committed Aug 4, 2017
1 parent c99e176 commit 579eaed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions lib/ssl/ssl3con.c
Expand Up @@ -9758,13 +9758,12 @@ ssl3_HandleCertificateVerify(sslSocket *ss, PRUint8 *b, PRUint32 length,

hashAlg = ssl_SignatureSchemeToHashType(sigScheme);

if (hashes->u.pointer_to_hash_input.data) {
rv = ssl3_ComputeHandshakeHash(hashes->u.pointer_to_hash_input.data,
hashes->u.pointer_to_hash_input.len,
hashAlg, &localHashes);
} else {
rv = SECFailure;
}
/* Read from the message buffer, but we need to use only up to the end
* of the previous handshake message. The length of the transcript up to
* that point is saved in |hashes->u.transcriptLen|. */
rv = ssl3_ComputeHandshakeHash(ss->ssl3.hs.messages.buf,
hashes->u.transcriptLen,
hashAlg, &localHashes);

if (rv == SECSuccess) {
hashesForVerify = &localHashes;
Expand Down Expand Up @@ -11664,15 +11663,15 @@ ssl3_HandleHandshakeMessage(sslSocket *ss, PRUint8 *b, PRUint32 length,
* additional handshake messages will have been added to the
* buffer, e.g. the certificate_verify message itself.)
*
* Therefore, we use SSL3Hashes.u.pointer_to_hash_input
* to signal the current state of the buffer.
* Therefore, we use SSL3Hashes.u.transcriptLen to save how much
* data there is and read directly from ss->ssl3.hs.messages
* when calculating the hashes.
*
* ssl3_HandleCertificateVerify will detect
* hashType == handshake_hash_record
* and use that information to calculate the hash.
*/
hashes.u.pointer_to_hash_input.data = ss->ssl3.hs.messages.buf;
hashes.u.pointer_to_hash_input.len = ss->ssl3.hs.messages.len;
hashes.u.transcriptLen = ss->ssl3.hs.messages.len;
hashesPtr = &hashes;
} else {
computeHashes = PR_TRUE;
Expand Down
2 changes: 1 addition & 1 deletion lib/ssl/ssl3prot.h
Expand Up @@ -236,7 +236,7 @@ typedef struct {
union {
PRUint8 raw[64];
SSL3HashesIndividually s;
SECItem pointer_to_hash_input;
unsigned int transcriptLen;
} u;
} SSL3Hashes;

Expand Down

0 comments on commit 579eaed

Please sign in to comment.