corrected brief
[strongswan.git] / src / libstrongswan / crypto / pkcs7.h
1 /**
2 * @file pkcs7.h
3 *
4 * @brief Interface of pkcs7_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Copyright (C) 2002-2007 Andreas Steffen
11 *
12 * Hochschule fuer Technik Rapperswil, Switzerland
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * RCSID $Id$
25 */
26
27 #ifndef _PKCS7_H
28 #define _PKCS7_H
29
30 typedef struct pkcs7_t pkcs7_t;
31
32 #include <library.h>
33 #include <crypto/x509.h>
34 #include <crypto/rsa/rsa_private_key.h>
35
36 /* Access structure for a PKCS#7 ContentInfo object */
37
38
39 /**
40 * @brief PKCS#7 ContentInfo object.
41 *
42 * @b Constructors:
43 * -pkcs7_create_from_chunk()
44 *
45 * @ingroup crypto
46 */
47 struct pkcs7_t {
48 /**
49 * @brief Check if the PKCS#7 contentType is data
50 *
51 * @param this calling object
52 * @return TRUE if the contentType is data
53 */
54 bool (*is_data) (pkcs7_t *this);
55
56 /**
57 * @brief Check if the PKCS#7 contentType is signedData
58 *
59 * @param this calling object
60 * @return TRUE if the contentType is signedData
61 */
62 bool (*is_signedData) (pkcs7_t *this);
63
64 /**
65 * @brief Check if the PKCS#7 contentType is envelopedData
66 *
67 * @param this calling object
68 * @return TRUE if the contentType is envelopedData
69 */
70 bool (*is_envelopedData) (pkcs7_t *this);
71
72 /**
73 * @brief Parse a PKCS#7 data content.
74 *
75 * @param this calling object
76 * @return TRUE if parsing was successful
77 */
78 bool (*parse_data) (pkcs7_t *this);
79
80 /**
81 * @brief Parse a PKCS#7 signedData content.
82 *
83 * @param this calling object
84 * @param cacert cacert used to verify the signature
85 * @return TRUE if parsing was successful
86 */
87 bool (*parse_signedData) (pkcs7_t *this, x509_t *cacert);
88
89 /**
90 * @brief Parse a PKCS#7 envelopedData content.
91 *
92 * @param this calling object
93 * @param serialNumber serialNumber of the request
94 * @param key RSA private key used to decrypt the symmetric key
95 * @return TRUE if parsing was successful
96 */
97 bool (*parse_envelopedData) (pkcs7_t *this, chunk_t serialNumber, rsa_private_key_t *key);
98
99 /**
100 * @brief Destroys the contentInfo object.
101 *
102 * @param this PKCS#7 contentInfo object to destroy
103 */
104 void (*destroy) (pkcs7_t *this);
105 };
106
107 /**
108 * @brief Read a PKCS#7 contentInfo object from a DER encoded chunk.
109 *
110 * @param chunk chunk containing DER encoded data
111 * @param level ASN.1 parsing start level
112 * @return created pkcs7_contentInfo object, or NULL if invalid.
113 *
114 * @ingroup crypto
115 */
116 pkcs7_t *pkcs7_create_from_chunk(chunk_t chunk, u_int level);
117
118 #endif /* _PKCS7_H */