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,
69 const u8 *cs, size_t cs_len)
71 struct ieee802_1x_kay_ctx *ops;
74 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
79 if (!ops || !ops->set_current_cipher_suite) {
81 "KaY: secy set_current_cipher_suite operation not supported");
85 return ops->set_current_cipher_suite(ops->ctx, cs, cs_len);
89 int secy_cp_control_confidentiality_offset(struct ieee802_1x_kay *kay,
90 enum confidentiality_offset co)
97 int secy_cp_control_enable_port(struct ieee802_1x_kay *kay, Boolean enabled)
99 struct ieee802_1x_kay_ctx *ops;
102 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
107 if (!ops || !ops->enable_controlled_port) {
108 wpa_printf(MSG_ERROR,
109 "KaY: secy enable_controlled_port operation not supported");
113 return ops->enable_controlled_port(ops->ctx, enabled);
117 int secy_get_receive_lowest_pn(struct ieee802_1x_kay *kay,
118 struct receive_sa *rxsa)
120 struct ieee802_1x_kay_ctx *ops;
123 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
128 if (!ops || !ops->get_receive_lowest_pn) {
129 wpa_printf(MSG_ERROR,
130 "KaY: secy get_receive_lowest_pn operation not supported");
134 return ops->get_receive_lowest_pn(ops->ctx,
141 int secy_get_transmit_next_pn(struct ieee802_1x_kay *kay,
142 struct transmit_sa *txsa)
144 struct ieee802_1x_kay_ctx *ops;
147 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
152 if (!ops || !ops->get_transmit_next_pn) {
153 wpa_printf(MSG_ERROR,
154 "KaY: secy get_receive_lowest_pn operation not supported");
158 return ops->get_transmit_next_pn(ops->ctx,
165 int secy_set_transmit_next_pn(struct ieee802_1x_kay *kay,
166 struct transmit_sa *txsa)
168 struct ieee802_1x_kay_ctx *ops;
171 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
176 if (!ops || !ops->set_transmit_next_pn) {
177 wpa_printf(MSG_ERROR,
178 "KaY: secy get_receive_lowest_pn operation not supported");
182 return ops->set_transmit_next_pn(ops->ctx,
189 int secy_get_available_receive_sc(struct ieee802_1x_kay *kay, u32 *channel)
191 struct ieee802_1x_kay_ctx *ops;
194 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
199 if (!ops || !ops->get_available_receive_sc) {
200 wpa_printf(MSG_ERROR,
201 "KaY: secy get_available_receive_sc operation not supported");
205 return ops->get_available_receive_sc(ops->ctx, channel);
209 int secy_create_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
211 struct ieee802_1x_kay_ctx *ops;
214 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
219 if (!ops || !ops->create_receive_sc) {
220 wpa_printf(MSG_ERROR,
221 "KaY: secy create_receive_sc operation not supported");
225 return ops->create_receive_sc(ops->ctx, rxsc->channel, &rxsc->sci,
230 int secy_delete_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
232 struct ieee802_1x_kay_ctx *ops;
235 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
240 if (!ops || !ops->delete_receive_sc) {
241 wpa_printf(MSG_ERROR,
242 "KaY: secy delete_receive_sc operation not supported");
246 return ops->delete_receive_sc(ops->ctx, rxsc->channel);
250 int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
252 struct ieee802_1x_kay_ctx *ops;
255 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
260 if (!ops || !ops->create_receive_sa) {
261 wpa_printf(MSG_ERROR,
262 "KaY: secy create_receive_sa operation not supported");
266 return ops->create_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an,
267 rxsa->lowest_pn, rxsa->pkey->key);
271 int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
273 struct ieee802_1x_kay_ctx *ops;
276 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
281 if (!ops || !ops->enable_receive_sa) {
282 wpa_printf(MSG_ERROR,
283 "KaY: secy enable_receive_sa operation not supported");
287 rxsa->enable_receive = TRUE;
289 return ops->enable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
293 int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
295 struct ieee802_1x_kay_ctx *ops;
298 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
303 if (!ops || !ops->disable_receive_sa) {
304 wpa_printf(MSG_ERROR,
305 "KaY: secy disable_receive_sa operation not supported");
309 rxsa->enable_receive = FALSE;
311 return ops->disable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
315 int secy_get_available_transmit_sc(struct ieee802_1x_kay *kay, u32 *channel)
317 struct ieee802_1x_kay_ctx *ops;
320 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
325 if (!ops || !ops->get_available_transmit_sc) {
326 wpa_printf(MSG_ERROR,
327 "KaY: secy get_available_transmit_sc operation not supported");
331 return ops->get_available_transmit_sc(ops->ctx, channel);
335 int secy_create_transmit_sc(struct ieee802_1x_kay *kay,
336 struct transmit_sc *txsc)
338 struct ieee802_1x_kay_ctx *ops;
341 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
346 if (!ops || !ops->create_transmit_sc) {
347 wpa_printf(MSG_ERROR,
348 "KaY: secy create_transmit_sc operation not supported");
352 return ops->create_transmit_sc(ops->ctx, txsc->channel, &txsc->sci,
357 int secy_delete_transmit_sc(struct ieee802_1x_kay *kay,
358 struct transmit_sc *txsc)
360 struct ieee802_1x_kay_ctx *ops;
363 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
368 if (!ops || !ops->delete_transmit_sc) {
369 wpa_printf(MSG_ERROR,
370 "KaY: secy delete_transmit_sc operation not supported");
374 return ops->delete_transmit_sc(ops->ctx, txsc->channel);
378 int secy_create_transmit_sa(struct ieee802_1x_kay *kay,
379 struct transmit_sa *txsa)
381 struct ieee802_1x_kay_ctx *ops;
384 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
389 if (!ops || !ops->create_transmit_sa) {
390 wpa_printf(MSG_ERROR,
391 "KaY: secy create_transmit_sa operation not supported");
395 return ops->create_transmit_sa(ops->ctx, txsa->sc->channel, txsa->an,
396 txsa->next_pn, txsa->confidentiality,
401 int secy_enable_transmit_sa(struct ieee802_1x_kay *kay,
402 struct transmit_sa *txsa)
404 struct ieee802_1x_kay_ctx *ops;
407 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
412 if (!ops || !ops->enable_transmit_sa) {
413 wpa_printf(MSG_ERROR,
414 "KaY: secy enable_transmit_sa operation not supported");
418 txsa->enable_transmit = TRUE;
420 return ops->enable_transmit_sa(ops->ctx, txsa->sc->channel, txsa->an);
424 int secy_disable_transmit_sa(struct ieee802_1x_kay *kay,
425 struct transmit_sa *txsa)
427 struct ieee802_1x_kay_ctx *ops;
430 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
435 if (!ops || !ops->disable_transmit_sa) {
436 wpa_printf(MSG_ERROR,
437 "KaY: secy disable_transmit_sa operation not supported");
441 txsa->enable_transmit = FALSE;
443 return ops->disable_transmit_sa(ops->ctx, txsa->sc->channel, txsa->an);
447 int secy_init_macsec(struct ieee802_1x_kay *kay)
450 struct ieee802_1x_kay_ctx *ops;
451 struct macsec_init_params params;
454 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
459 if (!ops || !ops->macsec_init) {
460 wpa_printf(MSG_ERROR,
461 "KaY: secy macsec_init operation not supported");
465 params.use_es = FALSE;
466 params.use_scb = FALSE;
467 params.always_include_sci = TRUE;
469 ret = ops->macsec_init(ops->ctx, ¶ms);
475 int secy_deinit_macsec(struct ieee802_1x_kay *kay)
477 struct ieee802_1x_kay_ctx *ops;
480 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
485 if (!ops || !ops->macsec_deinit) {
486 wpa_printf(MSG_ERROR,
487 "KaY: secy macsec_deinit operation not supported");
491 return ops->macsec_deinit(ops->ctx);