2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * Convert a form string to a encoding type
24 bool get_form(char *form
, key_encoding_type_t
*type
, bool pub
)
26 if (streq(form
, "der"))
28 /* der encoded keys usually contain the complete SubjectPublicKeyInfo */
29 *type
= pub ? KEY_PUB_SPKI_ASN1_DER
: KEY_PRIV_ASN1_DER
;
31 else if (streq(form
, "pem"))
33 *type
= pub ? KEY_PUB_PEM
: KEY_PRIV_PEM
;
35 else if (streq(form
, "pgp"))
37 *type
= pub ? KEY_PUB_PGP
: KEY_PRIV_PGP
;
47 * Convert a digest string to a hash algorithm
49 hash_algorithm_t
get_digest(char *name
)
51 if (streq(name
, "md5"))
55 if (streq(name
, "sha1"))
59 if (streq(name
, "sha224"))
63 if (streq(name
, "sha256"))
67 if (streq(name
, "sha384"))
71 if (streq(name
, "sha512"))
79 * Library initialization and operation parsing
81 int main(int argc
, char *argv
[])
83 atexit(library_deinit
);
84 if (!library_init(NULL
))
86 exit(SS_RC_LIBSTRONGSWAN_INTEGRITY
);
89 !lib
->integrity
->check_file(lib
->integrity
, "pki", argv
[0]))
91 fprintf(stderr
, "integrity check of pki failed\n");
92 exit(SS_RC_DAEMON_INTEGRITY
);
94 if (!lib
->plugins
->load(lib
->plugins
, NULL
,
95 lib
->settings
->get_str(lib
->settings
, "pki.load", PLUGINS
)))
97 exit(SS_RC_INITIALIZATION_FAILED
);
99 return command_dispatch(argc
, argv
);