1 /* 2 * Copyright (C) 2021 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 AUTH_SUB_SESSION_H 17 #define AUTH_SUB_SESSION_H 18 19 #include "json_utils.h" 20 #include "string_util.h" 21 22 typedef enum { 23 AUTH_STATE_INIT = 0, 24 AUTH_STATE_RUNNING = 1, 25 AUTH_STATE_FINISH = 2, 26 } AuthState; 27 28 typedef struct AuthSubSession AuthSubSession; 29 struct AuthSubSession { 30 int32_t protocolType; 31 int32_t state; 32 int32_t (*start)(AuthSubSession *self, CJson **returnSendMsg); 33 int32_t (*process)(AuthSubSession *self, const CJson *receviedMsg, CJson **returnSendMsg); 34 int32_t (*setPsk)(AuthSubSession *self, const Uint8Buff *psk); 35 int32_t (*setSelfProtectedMsg)(AuthSubSession *self, const Uint8Buff *selfMsg); 36 int32_t (*setPeerProtectedMsg)(AuthSubSession *self, const Uint8Buff *peerMsg); 37 int32_t (*getSessionKey)(AuthSubSession *self, Uint8Buff *returnSessionKey); 38 void (*destroy)(AuthSubSession *self); 39 }; 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 bool IsProtocolSupport(int32_t protocolType); 46 int32_t CreateAuthSubSession(int32_t protocolType, void *params, bool isClient, AuthSubSession **returnObj); 47 48 #ifdef __cplusplus 49 } 50 #endif 51 #endif 52