1 /* 2 * Copyright (c) 2023 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_DEVICE_COMMON_KEY_H 17 #define AUTH_DEVICE_COMMON_KEY_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include "lnn_node_info.h" 22 #include "softbus_def.h" 23 #include "softbus_common.h" 24 25 #ifdef __cplusplus 26 #if __cplusplus 27 extern "C" { 28 #endif 29 #endif 30 31 typedef struct { 32 bool isServerSide; 33 int32_t keyType; 34 int64_t keyIndex; 35 uint8_t deviceKey[SESSION_KEY_LENGTH]; 36 uint32_t keyLen; 37 } AuthDeviceKeyInfo; 38 39 void AuthLoadDeviceKey(void); 40 int32_t AuthInsertDeviceKey(const NodeInfo *deviceInfo, const AuthDeviceKeyInfo *deviceKey); 41 void AuthRemoveDeviceKeyByUdid(const char *udidOrHash); 42 void AuthRemoveDeviceKey(const char *udidHash, int32_t keyType); 43 int32_t AuthFindDeviceKey(const char *udidHash, int32_t keyType, AuthDeviceKeyInfo *deviceKey); 44 void AuthUpdateKeyIndex(const char *udidHash, int32_t keyType, int64_t index, bool isServer); 45 void AuthClearDeviceKey(void); 46 47 #ifdef __cplusplus 48 #if __cplusplus 49 } 50 #endif 51 #endif 52 #endif /* AUTH_DEVICE_COMMON_KEY_H */ 53