2 * External password backend
3 * Copyright (c) 2012, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
13 #endif /* __linux__ */
16 #include "ext_password_i.h"
19 #ifdef CONFIG_EXT_PASSWORD_TEST
20 extern struct ext_password_backend ext_password_test;
21 #endif /* CONFIG_EXT_PASSWORD_TEST */
23 static const struct ext_password_backend *backends[] = {
24 #ifdef CONFIG_EXT_PASSWORD_TEST
26 #endif /* CONFIG_EXT_PASSWORD_TEST */
30 struct ext_password_data {
31 const struct ext_password_backend *backend;
36 struct ext_password_data * ext_password_init(const char *backend,
39 struct ext_password_data *data;
42 data = os_zalloc(sizeof(*data));
46 for (i = 0; backends[i]; i++) {
47 if (os_strcmp(backends[i]->name, backend) == 0) {
48 data->backend = backends[i];
58 data->priv = data->backend->init(params);
59 if (data->priv == NULL) {
68 void ext_password_deinit(struct ext_password_data *data)
70 if (data && data->backend && data->priv)
71 data->backend->deinit(data->priv);
76 struct wpabuf * ext_password_get(struct ext_password_data *data,
81 return data->backend->get(data->priv, name);
85 struct wpabuf * ext_password_alloc(size_t len)
89 buf = wpabuf_alloc(len);
94 if (mlock(wpabuf_head(buf), wpabuf_len(buf)) < 0) {
95 wpa_printf(MSG_ERROR, "EXT PW: mlock failed: %s",
98 #endif /* __linux__ */
104 void ext_password_free(struct wpabuf *pw)
108 os_memset(wpabuf_mhead(pw), 0, wpabuf_len(pw));
110 if (munlock(wpabuf_head(pw), wpabuf_len(pw)) < 0) {
111 wpa_printf(MSG_ERROR, "EXT PW: munlock failed: %s",
114 #endif /* __linux__ */