e234df5beef4b191e775ef9e761f75cef0751540
[strongswan.git] / src / libcharon / encoding / payloads / certreq_payload.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup certreq_payload certreq_payload
19 * @{ @ingroup payloads
20 */
21
22 #ifndef CERTREQ_PAYLOAD_H_
23 #define CERTREQ_PAYLOAD_H_
24
25 typedef struct certreq_payload_t certreq_payload_t;
26
27 #include <library.h>
28 #include <encoding/payloads/payload.h>
29 #include <encoding/payloads/cert_payload.h>
30 #include <utils/identification.h>
31
32 /**
33 * Class representing an IKEv1/IKEv2 CERTREQ payload.
34 */
35 struct certreq_payload_t {
36
37 /**
38 * The payload_t interface.
39 */
40 payload_t payload_interface;
41
42 /**
43 * Create an enumerator over contained keyids (IKEv2 only).
44 *
45 * @return enumerator over chunk_t's.
46 */
47 enumerator_t* (*create_keyid_enumerator)(certreq_payload_t *this);
48
49 /**
50 * Get the type of contained certificate keyids.
51 *
52 * @return certificate keyid type
53 */
54 certificate_type_t (*get_cert_type)(certreq_payload_t *this);
55
56 /**
57 * Add a certificates keyid to the payload (IKEv2 only).
58 *
59 * @param keyid keyid of the trusted certifcate
60 * @return
61 */
62 void (*add_keyid)(certreq_payload_t *this, chunk_t keyid);
63
64 /**
65 * Get the distinguished name of the payload (IKEv1 only).
66 *
67 * @return DN as identity, must be destroyed
68 */
69 identification_t* (*get_dn)(certreq_payload_t *this);
70
71 /**
72 * Destroys an certreq_payload_t object.
73 */
74 void (*destroy) (certreq_payload_t *this);
75 };
76
77 /**
78 * Creates an empty certreq_payload_t object.
79 *
80 * @return certreq payload
81 */
82 certreq_payload_t *certreq_payload_create(payload_type_t payload_type);
83
84 /**
85 * Creates an empty IKEv2 certreq_payload_t for a kind of certificates.
86 *
87 * @param type type of the added keyids
88 * @return certreq payload
89 */
90 certreq_payload_t *certreq_payload_create_type(certificate_type_t type);
91
92 /**
93 * Creates a IKEv1 certreq_payload_t for a given distinguished name.
94 *
95 * @param dn distinguished name, does not get owned
96 * @return certreq payload
97 */
98 certreq_payload_t *certreq_payload_create_dn(identification_t *id);
99
100 #endif /** CERTREQ_PAYLOAD_H_ @}*/