- renamed some files
[strongswan.git] / Source / lib / crypto / certificate.h
1 /**
2 * @file certificate.h
3 *
4 * @brief Interface of certificate_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef CERTIFICATE_H_
24 #define CERTIFICATE_H_
25
26 #include <types.h>
27 #include <definitions.h>
28 #include <crypto/rsa/rsa_public_key.h>
29 #include <utils/identification.h>
30 #include <utils/iterator.h>
31
32
33 typedef struct certificate_t certificate_t;
34
35 /**
36 * @brief X509 certificate.
37 *
38 * @b Constructors:
39 * - certificate_create_from_chunk()
40 *
41 * @ingroup transforms
42 */
43 struct certificate_t {
44
45 /**
46 * @brief Get the RSA public key from the certificate.
47 *
48 * @param this calling object
49 * @return public_key
50 */
51 rsa_public_key_t *(*get_public_key) (certificate_t *this);
52
53 identification_t *(*get_issuer) (certificate_t *this);
54 identification_t *(*get_subject) (certificate_t *this);
55 iterator_t *(*create_subjectaltname_iter) (certificate_t *this);
56 iterator_t *(*create_issueraltname_iter) (certificate_t *this);
57 bool (*belongs_to) (certificate_t *this, identification_t *subject);
58 bool (*issued_by) (certificate_t *this, identification_t *issuer);
59 bool (*validate) (certificate_t *this, rsa_public_key_t *signer);
60
61 /**
62 * @brief Destroys the private key.
63 *
64 * @param this private key to destroy
65 */
66 void (*destroy) (certificate_t *this);
67 };
68
69 /**
70 * @brief Read a certificate from a blob.
71 *
72 * @return created certificate_t.
73 *
74 * @ingroup transforms
75 */
76 certificate_t *certificate_create_from_chunk(chunk_t chunk);
77
78 certificate_t *certificate_create_from_file(char *filename);
79
80 #endif /* CERTIFICATE_H_ */