ikev2.h revision 252726
1272234Sgjb/*
2272234Sgjb * IKEv2 initiator (RFC 4306) for EAP-IKEV2
3272234Sgjb * Copyright (c) 2007, Jouni Malinen <j@w1.fi>
4272234Sgjb *
5272234Sgjb * This software may be distributed under the terms of the BSD license.
6272234Sgjb * See README for more details.
7272234Sgjb */
8272234Sgjb
9272234Sgjb#ifndef IKEV2_H
10272234Sgjb#define IKEV2_H
11272234Sgjb
12272234Sgjb#include "eap_common/ikev2_common.h"
13272234Sgjb
14272234Sgjbstruct ikev2_proposal_data {
15272234Sgjb	u8 proposal_num;
16272234Sgjb	int integ;
17272234Sgjb	int prf;
18272234Sgjb	int encr;
19272234Sgjb	int dh;
20272234Sgjb};
21272234Sgjb
22272234Sgjb
23272234Sgjbstruct ikev2_initiator_data {
24272234Sgjb	enum { SA_INIT, SA_AUTH, CHILD_SA, IKEV2_DONE } state;
25272234Sgjb	u8 i_spi[IKEV2_SPI_LEN];
26272234Sgjb	u8 r_spi[IKEV2_SPI_LEN];
27272234Sgjb	u8 i_nonce[IKEV2_NONCE_MAX_LEN];
28272234Sgjb	size_t i_nonce_len;
29272234Sgjb	u8 r_nonce[IKEV2_NONCE_MAX_LEN];
30272234Sgjb	size_t r_nonce_len;
31272234Sgjb	struct wpabuf *r_dh_public;
32272234Sgjb	struct wpabuf *i_dh_private;
33272234Sgjb	struct ikev2_proposal_data proposal;
34272234Sgjb	const struct dh_group *dh;
35272234Sgjb	struct ikev2_keys keys;
36272234Sgjb	u8 *IDi;
37272234Sgjb	size_t IDi_len;
38272380Sgjb	u8 *IDr;
39272380Sgjb	size_t IDr_len;
40272380Sgjb	u8 IDr_type;
41272380Sgjb	struct wpabuf *r_sign_msg;
42272380Sgjb	struct wpabuf *i_sign_msg;
43272380Sgjb	u8 *shared_secret;
44272380Sgjb	size_t shared_secret_len;
45272380Sgjb	enum { PEER_AUTH_CERT, PEER_AUTH_SECRET } peer_auth;
46272380Sgjb	u8 *key_pad;
47272380Sgjb	size_t key_pad_len;
48272380Sgjb
49272380Sgjb	const u8 * (*get_shared_secret)(void *ctx, const u8 *IDr,
50272234Sgjb					size_t IDr_len, size_t *secret_len);
51272380Sgjb	void *cb_ctx;
52272380Sgjb	int unknown_user;
53272380Sgjb};
54272380Sgjb
55272380Sgjb
56272380Sgjbvoid ikev2_initiator_deinit(struct ikev2_initiator_data *data);
57272234Sgjbint ikev2_initiator_process(struct ikev2_initiator_data *data,
58272234Sgjb			    const struct wpabuf *buf);
59272234Sgjbstruct wpabuf * ikev2_initiator_build(struct ikev2_initiator_data *data);
60272234Sgjb
61272234Sgjb#endif /* IKEV2_H */
62272234Sgjb