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_IDENTITY_DEFINE_H 17 #define AUTH_IDENTITY_DEFINE_H 18 19 #include "alg_defs.h" 20 #include "hc_vector.h" 21 #include "string_util.h" 22 23 #define PRESHARED_URL_CREDENTIAL_TYPE "credentialType" 24 #define PRESHARED_URL_KEY_TYPE "keyType" 25 #define PRESHARED_URL_TRUST_TYPE "trustType" 26 27 #define SHARED_KEY_ALIAS "sharedKeyAlias" 28 #define KEY_INFO_PERSISTENT_TOKEN "persistent_token" 29 #define TMP_AUTH_KEY_FACTOR "hichain_tmp_auth_enc_key" 30 31 #define ASCII_CASE_DIFFERENCE_VALUE 32 32 #define P256_SHARED_SECRET_KEY_SIZE 32 33 #define AUTH_TOKEN_SIZE 32 34 #define PAKE_KEY_ALIAS_LEN 64 35 #define PAKE_NONCE_LEN 32 36 #define PAKE_PSK_LEN 32 37 #define ISO_PSK_LEN 32 38 #define SEED_LEN 32 39 #define ISO_KEY_ALIAS_LEN 32 40 #define ISO_UPGRADE_KEY_ALIAS_LEN 64 41 #define KEY_TYPE_PAIR_LEN 2 42 #define PAKE_ED25519_KEY_PAIR_LEN 32 43 #define PAKE_ED25519_KEY_STR_LEN 64 44 #define AUTH_CODE_LEN 32 45 #define KEY_ALIAS_LEN 32 46 #define PACKAGE_NAME_MAX_LEN 256 47 #define SERVICE_TYPE_MAX_LEN 256 48 #define AUTH_ID_MAX_LEN 64 49 #define USER_ID_LEN 65 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 55 typedef enum { KEY_TYPE_SYM, KEY_TYPE_ASYM } KeyType; 56 57 typedef enum { TRUST_TYPE_PIN, TRUST_TYPE_P2P, TRUST_TYPE_UID } TrustType; 58 59 typedef enum { PRE_SHARED, CERTIFICATED } IdentityProofType; 60 61 typedef enum { ALG_EC_SPEKE = 0x0001, ALG_DL_SPEKE = 0x0002, ALG_ISO = 0x0004 } ProtocolAlgType; 62 63 typedef enum { 64 KEY_ALIAS_ACCESSOR_PK = 0, 65 KEY_ALIAS_CONTROLLER_PK = 1, 66 KEY_ALIAS_LT_KEY_PAIR = 2, 67 KEY_ALIAS_KEK = 3, 68 KEY_ALIAS_DEK = 4, 69 KEY_ALIAS_TMP = 5, 70 KEY_ALIAS_PSK = 6, 71 KEY_ALIAS_AUTH_TOKEN = 7, 72 KEY_ALIAS_P2P_AUTH = 8, 73 74 KEY_ALIAS_TYPE_END 75 } KeyAliasType; // 0 ~ 2^8-1, don't change the order 76 77 typedef enum { 78 CMD_EXCHANGE_PK = 0x0001, 79 CMD_IMPORT_AUTH_CODE = 0x0002, 80 CMD_ADD_TRUST_DEVICE = 0x0004, 81 CMD_MK_AGREE = 0x0008, 82 } ExpandProcessCmd; 83 84 typedef enum { 85 DEFAULT_ID_TYPE = 0, 86 P2P_DIRECT_AUTH = 1, 87 } IdentityInfoType; 88 89 typedef struct { 90 ProtocolAlgType protocolType; 91 uint32_t expandProcessCmds; 92 } ProtocolEntity; 93 DECLARE_HC_VECTOR(ProtocolEntityVec, ProtocolEntity *) 94 95 typedef struct { 96 Uint8Buff pkInfoStr; 97 Uint8Buff pkInfoSignature; 98 Algorithm signAlg; 99 bool isPseudonym; 100 } CertInfo; 101 102 typedef struct { 103 Uint8Buff preSharedUrl; 104 CertInfo certInfo; 105 } IdentityProof; 106 107 typedef struct { 108 IdentityProofType proofType; 109 IdentityProof proof; 110 ProtocolEntityVec protocolVec; 111 int32_t IdInfoType; 112 } IdentityInfo; 113 DECLARE_HC_VECTOR(IdentityInfoVec, IdentityInfo *) 114 115 #ifdef __cplusplus 116 } 117 #endif 118 119 #endif