summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-09-01 11:10:06 +0800
committerliuxueli <[email protected]>2023-09-04 17:42:42 +0800
commit8ca7bc0ff9c85fa828772a1d3bf0d0f2a8c231f1 (patch)
tree6d6ecde0636c12c7a03d85fe073d4fa7c2fe3491
parenta8d75c2f89c0936a4fa4d6908d3de55cb51cf4e0 (diff)
TSG-16805: 删除解析cipher suite和alpn的逻辑v6.1.7
-rw-r--r--src/tsg_ssl_utils.cpp97
-rw-r--r--src/tsg_ssl_utils.h3
2 files changed, 1 insertions, 99 deletions
diff --git a/src/tsg_ssl_utils.cpp b/src/tsg_ssl_utils.cpp
index 634dae9..71d73c1 100644
--- a/src/tsg_ssl_utils.cpp
+++ b/src/tsg_ssl_utils.cpp
@@ -147,31 +147,9 @@ void ssl_chello_free(struct ssl_chello* chello)
}
free(chello->sni);
chello->sni = NULL;
- free(chello->alpn);
- chello->alpn = NULL;
- free(chello->cipher_suites);
- chello->cipher_suites = NULL;
- free(chello->cipher_suites_tls13);
- chello->cipher_suites_tls13 = NULL;
free(chello);
}
-static char* parse_alpn_extension(const unsigned char* buff, size_t buff_len, enum chello_parse_result* result)
-{
- size_t pos = 0;
- size_t len = ((size_t)buff[pos] << 8) + (size_t)buff[pos + 1];
- if(2 + len != buff_len)
- {
- *result = CHELLO_PARSE_INVALID_FORMAT;
- return NULL;
- }
- char* alpn = ALLOC(char, len + 1);
- strncpy((char*)alpn, (const char*)buff + 2, len);
- alpn[len] = '\0';
- *result = CHELLO_PARSE_SUCCESS;
- return alpn;
-}
-
static char* parse_server_name_extension(const unsigned char* buff, size_t buff_len, enum chello_parse_result* result)
{
size_t pos = 2; /* skip server name list length */
@@ -245,21 +223,6 @@ static enum chello_parse_result parse_extensions(const unsigned char* buff, size
{
return CHELLO_PARSE_INVALID_FORMAT;
}
- enum chello_parse_result result = CHELLO_PARSE_SUCCESS;
- p_buff = parse_alpn_extension(buff + pos + 4, len, &result);
- if(chello->alpn == NULL)
- {
- chello->alpn = p_buff;
- }
- else
- {
- free(p_buff);
- p_buff=NULL;
- }
- if(result != CHELLO_PARSE_SUCCESS)
- {
- return result;
- }
}
if (buff[pos] == 0xff && buff[pos + 1] == 0xce)//identify encrypt sni
{
@@ -279,50 +242,6 @@ static enum chello_parse_result parse_extensions(const unsigned char* buff, size
return CHELLO_PARSE_SUCCESS;
}
-static char* parse_cipher_suites(struct cipher_suite* _cipher_suite_list, int n, const unsigned char* buff, size_t buff_len, enum chello_parse_result* result)
-{
- char* cipher_suites_str = (char* )malloc(KNI_STRING_MAX);
- cipher_suites_str[0] = '\0';
- size_t pos = 0;
- int flag = 0;
- while(pos < buff_len)
- {
- int i = 0;
- for(i = 0;i < n; i++)
- {
- int val = (buff[pos] << 8) + buff[pos + 1];
- if(_cipher_suite_list[i].value == val)
- {
- if(strnlen(_cipher_suite_list[i].name, KNI_STRING_MAX) + strnlen(cipher_suites_str, KNI_STRING_MAX) + 1 > KNI_STRING_MAX)
- {
- flag = 1;
- break;
- }
- strncat(cipher_suites_str, _cipher_suite_list[i].name, KNI_STRING_MAX);
- strncat(cipher_suites_str, ":", KNI_STRING_MAX);
- }
- }
- pos += 2;
- if(flag == 1)
- {
- break;
- }
- }
- int len = strnlen(cipher_suites_str, KNI_STRING_MAX);
- if(len > 0)
- {
- cipher_suites_str[len-1] = '\0';
- }
- if(pos != buff_len && flag == 0)
- {
- *result = CHELLO_PARSE_INVALID_FORMAT;
- free(cipher_suites_str);
- return NULL;
- }
- *result = CHELLO_PARSE_SUCCESS;
- return cipher_suites_str;
-}
-
struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len, enum chello_parse_result* result)
{
if(buff == NULL)
@@ -405,9 +324,7 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
_chello->max_version.major = (uint8_t)(-1);
_chello->max_version.minor = (uint8_t)(-1);
_chello->sni = NULL;
- _chello->alpn = NULL;
- _chello->cipher_suites = NULL;
- _chello->cipher_suites_tls13 = NULL;
+
/* TLS record length */
size_t len = ((size_t)buff[3] << 8) + (size_t)buff[4] + 5;
if (buff_len < len)
@@ -459,18 +376,6 @@ struct ssl_chello* ssl_chello_parse(const unsigned char* buff, size_t buff_len,
*result = CHELLO_PARSE_INVALID_FORMAT;
return _chello;
}
- int n = sizeof(cipher_suite_list) / sizeof(struct cipher_suite);
- _chello->cipher_suites = parse_cipher_suites(cipher_suite_list, n, buff + pos, len, result);
- if(*result != CHELLO_PARSE_SUCCESS)
- {
- return _chello;
- }
- n = sizeof(cipher_suite_list_tls13) / sizeof(struct cipher_suite);
- _chello->cipher_suites_tls13 = parse_cipher_suites(cipher_suite_list_tls13, n, buff + pos, len, result);
- if(*result != CHELLO_PARSE_SUCCESS)
- {
- return _chello;
- }
pos += len;
/* Compression Methods */
if (pos >= buff_len)
diff --git a/src/tsg_ssl_utils.h b/src/tsg_ssl_utils.h
index 2d425e7..9d34746 100644
--- a/src/tsg_ssl_utils.h
+++ b/src/tsg_ssl_utils.h
@@ -26,9 +26,6 @@ struct ssl_chello
struct ssl_version max_version;
char* sni;
- char* alpn;
- char* cipher_suites;
- char* cipher_suites_tls13;
int is_encrypt_sni;
int is_encrypt_chello;
};