stoken: Implement new auth form to gather soft token information
[platform/upstream/openconnect.git] / ssl_ui.c
1 /*
2  * OpenConnect (SSL + DTLS) VPN client
3  *
4  * Copyright © 2008-2010 Intel Corporation.
5  *
6  * Author: David Woodhouse <dwmw2@infradead.org>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1, as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to:
19  *
20  *   Free Software Foundation, Inc.
21  *   51 Franklin Street, Fifth Floor,
22  *   Boston, MA 02110-1301 USA
23  */
24 #include <openssl/ssl.h>
25 #include <openssl/ui.h>
26
27 /* OpenSSL UI method calls. These are just stubs, to show how it's done */
28 /* While we can set user data on the calls from the TPM setup, we can't
29    set it on the calls for PEM certificate passphrases, AFAICT. */
30 static int ui_open(UI *ui)
31 {
32         /* Fall through to default OpenSSL UI */
33         return UI_method_get_opener(UI_OpenSSL())(ui);
34 }
35
36 static int ui_read(UI *ui, UI_STRING *uis)
37 {
38         /* Fall through to default OpenSSL UI */
39         return UI_method_get_reader(UI_OpenSSL())(ui, uis);
40 }
41 static int ui_write(UI *ui, UI_STRING *uis)
42 {
43         /* Fall through to default OpenSSL UI */
44         return UI_method_get_writer(UI_OpenSSL())(ui, uis);
45
46 }
47 static int ui_close(UI *ui)
48 {
49         /* Fall through to default OpenSSL UI */
50         return UI_method_get_closer(UI_OpenSSL())(ui);
51 }
52
53 int set_openssl_ui(void)
54 {
55         UI_METHOD *ui_method = UI_create_method("AnyConnect VPN UI");
56
57         /* Set up a UI method of our own for password/passphrase requests */
58         UI_method_set_opener(ui_method, ui_open);
59         UI_method_set_reader(ui_method, ui_read);
60         UI_method_set_writer(ui_method, ui_write);
61         UI_method_set_closer(ui_method, ui_close);
62
63         UI_set_default_method(ui_method);
64
65         return 0;
66 }
67