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 PAKE_BASE_CUR_TASK_H 17 #define PAKE_BASE_CUR_TASK_H 18 19 #include "das_module_defines.h" 20 #include "hc_types.h" 21 #include "json_utils.h" 22 #include "pake_defs.h" 23 24 #define HICHAIN_RETURN_KEY "hichain_return_key" 25 #define TMP_AUTH_KEY_FACTOR "hichain_tmp_auth_enc_key" 26 #define FIELD_P2P_PSEUDONYM_ID "pdId" 27 #define FIELD_PSEUDONYM_CHALLENGE "pdChlg" 28 #define FIELD_IS_PSEUDONYM_SUPPORTED "isPdSupported" 29 #define FIELD_SELF_NEXT_PSEUDONYM_ID "selfNextPseudonymId" 30 #define FIELD_PEER_NEXT_PSEUDONYM_ID "peerNextPseudonymId" 31 #define FIELD_SELF_NEXT_PSEUDONYM_CHALLENGE "selfNextPseudonymChallenge" 32 33 #define PAKE_KEY_ALIAS_LEN 64 34 #define PAKE_ED25519_KEY_PAIR_LEN 32 35 #define PAKE_NONCE_LEN 32 36 #define PAKE_PSK_LEN 32 37 #define PSEUDONYM_CHALLENGE_LEN 16 38 #define PSEUDONYM_ID_LEN 32 39 #define PSEUDONYM_COMBINE_CHALLENGE_LEN 32 40 41 typedef struct { 42 Uint8Buff selfNextPseudonymId; 43 Uint8Buff selfNextPseudonymChallenge; 44 Uint8Buff peerNextPseudonymId; 45 } PseudonymPskExtInfo; 46 47 48 typedef struct PakeParamsT { 49 PakeBaseParams baseParams; 50 51 bool isPskSupported; 52 Uint8Buff returnKey; 53 Uint8Buff nonce; 54 int32_t opCode; 55 int32_t userType; 56 int32_t userTypePeer; 57 char *packageName; 58 char *serviceType; 59 bool isPseudonym; 60 PseudonymPskExtInfo pseudonymExtInfo; 61 uint8_t selfNextPseudonymChallenge[PSEUDONYM_CHALLENGE_LEN]; 62 uint8_t peerNextPseudonymChallenge[PSEUDONYM_CHALLENGE_LEN]; 63 bool isSelfFromUpgrade; 64 bool isPeerFromUpgrade; 65 } PakeParams; 66 67 typedef struct AsyBaseCurTaskT { 68 CurTaskType (*getCurTaskType)(void); 69 void (*destroyTask)(struct AsyBaseCurTaskT *); 70 int(*process)(struct AsyBaseCurTaskT *, PakeParams *params, const CJson *in, CJson *out, int *status); 71 int taskStatus; 72 } AsyBaseCurTask; 73 74 #ifdef __cplusplus 75 extern "C" { 76 #endif 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif 83