summaryrefslogtreecommitdiff
path: root/src/libstrongswan/crypto/certinfo.h
blob: 476befda808cd7f5c1fd9fede9f48363c7213d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/**
 * @file certinfo.h
 * 
 * @brief Interface of certinfo_t.
 * 
 */

/*
 * Copyright (C) 2006 Andreas Steffen
 * Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#ifndef CERTINFO_H_
#define CERTINFO_H_

typedef enum cert_status_t cert_status_t;
typedef enum crl_reason_t crl_reason_t;
typedef struct certinfo_t certinfo_t;

#include <library.h>

/**
 * RFC 2560 OCSP - certificate status
 */
enum cert_status_t {
	CERT_GOOD = 		0,
	CERT_REVOKED = 		1,
	CERT_UNKNOWN = 		2,
	CERT_UNDEFINED =	3,
	CERT_UNTRUSTED =	4  /* private use */
};

extern enum_name_t *cert_status_names;

/**
 * RFC 2459 CRL reason codes
 */
enum crl_reason_t {
    REASON_UNSPECIFIED =			0,
    REASON_KEY_COMPROMISE = 		1,
    REASON_CA_COMPROMISE = 			2,
    REASON_AFFILIATION_CHANGED =	3,
    REASON_SUPERSEDED =				4,
    REASON_CESSATION_OF_OPERATON =	5,
    REASON_CERTIFICATE_HOLD =		6,
    REASON_REMOVE_FROM_CRL =		8
};

extern enum_name_t *crl_reason_names;

/**
 * @brief X.509 certificate status information
 *
 * @ingroup transforms
 */
struct certinfo_t {

	/**
	 * @brief Check if both certinfo objects have the same serialNumber.
	 * 
	 * @param this				calling object
	 * @param that				second certinfo_t object
	 * @return					TRUE if the same serialNumber
	 */
	bool (*equals_serialNumber) (const certinfo_t *this, const certinfo_t *that);

	/**
	 * @brief Compares two serial numbers.
	 * 
	 * @param this				calling object
	 * @param that				second certinfo_t object
	 * @return					negative if this is smaller than that
	 *							zero if this equals that
	 *							positive if this is greater than that
	 */
	int (*compare_serialNumber) (const certinfo_t *this, const certinfo_t *that);

	/**
	 * @brief Get serial number.
	 *
	 * @param this				calling object
	 * @return					serialNumber
	 */
	chunk_t (*get_serialNumber) (const certinfo_t *this);

	/**
	 * @brief Set certificate status.
	 *
	 * @param this				calling object
	 * @param status			status
	 */
	void (*set_status) (certinfo_t *this, cert_status_t status);

	/**
	 * @brief Get certificate status.
	 *
	 * @param this				calling object
	 * @return					status
	 */
	cert_status_t (*get_status) (const certinfo_t *this);

	/**
	 * @brief Set thisUpdate.
	 *
	 * @param this				calling object
	 * @param thisUpdate		thisUpdate
	 */
	void (*set_thisUpdate) (certinfo_t *this, time_t thisUpdate);

	/**
	 * @brief Get thisUpdate.
	 *
	 * @param this				calling object
	 * @return					thisUpdate
	 */
	time_t (*get_thisUpdate) (const certinfo_t *this);

	/**
	 * @brief Set nextUpdate.
	 *
	 * @param this				calling object
	 * @param					nextUpdate
	 */
	void (*set_nextUpdate) (certinfo_t *this, time_t nextUpdate);

	/**
	 * @brief Get nextUpdate.
	 *
	 * @param this				calling object
	 * @return					nextUpdate
	 */
	time_t (*get_nextUpdate) (const certinfo_t *this);

	/**
	 * @brief Set revocationTime.
	 *
	 * @param this				calling object
	 * @param revocationTime	revocationTime
	 */
	void (*set_revocationTime) (certinfo_t *this, time_t revocationTime);

	/**
	 * @brief Get revocationTime.
	 *
	 * @param this				calling object
	 * @return					revocationTime
	 */
	time_t (*get_revocationTime) (const certinfo_t *this);

	/**
	 * @brief Set revocationReason.
	 *
	 * @param this				calling object
	 * @param reason			revocationReason
	 */
	void (*set_revocationReason) (certinfo_t *this, crl_reason_t reason);

	/**
	 * @brief Get revocationReason.
	 *
	 * @param this				calling object
	 * @return					revocationReason
	 */
	crl_reason_t (*get_revocationReason) (const certinfo_t *this);

	/**
	 * @brief Set revocationReason.
	 *
	 * @param this				calling object to be updated
	 * @param that				object containing updated information
	 */
	void (*update) (certinfo_t *this, const certinfo_t *that);

	/**
	 * @brief Destroys the certinfo_t object.
	 * 
	 * @param this			certinfo_t to destroy
	 */
	void (*destroy) (certinfo_t *this);

};

/**
 * @brief Create a certinfo_t object.
 * 
 * @param serial 	chunk serial number of the certificate
 * @return 			created certinfo_t object
 * 
 * @ingroup transforms
 */
certinfo_t *certinfo_create(chunk_t serial);

#endif /* CERTINFO_H_ */