Skip to content

Commit

Permalink
Bug 1471126 - Record layer separation, r=ekr
Browse files Browse the repository at this point in the history
Summary:
Add functions for QUIC that provide the raw content of records to callback functions.

Reviewers: ekr

Reviewed By: ekr

Bug #: 1471126

Differential Revision: https://phabricator.services.mozilla.com/D1874

--HG--
extra : rebase_source : 169bf11f3d2dc5534a059c0dbb9972ad82344fbb
extra : histedit_source : 63ba5cb0da868bb2e136a24a16e50ff71edee751%2Cf00481e4699bf47cf7620de6f9ff82ef10412df2
  • Loading branch information
martinthomson committed Feb 17, 2019
1 parent 4a3d54c commit 7b3eabb
Show file tree
Hide file tree
Showing 19 changed files with 733 additions and 224 deletions.
26 changes: 26 additions & 0 deletions cpputil/tls_parser.h
Expand Up @@ -80,6 +80,32 @@ inline std::ostream& operator<<(std::ostream& os, SSLProtocolVariant v) {
return os << ((v == ssl_variant_stream) ? "TLS" : "DTLS");
}

inline std::ostream& operator<<(std::ostream& os, SSLContentType v) {
switch (v) {
case ssl_ct_change_cipher_spec:
return os << "CCS";
case ssl_ct_alert:
return os << "alert";
case ssl_ct_handshake:
return os << "handshake";
case ssl_ct_application_data:
return os << "application data";
case ssl_ct_ack:
return os << "ack";
}
return os << "UNKNOWN content type " << static_cast<int>(v);
}

inline std::ostream& operator<<(std::ostream& os, SSLSecretDirection v) {
switch (v) {
case ssl_secret_read:
return os << "read";
case ssl_secret_write:
return os << "write";
}
return os << "UNKNOWN secret direction " << static_cast<int>(v);
}

inline bool IsDtls(uint16_t version) { return (version & 0x8000) == 0x8000; }

inline uint16_t NormalizeTlsVersion(uint16_t version) {
Expand Down
12 changes: 12 additions & 0 deletions gtests/ssl_gtest/libssl_internals.c
Expand Up @@ -373,3 +373,15 @@ SECStatus SSLInt_GetEpochs(PRFileDesc *fd, PRUint16 *readEpoch,
ssl_ReleaseSpecReadLock(ss);
return SECSuccess;
}

SECStatus SSLInt_HasPendingHandshakeData(PRFileDesc *fd, PRBool *pending) {
sslSocket *ss = ssl_FindSocket(fd);
if (!ss) {
return SECFailure;
}

ssl_GetSSL3HandshakeLock(ss);
*pending = ss->ssl3.hs.msg_body.len > 0;
ssl_ReleaseSSL3HandshakeLock(ss);
return SECSuccess;
}
1 change: 1 addition & 0 deletions gtests/ssl_gtest/libssl_internals.h
Expand Up @@ -41,6 +41,7 @@ SECStatus SSLInt_AdvanceWriteSeqByAWindow(PRFileDesc *fd, PRInt32 extra);
SSLKEAType SSLInt_GetKEAType(SSLNamedGroup group);
SECStatus SSLInt_GetEpochs(PRFileDesc *fd, PRUint16 *readEpoch,
PRUint16 *writeEpoch);
SECStatus SSLInt_HasPendingHandshakeData(PRFileDesc *fd, PRBool *pending);

SECStatus SSLInt_SetCipherSpecChangeFunc(PRFileDesc *fd,
sslCipherSpecChangedFunc func,
Expand Down

0 comments on commit 7b3eabb

Please sign in to comment.