From 663a145bdb100a367cf19422faf1438a0625602d Mon Sep 17 00:00:00 2001 From: winnieHu Date: Mon, 12 Apr 2021 16:51:55 +0800 Subject: [PATCH] add code fix for only bind. --- frameworks/deviceauth_lite/source/hichain.c | 25 ++++++++++++++++++- .../source/key_agreement/sts_server.h | 15 ++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) mode change 100755 => 100644 frameworks/deviceauth_lite/source/hichain.c mode change 100755 => 100644 frameworks/deviceauth_lite/source/key_agreement/sts_server.h diff --git a/frameworks/deviceauth_lite/source/hichain.c b/frameworks/deviceauth_lite/source/hichain.c old mode 100755 new mode 100644 index 1b4a871..0342754 --- a/frameworks/deviceauth_lite/source/hichain.c +++ b/frameworks/deviceauth_lite/source/hichain.c @@ -63,7 +63,9 @@ static int32_t check_call_back(const struct hc_call_back *call_back); static int32_t check_auth_info(const struct hc_user_info *user_info); static int32_t delete_base_key(struct service_id service_id, struct operation_parameter para); static int32_t delete_public_key(hc_handle handle, struct service_id service_id, int32_t user_type); +#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_)) static void build_self_lt_key_pair(const struct hichain *hichain); +#endif #if DESC("api") DLL_API_PUBLIC hc_handle get_instance(const struct session_identity *identity, enum hc_type type, @@ -746,6 +748,13 @@ static void encap_inform_message(int32_t error_code, struct message *send) if ((error_code == HC_OK) || (send->msg_code != INFORM_MESSAGE) || (send->payload != NULL)) { return; } + + #if (defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_)) + if(error_code == HC_UNSUPPORT){ + send->msg_code=INVALID_MESSAGE; + return; + } + #endif int32_t *err = (int32_t *)MALLOC(sizeof(int32_t)); if (err == NULL) { LOGE("Malloc for encape inform message failed"); @@ -851,6 +860,14 @@ static int32_t deserialize_message(const struct uint8_buff *data, struct message return HC_BUILD_OBJECT_FAILED; } + #if (defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_)) + if(pass_through_data->message_code == EXCHANGE_REQUEST){ + free_data(pass_through_data); + pass_through_data = NULL; + return HC_UNSUPPORT; + } + #endif + /* message payload deserialization */ int32_t ret = build_struct_by_receive_data(pass_through_data->message_code, pass_through_data->payload_data, JSON_STRING_DATA, receive); @@ -874,7 +891,11 @@ static int32_t deserialize_message_with_json_object(const void *json_object, str LOGE("Parse data failed"); return HC_BUILD_OBJECT_FAILED; } - + #if (defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_)) + if(message_code == EXCHANGE_REQUEST){ + return HC_UNSUPPORT; + } + #endif /* message payload deserialization */ int32_t ret = build_struct_by_receive_data(message_code, obj_value, JSON_OBJECT_DATA, receive); if (ret != HC_OK) { @@ -1184,6 +1205,7 @@ static int32_t delete_public_key(hc_handle handle, struct service_id service_id, return HC_OK; } +#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_)|| defined(_CUT_EXCHANGE_)|| defined(_CUT_EXCHANGE_SERVER_)) static void build_self_lt_key_pair(const struct hichain *hichain) { struct hc_pin pin = { 0, {0} }; @@ -1218,3 +1240,4 @@ static void build_self_lt_key_pair(const struct hichain *hichain) } } } +#endif diff --git a/frameworks/deviceauth_lite/source/key_agreement/sts_server.h b/frameworks/deviceauth_lite/source/key_agreement/sts_server.h old mode 100755 new mode 100644 index 29e792f..612f323 --- a/frameworks/deviceauth_lite/source/key_agreement/sts_server.h +++ b/frameworks/deviceauth_lite/source/key_agreement/sts_server.h @@ -24,8 +24,6 @@ enum sts_message_type { STS_END_MSG, }; -#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_)) - #include "key_agreement_server.h" #if (defined(_SUPPORT_SEC_CLONE_) || defined(_SUPPORT_SEC_CLONE_SERVER_)) @@ -71,6 +69,7 @@ struct sts_start_response_data { enum hc_user_type peer_user_type; }; +#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_)) struct sts_server { struct key_agreement_server server_info; const struct session_identity *identity; @@ -92,6 +91,11 @@ struct sts_server { struct sts_start_response_data start_response_data; struct sts_end_response_data end_response_data; }; +#else +struct sts_server{ + char rsv; +}; +#endif struct sts_start_request_data { struct key_agreement_version peer_version; @@ -125,6 +129,7 @@ struct sts_end_request_data { struct auth_data auth_data; }; +#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_)) static inline uint32_t sts_server_sn(struct sts_server *server) { return server->server_info.protocol_base_info.sn; @@ -133,12 +138,6 @@ static inline uint32_t sts_server_sn(struct sts_server *server) int32_t send_sts_start_response(struct sts_server *handle, struct message *receive, struct message *send); int32_t send_sts_end_response(struct sts_server *handle, struct message *receive, struct message *send); -#else /* _CUT_XXX_ */ - -struct sts_server { - char rsv; -}; - #endif /* _CUT_XXX_ */ struct sts_server *build_sts_server(const hc_handle hichain_handle, uint32_t key_length,