You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/08/28 03:37:38 UTC
[trafficserver] 01/03: Remove ssl_handle() from QUICHandshake
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit cb79e0257d04b2110dd310d3a1378c99c651e9c2
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Aug 28 11:28:36 2018 +0900
Remove ssl_handle() from QUICHandshake
---
iocore/net/quic/Mock.h | 13 +++++++++++++
iocore/net/quic/QUICHandshake.cc | 14 ++------------
iocore/net/quic/QUICHandshakeProtocol.h | 2 ++
iocore/net/quic/QUICTLS.cc | 18 ++++++++++++------
iocore/net/quic/QUICTLS.h | 5 ++---
5 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/iocore/net/quic/Mock.h b/iocore/net/quic/Mock.h
index 15bd188..b282b8c 100644
--- a/iocore/net/quic/Mock.h
+++ b/iocore/net/quic/Mock.h
@@ -556,6 +556,19 @@ public:
return 0;
}
+ const char *
+ negotiated_cipher_suite() const override
+ {
+ return nullptr;
+ }
+
+ void
+ negotiated_application_name(const uint8_t **name, unsigned int *len) const override
+ {
+ *name = reinterpret_cast<const uint8_t *>("hq");
+ *len = 2;
+ }
+
bool
encrypt(uint8_t *cipher, size_t &cipher_len, size_t max_cipher_len, const uint8_t *plain, size_t plain_len, uint64_t pkt_num,
const uint8_t *ad, size_t ad_len, QUICKeyPhase phase) const override
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 17d1144..96ab765 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -219,23 +219,13 @@ QUICHandshake::negotiated_version()
const char *
QUICHandshake::negotiated_cipher_suite()
{
- // FIXME Generalize and remove dynamic_cast
- QUICTLS *hs_tls = dynamic_cast<QUICTLS *>(this->_hs_protocol);
- if (hs_tls) {
- return SSL_get_cipher_name(hs_tls->ssl_handle());
- }
-
- return nullptr;
+ return this->_hs_protocol->negotiated_cipher_suite();
}
void
QUICHandshake::negotiated_application_name(const uint8_t **name, unsigned int *len)
{
- // FIXME Generalize and remove dynamic_cast
- QUICTLS *hs_tls = dynamic_cast<QUICTLS *>(this->_hs_protocol);
- if (hs_tls) {
- SSL_get0_alpn_selected(hs_tls->ssl_handle(), name, len);
- }
+ this->_hs_protocol->negotiated_application_name(name, len);
}
void
diff --git a/iocore/net/quic/QUICHandshakeProtocol.h b/iocore/net/quic/QUICHandshakeProtocol.h
index 88dc369..3627e41 100644
--- a/iocore/net/quic/QUICHandshakeProtocol.h
+++ b/iocore/net/quic/QUICHandshakeProtocol.h
@@ -76,6 +76,8 @@ public:
virtual bool is_key_derived(QUICKeyPhase key_phase, bool for_encryption) const = 0;
virtual int initialize_key_materials(QUICConnectionId cid) = 0;
virtual int update_key_materials() = 0;
+ virtual const char *negotiated_cipher_suite() const = 0;
+ virtual void negotiated_application_name(const uint8_t **name, unsigned int *len) const = 0;
virtual bool encrypt(uint8_t *cipher, size_t &cipher_len, size_t max_cipher_len, const uint8_t *plain, size_t plain_len,
uint64_t pkt_num, const uint8_t *ad, size_t ad_len, QUICKeyPhase phase) const = 0;
virtual bool decrypt(uint8_t *plain, size_t &plain_len, size_t max_plain_len, const uint8_t *cipher, size_t cipher_len,
diff --git a/iocore/net/quic/QUICTLS.cc b/iocore/net/quic/QUICTLS.cc
index fb8803e..21b3599 100644
--- a/iocore/net/quic/QUICTLS.cc
+++ b/iocore/net/quic/QUICTLS.cc
@@ -122,6 +122,18 @@ QUICTLS::update_key_materials()
return 1;
}
+const char *
+QUICTLS::negotiated_cipher_suite() const
+{
+ return SSL_get_cipher_name(this->_ssl);
+}
+
+void
+QUICTLS::negotiated_application_name(const uint8_t **name, unsigned int *len) const
+{
+ SSL_get0_alpn_selected(this->_ssl, name, len);
+}
+
QUICEncryptionLevel
QUICTLS::current_encryption_level() const
{
@@ -146,12 +158,6 @@ QUICTLS::_update_encryption_level(QUICEncryptionLevel level)
return;
}
-SSL *
-QUICTLS::ssl_handle()
-{
- return this->_ssl;
-}
-
bool
QUICTLS::encrypt(uint8_t *cipher, size_t &cipher_len, size_t max_cipher_len, const uint8_t *plain, size_t plain_len,
uint64_t pkt_num, const uint8_t *ad, size_t ad_len, QUICKeyPhase phase) const
diff --git a/iocore/net/quic/QUICTLS.h b/iocore/net/quic/QUICTLS.h
index 81fd96d..febdedf 100644
--- a/iocore/net/quic/QUICTLS.h
+++ b/iocore/net/quic/QUICTLS.h
@@ -58,6 +58,8 @@ public:
int initialize_key_materials(QUICConnectionId cid) override;
int update_key_materials() override;
void update_key_materials_on_key_cb(std::unique_ptr<KeyMaterial> km, int name);
+ const char *negotiated_cipher_suite() const override;
+ void negotiated_application_name(const uint8_t **name, unsigned int *len) const override;
bool encrypt(uint8_t *cipher, size_t &cipher_len, size_t max_cipher_len, const uint8_t *plain, size_t plain_len, uint64_t pkt_num,
const uint8_t *ad, size_t ad_len, QUICKeyPhase phase) const override;
bool decrypt(uint8_t *plain, size_t &plain_len, size_t max_plain_len, const uint8_t *cipher, size_t cipher_len, uint64_t pkt_num,
@@ -69,9 +71,6 @@ public:
QUICEncryptionLevel current_encryption_level() const override;
void abort_handshake() override;
- // FIXME SSL handle should not be exported
- SSL *ssl_handle();
-
private:
QUICKeyGenerator _keygen_for_client = QUICKeyGenerator(QUICKeyGenerator::Context::CLIENT);
QUICKeyGenerator _keygen_for_server = QUICKeyGenerator(QUICKeyGenerator::Context::SERVER);