• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 ASY_TOKEN_MANAGER_H
17 #define ASY_TOKEN_MANAGER_H
18 
19 #include <stdint.h>
20 #include "alg_defs.h"
21 #include "common_defs.h"
22 #include "string_util.h"
23 
24 typedef struct {
25     Uint8Buff version;
26     Uint8Buff userId;
27     Uint8Buff deviceId;
28     Uint8Buff devicePk;
29 } PkInfo;
30 
31 typedef struct {
32     Uint8Buff pkInfoStr;
33     PkInfo pkInfo;
34     Uint8Buff pkInfoSignature;
35     Uint8Buff serverPk;
36 } AccountToken;
37 DECLARE_HC_VECTOR(AccountTokenVec, AccountToken*)
38 
39 typedef struct {
40     int32_t (*addToken)(int32_t osAccountId, int32_t opCode, const CJson *in);
41     int32_t (*getToken)(int32_t osAccountId, AccountToken *token, const char *userId, const char *deviceId);
42     int32_t (*deleteToken)(int32_t osAccountId, const char *userId, const char *deviceId);
43     int32_t (*getRegisterProof)(const CJson *in, CJson *out);
44     int32_t (*generateKeyAlias)(const char *userId, const char *deviceId,
45         Uint8Buff *keyAlias, bool isServerPkAlias);
46     Algorithm (*getAlgVersion)(int32_t osAccountId, const char *userId, const char *deviceId);
47 } AccountAuthTokenManager;
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 AccountAuthTokenManager *GetAccountAuthTokenManager(void);
54 
55 void InitTokenManager(void);
56 void DestroyTokenManager(void);
57 
58 AccountToken *CreateAccountToken(void);
59 void DestroyAccountToken(AccountToken *token);
60 
61 AccountTokenVec CreateAccountTokenVec(void);
62 void ClearAccountTokenVec(AccountTokenVec *vec);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif