]>
git.ipfire.org Git - thirdparty/hostap.git/blob - src/utils/ext_password.c
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 static const struct ext_password_backend
*backends
[] = {
20 #ifdef CONFIG_EXT_PASSWORD_TEST
22 #endif /* CONFIG_EXT_PASSWORD_TEST */
26 struct ext_password_data
{
27 const struct ext_password_backend
*backend
;
32 struct ext_password_data
* ext_password_init(const char *backend
,
35 struct ext_password_data
*data
;
38 data
= os_zalloc(sizeof(*data
));
42 for (i
= 0; backends
[i
]; i
++) {
43 if (os_strcmp(backends
[i
]->name
, backend
) == 0) {
44 data
->backend
= backends
[i
];
54 data
->priv
= data
->backend
->init(params
);
55 if (data
->priv
== NULL
) {
64 void ext_password_deinit(struct ext_password_data
*data
)
66 if (data
&& data
->backend
&& data
->priv
)
67 data
->backend
->deinit(data
->priv
);
72 struct wpabuf
* ext_password_get(struct ext_password_data
*data
,
77 return data
->backend
->get(data
->priv
, name
);
81 struct wpabuf
* ext_password_alloc(size_t len
)
85 buf
= wpabuf_alloc(len
);
90 if (mlock(wpabuf_head(buf
), wpabuf_len(buf
)) < 0) {
91 wpa_printf(MSG_ERROR
, "EXT PW: mlock failed: %s",
94 #endif /* __linux__ */
100 void ext_password_free(struct wpabuf
*pw
)
104 os_memset(wpabuf_mhead(pw
), 0, wpabuf_len(pw
));
106 if (munlock(wpabuf_head(pw
), wpabuf_len(pw
)) < 0) {
107 wpa_printf(MSG_ERROR
, "EXT PW: munlock failed: %s",
110 #endif /* __linux__ */