3 * Copyright (c) 2013, Qualcomm Atheros, Inc.
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #include "utils/common.h"
12 #include "utils/eloop.h"
13 #include "common/defs.h"
14 #include "drivers/driver.h"
15 #include "pae/ieee802_1x_kay.h"
16 #include "pae/ieee802_1x_kay_i.h"
17 #include "pae/ieee802_1x_secy_ops.h"
20 int secy_cp_control_validate_frames(struct ieee802_1x_kay *kay,
21 enum validate_frames vf)
28 int secy_cp_control_protect_frames(struct ieee802_1x_kay *kay, Boolean enabled)
30 struct ieee802_1x_kay_ctx *ops;
33 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
38 if (!ops || !ops->enable_protect_frames) {
40 "KaY: secy enable_protect_frames operation not supported");
44 return ops->enable_protect_frames(ops->ctx, enabled);
48 int secy_cp_control_replay(struct ieee802_1x_kay *kay, Boolean enabled, u32 win)
50 struct ieee802_1x_kay_ctx *ops;
53 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
58 if (!ops || !ops->set_replay_protect) {
60 "KaY: secy set_replay_protect operation not supported");
64 return ops->set_replay_protect(ops->ctx, enabled, win);
68 int secy_cp_control_current_cipher_suite(struct ieee802_1x_kay *kay, u64 cs)
70 struct ieee802_1x_kay_ctx *ops;
73 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
78 if (!ops || !ops->set_current_cipher_suite) {
80 "KaY: secy set_current_cipher_suite operation not supported");
84 return ops->set_current_cipher_suite(ops->ctx, cs);
88 int secy_cp_control_confidentiality_offset(struct ieee802_1x_kay *kay,
89 enum confidentiality_offset co)
96 int secy_cp_control_enable_port(struct ieee802_1x_kay *kay, Boolean enabled)
98 struct ieee802_1x_kay_ctx *ops;
101 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
106 if (!ops || !ops->enable_controlled_port) {
107 wpa_printf(MSG_ERROR,
108 "KaY: secy enable_controlled_port operation not supported");
112 return ops->enable_controlled_port(ops->ctx, enabled);
116 int secy_get_receive_lowest_pn(struct ieee802_1x_kay *kay,
117 struct receive_sa *rxsa)
119 struct ieee802_1x_kay_ctx *ops;
122 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
127 if (!ops || !ops->get_receive_lowest_pn) {
128 wpa_printf(MSG_ERROR,
129 "KaY: secy get_receive_lowest_pn operation not supported");
133 return ops->get_receive_lowest_pn(ops->ctx,
140 int secy_get_transmit_next_pn(struct ieee802_1x_kay *kay,
141 struct transmit_sa *txsa)
143 struct ieee802_1x_kay_ctx *ops;
146 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
151 if (!ops || !ops->get_transmit_next_pn) {
152 wpa_printf(MSG_ERROR,
153 "KaY: secy get_receive_lowest_pn operation not supported");
157 return ops->get_transmit_next_pn(ops->ctx,
164 int secy_set_transmit_next_pn(struct ieee802_1x_kay *kay,
165 struct transmit_sa *txsa)
167 struct ieee802_1x_kay_ctx *ops;
170 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
175 if (!ops || !ops->set_transmit_next_pn) {
176 wpa_printf(MSG_ERROR,
177 "KaY: secy get_receive_lowest_pn operation not supported");
181 return ops->set_transmit_next_pn(ops->ctx,
188 int secy_get_available_receive_sc(struct ieee802_1x_kay *kay, u32 *channel)
190 struct ieee802_1x_kay_ctx *ops;
193 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
198 if (!ops || !ops->get_available_receive_sc) {
199 wpa_printf(MSG_ERROR,
200 "KaY: secy get_available_receive_sc operation not supported");
204 return ops->get_available_receive_sc(ops->ctx, channel);
208 int secy_create_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
210 struct ieee802_1x_kay_ctx *ops;
213 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
218 if (!ops || !ops->create_receive_sc) {
219 wpa_printf(MSG_ERROR,
220 "KaY: secy create_receive_sc operation not supported");
224 return ops->create_receive_sc(ops->ctx, rxsc->channel, &rxsc->sci,
229 int secy_delete_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
231 struct ieee802_1x_kay_ctx *ops;
234 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
239 if (!ops || !ops->delete_receive_sc) {
240 wpa_printf(MSG_ERROR,
241 "KaY: secy delete_receive_sc operation not supported");
245 return ops->delete_receive_sc(ops->ctx, rxsc->channel);
249 int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
251 struct ieee802_1x_kay_ctx *ops;
254 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
259 if (!ops || !ops->create_receive_sa) {
260 wpa_printf(MSG_ERROR,
261 "KaY: secy create_receive_sa operation not supported");
265 return ops->create_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an,
266 rxsa->lowest_pn, rxsa->pkey->key);
270 int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
272 struct ieee802_1x_kay_ctx *ops;
275 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
280 if (!ops || !ops->enable_receive_sa) {
281 wpa_printf(MSG_ERROR,
282 "KaY: secy enable_receive_sa operation not supported");
286 rxsa->enable_receive = TRUE;
288 return ops->enable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
292 int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
294 struct ieee802_1x_kay_ctx *ops;
297 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
302 if (!ops || !ops->disable_receive_sa) {
303 wpa_printf(MSG_ERROR,
304 "KaY: secy disable_receive_sa operation not supported");
308 rxsa->enable_receive = FALSE;
310 return ops->disable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
314 int secy_get_available_transmit_sc(struct ieee802_1x_kay *kay, u32 *channel)
316 struct ieee802_1x_kay_ctx *ops;
319 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
324 if (!ops || !ops->get_available_transmit_sc) {
325 wpa_printf(MSG_ERROR,
326 "KaY: secy get_available_transmit_sc operation not supported");
330 return ops->get_available_transmit_sc(ops->ctx, channel);
334 int secy_create_transmit_sc(struct ieee802_1x_kay *kay,
335 struct transmit_sc *txsc)
337 struct ieee802_1x_kay_ctx *ops;
340 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
345 if (!ops || !ops->create_transmit_sc) {
346 wpa_printf(MSG_ERROR,
347 "KaY: secy create_transmit_sc operation not supported");
351 return ops->create_transmit_sc(ops->ctx, txsc->channel, &txsc->sci,
356 int secy_delete_transmit_sc(struct ieee802_1x_kay *kay,
357 struct transmit_sc *txsc)
359 struct ieee802_1x_kay_ctx *ops;
362 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
367 if (!ops || !ops->delete_transmit_sc) {
368 wpa_printf(MSG_ERROR,
369 "KaY: secy delete_transmit_sc operation not supported");
373 return ops->delete_transmit_sc(ops->ctx, txsc->channel);
377 int secy_create_transmit_sa(struct ieee802_1x_kay *kay,
378 struct transmit_sa *txsa)
380 struct ieee802_1x_kay_ctx *ops;
383 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
388 if (!ops || !ops->create_transmit_sa) {
389 wpa_printf(MSG_ERROR,
390 "KaY: secy create_transmit_sa operation not supported");
394 return ops->create_transmit_sa(ops->ctx, txsa->sc->channel, txsa->an,
395 txsa->next_pn, txsa->confidentiality,
400 int secy_enable_transmit_sa(struct ieee802_1x_kay *kay,
401 struct transmit_sa *txsa)
403 struct ieee802_1x_kay_ctx *ops;
406 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
411 if (!ops || !ops->enable_transmit_sa) {
412 wpa_printf(MSG_ERROR,
413 "KaY: secy enable_transmit_sa operation not supported");
417 txsa->enable_transmit = TRUE;
419 return ops->enable_transmit_sa(ops->ctx, txsa->sc->channel, txsa->an);
423 int secy_disable_transmit_sa(struct ieee802_1x_kay *kay,
424 struct transmit_sa *txsa)
426 struct ieee802_1x_kay_ctx *ops;
429 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
434 if (!ops || !ops->disable_transmit_sa) {
435 wpa_printf(MSG_ERROR,
436 "KaY: secy disable_transmit_sa operation not supported");
440 txsa->enable_transmit = FALSE;
442 return ops->disable_transmit_sa(ops->ctx, txsa->sc->channel, txsa->an);
446 int secy_init_macsec(struct ieee802_1x_kay *kay)
449 struct ieee802_1x_kay_ctx *ops;
450 struct macsec_init_params params;
453 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
458 if (!ops || !ops->macsec_init) {
459 wpa_printf(MSG_ERROR,
460 "KaY: secy macsec_init operation not supported");
464 params.use_es = FALSE;
465 params.use_scb = FALSE;
466 params.always_include_sci = TRUE;
468 ret = ops->macsec_init(ops->ctx, ¶ms);
474 int secy_deinit_macsec(struct ieee802_1x_kay *kay)
476 struct ieee802_1x_kay_ctx *ops;
479 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
484 if (!ops || !ops->macsec_deinit) {
485 wpa_printf(MSG_ERROR,
486 "KaY: secy macsec_deinit operation not supported");
490 return ops->macsec_deinit(ops->ctx);