• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEFS_H
17 #define PAKE_DEFS_H
18 
19 #include "alg_defs.h"
20 #include "string_util.h"
21 
22 #define HICHAIN_SPEKE_BASE_INFO "hichain_speke_base_info"
23 #define HICHAIN_SPEKE_SESSIONKEY_INFO "hichain_speke_sessionkey_info"
24 #define SHARED_SECRET_DERIVED_FACTOR "hichain_speke_shared_secret_info"
25 
26 #define PAKE_SALT_LEN 16
27 #define PAKE_CHALLENGE_LEN 16
28 #define PAKE_SECRET_LEN 32
29 #define PAKE_HMAC_KEY_LEN 32
30 #define PAKE_EC_KEY_LEN 32
31 #define PAKE_DL_EXP_LEN 1
32 #define PAKE_DL_ESK_SMALL_LEN 28
33 #define PAKE_DL_ESK_LEN 32
34 #define PAKE_DL_PRIME_SMALL_LEN 256
35 #define PAKE_DL_PRIME_LEN 384
36 
37 typedef enum {
38     PAKE_ALG_NONE = 0x0000,
39     PAKE_ALG_DL = 0x0001,
40     PAKE_ALG_EC = 0x0002,
41 } PakeAlgType;
42 
43 typedef enum {
44     DL_PRIME_MOD_NONE = 0x0000,
45     DL_PRIME_MOD_256 = 0x0001,
46     DL_PRIME_MOD_384 = 0x0002,
47 } PakeDlPrimeMod;
48 
49 typedef struct PakeBaseParamsT {
50     Uint8Buff salt;
51     Uint8Buff psk;
52     Uint8Buff challengeSelf;
53     Uint8Buff challengePeer;
54     Uint8Buff base;
55     Uint8Buff eskSelf;
56     Uint8Buff epkSelf;
57     Uint8Buff epkPeer;
58     Uint8Buff idSelf;
59     Uint8Buff idPeer;
60     Uint8Buff sessionKey;
61     Uint8Buff sharedSecret;
62     Uint8Buff hmacKey;
63     Uint8Buff kcfData;
64     Uint8Buff kcfDataPeer;
65     Uint8Buff extraData;
66     uint32_t innerKeyLen;
67     const char *largePrimeNumHex;
68     PakeDlPrimeMod supportedDlPrimeMod; // default: DL_PRIME_MOD_NONE
69     CurveType curveType; // default: CURVE_NONE
70     PakeAlgType supportedPakeAlg;
71     bool isClient;
72 
73     const AlgLoader *loader;
74 } PakeBaseParams;
75 
76 void CleanPakeSensitiveKeys(PakeBaseParams *params);
77 
78 #endif