1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __DISTRIBUTION_H__ 17 #define __DISTRIBUTION_H__ 18 19 #include <stdint.h> 20 #include "hichain.h" 21 #include "pake_client.h" 22 #include "pake_server.h" 23 #include "sts_client.h" 24 #include "sts_server.h" 25 #include "sec_clone_server.h" 26 27 enum hichain_state { 28 INIT_STATE = 0, 29 KEY_AGREEMENT_STATE = 1, 30 OPERATION_STATE, 31 OVER_STATE 32 }; 33 34 struct hichain { 35 struct session_identity identity; 36 enum hc_type type; 37 enum hichain_state state; 38 enum hichain_state last_state; 39 int32_t operation_code; 40 struct pake_client *pake_client; 41 struct pake_server *pake_server; 42 struct sts_server *sts_server; 43 struct sts_client *sts_client; 44 struct sec_clone_server *sec_clone_server; 45 struct auth_info_cache *auth_info; 46 struct hc_call_back cb; 47 }; 48 49 enum message_modular { 50 INVALID_MODULAR = 0, 51 PAKE_MODULAR = 1, 52 STS_MODULAR, 53 EXCHANGE_MODULAR, 54 ADD_MODULAR, 55 REMOVE_MODULAR, 56 SEC_CLONE_MODULAR, 57 INFORM_MODULAR, 58 }; 59 60 struct header_analysis { 61 int32_t modular; 62 int32_t msg_type; 63 bool is_request_msg; 64 }; 65 66 struct header_analysis navigate_message(uint32_t message_code); 67 int32_t check_message_support(struct hichain *hichain, const struct header_analysis *nav, 68 const struct message *receive); 69 int32_t proc_message(struct hichain *handle, struct header_analysis *nav, struct message *receive, 70 struct message *send); 71 int32_t connect_message(struct hichain *handle, struct header_analysis *nav, struct message *send); 72 #endif /* __DISTRIBUTION_H__ */ 73