aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/crypto/certinfo.h
blob: 6561462a7a9be40ba4d7dc4ac69d956ec10e9fb9 (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
/**
 * @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_

#include <types.h>
#include <definitions.h>

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

extern enum_name_t *cert_status_names;

/**
 * RFC 2459 CRL reason codes
 */
typedef enum {
    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
} crl_reason_t;

extern enum_name_t *crl_reason_names;

typedef struct certinfo_t certinfo_t;

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

	/**
	 * @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 nextUpdate.
	 *
	 * @param this				calling object
	 * @return					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 Destroys the certinfo_t object.
	 * 
	 * @param this			crl 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_ */