0c2a779a2c97f7af667342956aee40b7e6f9b334
[strongswan.git] / src / libstrongswan / crypto / pkcs9.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2008 Andreas Steffen
4 * Hochschule fuer Technik Rapperswil, Switzerland
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 pkcs9 pkcs9
19 * @{ @ingroup crypto
20 */
21
22 #ifndef PKCS9_H_
23 #define PKCS9_H_
24
25 typedef struct pkcs9_t pkcs9_t;
26
27 #include <library.h>
28
29 /**
30 * PKCS#9 attribute lists.
31 */
32 struct pkcs9_t {
33
34 /**
35 * Gets ASN.1 encoding of PKCS#9 attribute list.
36 *
37 * @return ASN.1 encoded PKCSI#9 list
38 */
39 chunk_t (*get_encoding) (pkcs9_t *this);
40
41 /**
42 * Gets a PKCS#9 attribute from the list.
43 *
44 * @param oid OID of the attribute
45 * @return value of the attribute (internal data)
46 */
47 chunk_t (*get_attribute) (pkcs9_t *this, int oid);
48
49 /**
50 * Adds a PKCS#9 attribute.
51 *
52 * @param oid OID of the attribute
53 * @param value value of the attribute, with ASN1 type (gets owned)
54 */
55 void (*add_attribute) (pkcs9_t *this, int oid, chunk_t value);
56
57 /**
58 * Destroys the PKCS#9 attribute list.
59 */
60 void (*destroy) (pkcs9_t *this);
61 };
62
63 /**
64 * Read a PKCS#9 attribute list from a DER encoded chunk.
65 *
66 * @param chunk chunk containing DER encoded data
67 * @param level ASN.1 parsing start level
68 * @return created pkcs9 attribute list, or NULL if invalid.
69 */
70 pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level);
71
72 /**
73 * Create an empty PKCS#9 attribute list
74 *
75 * @return created pkcs9 attribute list.
76 */
77 pkcs9_t *pkcs9_create(void);
78
79 #endif /** PKCS9_H_ @}*/