117fd14ceSopenharmony_ci/*
217fd14ceSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
317fd14ceSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
417fd14ceSopenharmony_ci * you may not use this file except in compliance with the License.
517fd14ceSopenharmony_ci * You may obtain a copy of the License at
617fd14ceSopenharmony_ci *
717fd14ceSopenharmony_ci *    http://www.apache.org/licenses/LICENSE-2.0
817fd14ceSopenharmony_ci *
917fd14ceSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1017fd14ceSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1117fd14ceSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1217fd14ceSopenharmony_ci * See the License for the specific language governing permissions and
1317fd14ceSopenharmony_ci * limitations under the License.
1417fd14ceSopenharmony_ci */
1517fd14ceSopenharmony_ci
1617fd14ceSopenharmony_ci#ifndef AUTH_IDENTITY_MANAGER_H
1717fd14ceSopenharmony_ci#define AUTH_IDENTITY_MANAGER_H
1817fd14ceSopenharmony_ci
1917fd14ceSopenharmony_ci#include "alg_defs.h"
2017fd14ceSopenharmony_ci#include "alg_loader.h"
2117fd14ceSopenharmony_ci#include "common_defs.h"
2217fd14ceSopenharmony_ci#include "das_task_common.h"
2317fd14ceSopenharmony_ci#include "device_auth_defines.h"
2417fd14ceSopenharmony_ci#include "hc_log.h"
2517fd14ceSopenharmony_ci#include "hc_types.h"
2617fd14ceSopenharmony_ci#include "identity_common.h"
2717fd14ceSopenharmony_ci#include "identity_defines.h"
2817fd14ceSopenharmony_ci#include "json_utils.h"
2917fd14ceSopenharmony_ci#include "securec.h"
3017fd14ceSopenharmony_ci
3117fd14ceSopenharmony_ci#ifdef __cplusplus
3217fd14ceSopenharmony_ciextern "C" {
3317fd14ceSopenharmony_ci#endif
3417fd14ceSopenharmony_ci
3517fd14ceSopenharmony_citypedef enum {
3617fd14ceSopenharmony_ci    AUTH_IDENTITY_TYPE_INVALID = -1,
3717fd14ceSopenharmony_ci    AUTH_IDENTITY_TYPE_GROUP,
3817fd14ceSopenharmony_ci    AUTH_IDENTITY_TYPE_PIN,
3917fd14ceSopenharmony_ci    AUTH_IDENTITY_TYPE_P2P,
4017fd14ceSopenharmony_ci} AuthIdentityType;
4117fd14ceSopenharmony_ci
4217fd14ceSopenharmony_citypedef struct {
4317fd14ceSopenharmony_ci    int32_t (*getCredInfosByPeerIdentity)(const CJson *in, IdentityInfoVec *vec);
4417fd14ceSopenharmony_ci    int32_t (*getCredInfoByPeerUrl)(const CJson *in, const Uint8Buff *presharedUrl, IdentityInfo **returnInfo);
4517fd14ceSopenharmony_ci    int32_t (*getSharedSecretByUrl)(
4617fd14ceSopenharmony_ci        const CJson *in, const Uint8Buff *presharedUrl, ProtocolAlgType protocolType, Uint8Buff *sharedSecret);
4717fd14ceSopenharmony_ci    int32_t (*getCredInfoByPeerCert)(const CJson *in, const CertInfo *certInfo, IdentityInfo **returnInfo);
4817fd14ceSopenharmony_ci    int32_t (*getSharedSecretByPeerCert)(
4917fd14ceSopenharmony_ci        const CJson *in, const CertInfo *peerCertInfo, ProtocolAlgType protocolType, Uint8Buff *sharedSecret);
5017fd14ceSopenharmony_ci} AuthIdentity;
5117fd14ceSopenharmony_ci
5217fd14ceSopenharmony_citypedef struct {
5317fd14ceSopenharmony_ci    int32_t (*queryCredential)(const char *reqJsonStr, char **returnData);
5417fd14ceSopenharmony_ci    int32_t (*genarateCredential)(const char *reqJsonStr, char **returnData);
5517fd14ceSopenharmony_ci    int32_t (*importCredential)(const char *reqJsonStr, char **returnData);
5617fd14ceSopenharmony_ci    int32_t (*deleteCredential)(const char *reqJsonStr, char **returnData);
5717fd14ceSopenharmony_ci} CredentialOperator;
5817fd14ceSopenharmony_ci
5917fd14ceSopenharmony_citypedef struct {
6017fd14ceSopenharmony_ci    const AuthIdentity *(*getAuthIdentityByType)(AuthIdentityType type);
6117fd14ceSopenharmony_ci    const CredentialOperator *(*getCredentialOperator)(void);
6217fd14ceSopenharmony_ci} AuthIdentityManager;
6317fd14ceSopenharmony_ci
6417fd14ceSopenharmony_ciconst AuthIdentity *GetGroupAuthIdentity(void);
6517fd14ceSopenharmony_ciconst AuthIdentity *GetPinAuthIdentity(void);
6617fd14ceSopenharmony_ciconst AuthIdentity *GetP2pAuthIdentity(void);
6717fd14ceSopenharmony_ciconst AuthIdentity *GetAuthIdentityByType(AuthIdentityType type);
6817fd14ceSopenharmony_ciconst CredentialOperator *GetCredentialOperator(void);
6917fd14ceSopenharmony_ciconst AuthIdentityManager *GetAuthIdentityManager(void);
7017fd14ceSopenharmony_ci
7117fd14ceSopenharmony_ciuint8_t *GetKeyTypePair(KeyAliasType keyAliasType);
7217fd14ceSopenharmony_ci
7317fd14ceSopenharmony_ci#ifdef __cplusplus
7417fd14ceSopenharmony_ci}
7517fd14ceSopenharmony_ci#endif
7617fd14ceSopenharmony_ci
7717fd14ceSopenharmony_ci#endif // AUTH_IDENTITY_MANAGER_H