created signature_scheme_from_oid() helper function
[strongswan.git] / src / libstrongswan / credentials / keys / public_key.c
1 /*
2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 #include <asn1/oid.h>
17
18 #include "public_key.h"
19
20 ENUM(key_type_names, KEY_RSA, KEY_DSA,
21 "RSA",
22 "ECDSA",
23 "DSA"
24 );
25
26 ENUM(signature_scheme_names, SIGN_UNKNOWN, SIGN_ECDSA_521,
27 "UNKNOWN",
28 "DEFAULT",
29 "RSA_EMSA_PKCS1_NULL",
30 "RSA_EMSA_PKCS1_MD5",
31 "RSA_EMSA_PKCS1_SHA1",
32 "RSA_EMSA_PKCS1_SHA256",
33 "RSA_EMSA_PKCS1_SHA384",
34 "RSA_EMSA_PKCS1_SHA512",
35 "ECDSA_WITH_SHA1",
36 "ECDSA-256",
37 "ECDSA-384",
38 "ECDSA-521",
39 );
40
41 /*
42 * Defined in header.
43 */
44 signature_scheme_t signature_scheme_from_oid(int oid)
45 {
46 switch (oid)
47 {
48 case OID_MD5_WITH_RSA:
49 case OID_MD5:
50 return SIGN_RSA_EMSA_PKCS1_MD5;
51 case OID_SHA1_WITH_RSA:
52 case OID_SHA1:
53 return SIGN_RSA_EMSA_PKCS1_SHA1;
54 case OID_SHA256_WITH_RSA:
55 case OID_SHA256:
56 return SIGN_RSA_EMSA_PKCS1_SHA256;
57 case OID_SHA384_WITH_RSA:
58 case OID_SHA384:
59 return SIGN_RSA_EMSA_PKCS1_SHA384;
60 case OID_SHA512_WITH_RSA:
61 case OID_SHA512:
62 return SIGN_RSA_EMSA_PKCS1_SHA512;
63 case OID_ECDSA_WITH_SHA1:
64 case OID_EC_PUBLICKEY:
65 return SIGN_ECDSA_WITH_SHA1;
66 default:
67 return SIGN_UNKNOWN;
68 }
69 }
70