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_receive_lowest_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 get_receive_lowest_pn operation not supported");
215 return ops->set_transmit_next_pn(ops->ctx, txsa);
219 int secy_create_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
221 struct ieee802_1x_kay_ctx *ops;
224 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
229 if (!ops || !ops->create_receive_sc) {
230 wpa_printf(MSG_ERROR,
231 "KaY: secy create_receive_sc operation not supported");
235 return ops->create_receive_sc(ops->ctx, rxsc, kay->vf, kay->co);
239 int secy_delete_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
241 struct ieee802_1x_kay_ctx *ops;
244 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
249 if (!ops || !ops->delete_receive_sc) {
250 wpa_printf(MSG_ERROR,
251 "KaY: secy delete_receive_sc operation not supported");
255 return ops->delete_receive_sc(ops->ctx, rxsc);
259 int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
261 struct ieee802_1x_kay_ctx *ops;
264 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
269 if (!ops || !ops->create_receive_sa) {
270 wpa_printf(MSG_ERROR,
271 "KaY: secy create_receive_sa operation not supported");
275 return ops->create_receive_sa(ops->ctx, rxsa);
279 int secy_delete_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
281 struct ieee802_1x_kay_ctx *ops;
284 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
289 if (!ops || !ops->delete_receive_sa) {
290 wpa_printf(MSG_ERROR,
291 "KaY: secy delete_receive_sa operation not supported");
295 return ops->delete_receive_sa(ops->ctx, rxsa);
299 int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
301 struct ieee802_1x_kay_ctx *ops;
304 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
309 if (!ops || !ops->enable_receive_sa) {
310 wpa_printf(MSG_ERROR,
311 "KaY: secy enable_receive_sa operation not supported");
315 rxsa->enable_receive = TRUE;
317 return ops->enable_receive_sa(ops->ctx, rxsa);
321 int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
323 struct ieee802_1x_kay_ctx *ops;
326 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
331 if (!ops || !ops->disable_receive_sa) {
332 wpa_printf(MSG_ERROR,
333 "KaY: secy disable_receive_sa operation not supported");
337 rxsa->enable_receive = FALSE;
339 return ops->disable_receive_sa(ops->ctx, rxsa);
343 int secy_create_transmit_sc(struct ieee802_1x_kay *kay,
344 struct transmit_sc *txsc)
346 struct ieee802_1x_kay_ctx *ops;
349 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
354 if (!ops || !ops->create_transmit_sc) {
355 wpa_printf(MSG_ERROR,
356 "KaY: secy create_transmit_sc operation not supported");
360 return ops->create_transmit_sc(ops->ctx, txsc, kay->co);
364 int secy_delete_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->delete_transmit_sc) {
376 wpa_printf(MSG_ERROR,
377 "KaY: secy delete_transmit_sc operation not supported");
381 return ops->delete_transmit_sc(ops->ctx, txsc);
385 int secy_create_transmit_sa(struct ieee802_1x_kay *kay,
386 struct transmit_sa *txsa)
388 struct ieee802_1x_kay_ctx *ops;
391 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
396 if (!ops || !ops->create_transmit_sa) {
397 wpa_printf(MSG_ERROR,
398 "KaY: secy create_transmit_sa operation not supported");
402 return ops->create_transmit_sa(ops->ctx, txsa);
406 int secy_delete_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->delete_transmit_sa) {
418 wpa_printf(MSG_ERROR,
419 "KaY: secy delete_transmit_sa operation not supported");
423 return ops->delete_transmit_sa(ops->ctx, txsa);
427 int secy_enable_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->enable_transmit_sa) {
439 wpa_printf(MSG_ERROR,
440 "KaY: secy enable_transmit_sa operation not supported");
444 txsa->enable_transmit = TRUE;
446 return ops->enable_transmit_sa(ops->ctx, txsa);
450 int secy_disable_transmit_sa(struct ieee802_1x_kay *kay,
451 struct transmit_sa *txsa)
453 struct ieee802_1x_kay_ctx *ops;
456 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
461 if (!ops || !ops->disable_transmit_sa) {
462 wpa_printf(MSG_ERROR,
463 "KaY: secy disable_transmit_sa operation not supported");
467 txsa->enable_transmit = FALSE;
469 return ops->disable_transmit_sa(ops->ctx, txsa);
473 int secy_init_macsec(struct ieee802_1x_kay *kay)
476 struct ieee802_1x_kay_ctx *ops;
477 struct macsec_init_params params;
480 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
485 if (!ops || !ops->macsec_init) {
486 wpa_printf(MSG_ERROR,
487 "KaY: secy macsec_init operation not supported");
491 params.use_es = FALSE;
492 params.use_scb = FALSE;
493 params.always_include_sci = TRUE;
495 ret = ops->macsec_init(ops->ctx, ¶ms);
501 int secy_deinit_macsec(struct ieee802_1x_kay *kay)
503 struct ieee802_1x_kay_ctx *ops;
506 wpa_printf(MSG_ERROR, "KaY: %s params invalid", __func__);
511 if (!ops || !ops->macsec_deinit) {
512 wpa_printf(MSG_ERROR,
513 "KaY: secy macsec_deinit operation not supported");
517 return ops->macsec_deinit(ops->ctx);