Removed len argument from proposal_get_token()
[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 attributes.
31 */
32 struct pkcs9_t {
33
34 /**
35 * Generate ASN.1 encoding of attribute list
36 */
37 void (*build_encoding) (pkcs9_t *this);
38
39 /**
40 * Gets ASN.1 encoding of PKCS#9 attribute list
41 *
42 * @return ASN.1 encoded PKCSI#9 list
43 */
44 chunk_t (*get_encoding) (pkcs9_t *this);
45
46 /**
47 * Gets a PKCS#9 attribute
48 *
49 * @param oid OID of the attribute
50 * @return value of the attribute (internal data)
51 */
52 chunk_t (*get_attribute) (pkcs9_t *this, int oid);
53
54 /**
55 * Adds a PKCS#9 attribute
56 *
57 * @param oid OID of the attribute
58 * @param value value of the attribute (gets cloned)
59 */
60 void (*set_attribute) (pkcs9_t *this, int oid, chunk_t value);
61
62 /**
63 * Adds a ASN.1 encoded PKCS#9 attribute
64 *
65 * @param oid OID of the attribute
66 * @param value ASN.1 encoded value of the attribute (gets adopted)
67 */
68 void (*set_attribute_raw) (pkcs9_t *this, int oid, chunk_t value);
69
70 /**
71 * Destroys the PKCS#9 attribute list.
72 */
73 void (*destroy) (pkcs9_t *this);
74 };
75
76 /**
77 * Read a PKCS#9 attribute list from a DER encoded chunk.
78 *
79 * @param chunk chunk containing DER encoded data
80 * @param level ASN.1 parsing start level
81 * @return created pkcs9 attribute list, or NULL if invalid.
82 */
83 pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level);
84
85 /**
86 * Create an empty PKCS#9 attribute list
87 *
88 * @return created pkcs9 attribute list.
89 */
90 pkcs9_t *pkcs9_create(void);
91
92 #endif /** PKCS9_H_ @}*/