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_encrypt(struct ieee802_1x_kay *kay, Boolean enabled)
50 struct ieee802_1x_kay_ctx *ops;
53 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
58 if (!ops || !ops->enable_encrypt) {
60 "KaY: secy enable_encrypt operation not supported");
64 return ops->enable_encrypt(ops->ctx, enabled);
68 int secy_cp_control_replay(struct ieee802_1x_kay *kay, Boolean enabled, u32 win)
70 struct ieee802_1x_kay_ctx *ops;
73 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
78 if (!ops || !ops->set_replay_protect) {
80 "KaY: secy set_replay_protect operation not supported");
84 return ops->set_replay_protect(ops->ctx, enabled, win);
88 int secy_cp_control_current_cipher_suite(struct ieee802_1x_kay *kay, u64 cs)
90 struct ieee802_1x_kay_ctx *ops;
93 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
98 if (!ops || !ops->set_current_cipher_suite) {
100 "KaY: secy set_current_cipher_suite operation not supported");
104 return ops->set_current_cipher_suite(ops->ctx, cs);
108 int secy_cp_control_confidentiality_offset(struct ieee802_1x_kay *kay,
109 enum confidentiality_offset co)
116 int secy_cp_control_enable_port(struct ieee802_1x_kay *kay, Boolean enabled)
118 struct ieee802_1x_kay_ctx *ops;
121 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
126 if (!ops || !ops->enable_controlled_port) {
127 wpa_printf(MSG_ERROR,
128 "KaY: secy enable_controlled_port operation not supported");
132 return ops->enable_controlled_port(ops->ctx, enabled);
136 int secy_get_capability(struct ieee802_1x_kay *kay, enum macsec_cap *cap)
138 struct ieee802_1x_kay_ctx *ops;
141 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
146 if (!ops || !ops->macsec_get_capability) {
147 wpa_printf(MSG_ERROR,
148 "KaY: secy macsec_get_capability operation not supported");
152 return ops->macsec_get_capability(ops->ctx, cap);
156 int secy_get_receive_lowest_pn(struct ieee802_1x_kay *kay,
157 struct receive_sa *rxsa)
159 struct ieee802_1x_kay_ctx *ops;
162 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
167 if (!ops || !ops->get_receive_lowest_pn) {
168 wpa_printf(MSG_ERROR,
169 "KaY: secy get_receive_lowest_pn operation not supported");
173 return ops->get_receive_lowest_pn(ops->ctx, rxsa);
177 int secy_get_transmit_next_pn(struct ieee802_1x_kay *kay,
178 struct transmit_sa *txsa)
180 struct ieee802_1x_kay_ctx *ops;
183 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
188 if (!ops || !ops->get_transmit_next_pn) {
189 wpa_printf(MSG_ERROR,
190 "KaY: secy get_transmit_next_pn operation not supported");
194 return ops->get_transmit_next_pn(ops->ctx, txsa);
198 int secy_set_transmit_next_pn(struct ieee802_1x_kay *kay,
199 struct transmit_sa *txsa)
201 struct ieee802_1x_kay_ctx *ops;
204 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
209 if (!ops || !ops->set_transmit_next_pn) {
210 wpa_printf(MSG_ERROR,
211 "KaY: secy set_transmit_next_pn operation not supported");
215 return ops->set_transmit_next_pn(ops->ctx, txsa);
219 int secy_set_receive_lowest_pn(struct ieee802_1x_kay *kay,
220 struct receive_sa *rxsa)
222 struct ieee802_1x_kay_ctx *ops;
225 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
230 if (!ops || !ops->set_receive_lowest_pn) {
231 wpa_printf(MSG_ERROR,
232 "KaY: secy set_receive_lowest_pn operation not supported");
236 return ops->set_receive_lowest_pn(ops->ctx, rxsa);
240 int secy_create_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
242 struct ieee802_1x_kay_ctx *ops;
245 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
250 if (!ops || !ops->create_receive_sc) {
251 wpa_printf(MSG_ERROR,
252 "KaY: secy create_receive_sc operation not supported");
256 return ops->create_receive_sc(ops->ctx, rxsc, kay->vf, kay->co);
260 int secy_delete_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
262 struct ieee802_1x_kay_ctx *ops;
265 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
270 if (!ops || !ops->delete_receive_sc) {
271 wpa_printf(MSG_ERROR,
272 "KaY: secy delete_receive_sc operation not supported");
276 return ops->delete_receive_sc(ops->ctx, rxsc);
280 int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
282 struct ieee802_1x_kay_ctx *ops;
285 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
290 if (!ops || !ops->create_receive_sa) {
291 wpa_printf(MSG_ERROR,
292 "KaY: secy create_receive_sa operation not supported");
296 return ops->create_receive_sa(ops->ctx, rxsa);
300 int secy_delete_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
302 struct ieee802_1x_kay_ctx *ops;
305 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
310 if (!ops || !ops->delete_receive_sa) {
311 wpa_printf(MSG_ERROR,
312 "KaY: secy delete_receive_sa operation not supported");
316 return ops->delete_receive_sa(ops->ctx, rxsa);
320 int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
322 struct ieee802_1x_kay_ctx *ops;
325 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
330 if (!ops || !ops->enable_receive_sa) {
331 wpa_printf(MSG_ERROR,
332 "KaY: secy enable_receive_sa operation not supported");
336 rxsa->enable_receive = TRUE;
338 return ops->enable_receive_sa(ops->ctx, rxsa);
342 int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
344 struct ieee802_1x_kay_ctx *ops;
347 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
352 if (!ops || !ops->disable_receive_sa) {
353 wpa_printf(MSG_ERROR,
354 "KaY: secy disable_receive_sa operation not supported");
358 rxsa->enable_receive = FALSE;
360 return ops->disable_receive_sa(ops->ctx, rxsa);
364 int secy_create_transmit_sc(struct ieee802_1x_kay *kay,
365 struct transmit_sc *txsc)
367 struct ieee802_1x_kay_ctx *ops;
370 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
375 if (!ops || !ops->create_transmit_sc) {
376 wpa_printf(MSG_ERROR,
377 "KaY: secy create_transmit_sc operation not supported");
381 return ops->create_transmit_sc(ops->ctx, txsc, kay->co);
385 int secy_delete_transmit_sc(struct ieee802_1x_kay *kay,
386 struct transmit_sc *txsc)
388 struct ieee802_1x_kay_ctx *ops;
391 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
396 if (!ops || !ops->delete_transmit_sc) {
397 wpa_printf(MSG_ERROR,
398 "KaY: secy delete_transmit_sc operation not supported");
402 return ops->delete_transmit_sc(ops->ctx, txsc);
406 int secy_create_transmit_sa(struct ieee802_1x_kay *kay,
407 struct transmit_sa *txsa)
409 struct ieee802_1x_kay_ctx *ops;
412 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
417 if (!ops || !ops->create_transmit_sa) {
418 wpa_printf(MSG_ERROR,
419 "KaY: secy create_transmit_sa operation not supported");
423 return ops->create_transmit_sa(ops->ctx, txsa);
427 int secy_delete_transmit_sa(struct ieee802_1x_kay *kay,
428 struct transmit_sa *txsa)
430 struct ieee802_1x_kay_ctx *ops;
433 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
438 if (!ops || !ops->delete_transmit_sa) {
439 wpa_printf(MSG_ERROR,
440 "KaY: secy delete_transmit_sa operation not supported");
444 return ops->delete_transmit_sa(ops->ctx, txsa);
448 int secy_enable_transmit_sa(struct ieee802_1x_kay *kay,
449 struct transmit_sa *txsa)
451 struct ieee802_1x_kay_ctx *ops;
454 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
459 if (!ops || !ops->enable_transmit_sa) {
460 wpa_printf(MSG_ERROR,
461 "KaY: secy enable_transmit_sa operation not supported");
465 txsa->enable_transmit = TRUE;
467 return ops->enable_transmit_sa(ops->ctx, txsa);
471 int secy_disable_transmit_sa(struct ieee802_1x_kay *kay,
472 struct transmit_sa *txsa)
474 struct ieee802_1x_kay_ctx *ops;
477 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
482 if (!ops || !ops->disable_transmit_sa) {
483 wpa_printf(MSG_ERROR,
484 "KaY: secy disable_transmit_sa operation not supported");
488 txsa->enable_transmit = FALSE;
490 return ops->disable_transmit_sa(ops->ctx, txsa);
494 int secy_init_macsec(struct ieee802_1x_kay *kay)
497 struct ieee802_1x_kay_ctx *ops;
498 struct macsec_init_params params;
501 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
506 if (!ops || !ops->macsec_init) {
507 wpa_printf(MSG_ERROR,
508 "KaY: secy macsec_init operation not supported");
512 params.use_es = FALSE;
513 params.use_scb = FALSE;
514 params.always_include_sci = TRUE;
516 ret = ops->macsec_init(ops->ctx, ¶ms);
522 int secy_deinit_macsec(struct ieee802_1x_kay *kay)
524 struct ieee802_1x_kay_ctx *ops;
527 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
532 if (!ops || !ops->macsec_deinit) {
533 wpa_printf(MSG_ERROR,
534 "KaY: secy macsec_deinit operation not supported");
538 return ops->macsec_deinit(ops->ctx);