updated Doxyfile
[strongswan.git] / src / charon / sa / authenticators / authenticator.c
1 /*
2 * Copyright (C) 2008 Tobias Brunner
3 * Copyright (C) 2006-2008 Martin Willi
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 #include <string.h>
20
21 #include "authenticator.h"
22
23 #include <sa/authenticators/pubkey_authenticator.h>
24 #include <sa/authenticators/psk_authenticator.h>
25 #include <sa/authenticators/eap_authenticator.h>
26
27
28 ENUM_BEGIN(auth_method_names, AUTH_RSA, AUTH_DSS,
29 "RSA signature",
30 "pre-shared key",
31 "DSS signature");
32 ENUM_NEXT(auth_method_names, AUTH_ECDSA_256, AUTH_ECDSA_521, AUTH_DSS,
33 "ECDSA-256 signature",
34 "ECDSA-384 signature",
35 "ECDSA-521 signature");
36 ENUM_END(auth_method_names, AUTH_ECDSA_521);
37
38 ENUM(auth_class_names, AUTH_CLASS_PUBKEY, AUTH_CLASS_EAP,
39 "public key",
40 "pre-shared key",
41 "EAP",
42 );
43
44 /**
45 * Described in header.
46 */
47 authenticator_t *authenticator_create_from_class(ike_sa_t *ike_sa,
48 auth_class_t class)
49 {
50 switch (class)
51 {
52 case AUTH_CLASS_PUBKEY:
53 return (authenticator_t*)pubkey_authenticator_create(ike_sa);
54 case AUTH_CLASS_PSK:
55 return (authenticator_t*)psk_authenticator_create(ike_sa);
56 case AUTH_CLASS_EAP:
57 return (authenticator_t*)eap_authenticator_create(ike_sa);
58 default:
59 return NULL;
60 }
61 }
62
63 /**
64 * Described in header.
65 */
66 authenticator_t *authenticator_create_from_method(ike_sa_t *ike_sa,
67 auth_method_t method)
68 {
69 switch (method)
70 {
71 case AUTH_RSA:
72 case AUTH_ECDSA_256:
73 case AUTH_ECDSA_384:
74 case AUTH_ECDSA_521:
75 return (authenticator_t*)pubkey_authenticator_create(ike_sa);
76 case AUTH_PSK:
77 return (authenticator_t*)psk_authenticator_create(ike_sa);
78 default:
79 return NULL;
80 }
81 }