1 /*
2 * Copyright (c) 2020 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_CLIENT_H__
17 #define __PAKE_CLIENT_H__
18
19 #include "hichain.h"
20 #include "base.h"
21
22 #if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_CLIENT_))
23
24 #include "pake_server.h"
25 #include "key_agreement_client.h"
26
27 struct pake_client {
28 struct key_agreement_client client_info;
29 uint32_t key_length;
30 struct hc_pin pin;
31 struct hc_salt salt;
32 struct hc_auth_id self_id;
33 struct hc_auth_id peer_id;
34 struct challenge self_challenge;
35 struct challenge peer_challenge;
36 struct esk self_esk;
37 struct pake_session_key session_key;
38 struct pake_hmac_key hmac_key;
39 struct hc_session_key service_key;
40 enum large_prime_number_type prime_type;
41 struct epk self_epk;
42 struct epk peer_epk;
43 struct pake_shared_secret shared_secret;
44 struct hmac kcf_data;
45 const struct session_identity *identity;
46 int32_t operation_code;
47 };
48
pake_client_sn(struct pake_client * client)49 static inline uint32_t pake_client_sn(struct pake_client *client)
50 {
51 return client->client_info.protocol_base_info.sn;
52 }
53
54 int32_t send_pake_start_request(struct pake_client *pake_client, struct message *send);
55 int32_t send_pake_end_request(struct pake_client *pake_client, const struct message *receive, struct message *send);
56 int32_t receive_pake_end_response(struct pake_client *pake_client, struct message *receive);
57
58 #else /* _CUT_XXX_ */
59
60 struct pake_client {
61 char rsv;
62 };
63
64 #endif /* _CUT_XXX_ */
65
66 struct pake_client *build_pake_client(const struct session_identity *identity, const struct hc_pin *pin,
67 uint32_t key_length, const struct hc_auth_id *client, const struct hc_auth_id *server);
68 void destroy_pake_client(struct pake_client *pake_client);
69
70 #endif /* __PAKE_CLIENT_H__ */
71