updated integrity algorithm identifiers
[strongswan.git] / src / libstrongswan / crypto / pkcs9.h
1 /*
2 * Copyright (C) 2008 Andreas Steffen
3 * Hochschule fuer Technik Rapperswil, Switzerland
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup pkcs9 pkcs9
18 * @{ @ingroup crypto
19 */
20
21 #ifndef PKCS9_H_
22 #define PKCS9_H_
23
24 typedef struct pkcs9_t pkcs9_t;
25
26 #include <library.h>
27
28 /**
29 * PKCS#9 attributes.
30 */
31 struct pkcs9_t {
32
33 /**
34 * Generate ASN.1 encoding of attribute list
35 */
36 void (*build_encoding) (pkcs9_t *this);
37
38 /**
39 * Gets ASN.1 encoding of PKCS#9 attribute list
40 *
41 * @return ASN.1 encoded PKCSI#9 list
42 */
43 chunk_t (*get_encoding) (pkcs9_t *this);
44
45 /**
46 * Gets a PKCS#9 attribute
47 *
48 * @param oid OID of the attribute
49 * @return ASN.1 encoded value of the attribute
50 */
51 chunk_t (*get_attribute) (pkcs9_t *this, int oid);
52
53 /**
54 * Adds a PKCS#9 attribute
55 *
56 * @param oid OID of the attribute
57 * @param value ASN.1 encoded value of the attribute
58 */
59 void (*set_attribute) (pkcs9_t *this, int oid, chunk_t value);
60
61 /**
62 * Gets a PKCS#9 messageDigest attribute
63 *
64 * @return messageDigest
65 */
66 chunk_t (*get_messageDigest) (pkcs9_t *this);
67
68 /**
69 * Add a PKCS#9 messageDigest attribute
70 *
71 * @param value messageDigest
72 */
73 void (*set_messageDigest) (pkcs9_t *this, chunk_t value);
74
75 /**
76 * Destroys the PKCS#9 attribute list.
77 */
78 void (*destroy) (pkcs9_t *this);
79 };
80
81 /**
82 * Read a PKCS#9 attribute list from a DER encoded chunk.
83 *
84 * @param chunk chunk containing DER encoded data
85 * @param level ASN.1 parsing start level
86 * @return created pkcs9 attribute list, or NULL if invalid.
87 */
88 pkcs9_t *pkcs9_create_from_chunk(chunk_t chunk, u_int level);
89
90 /**
91 * Create an empty PKCS#9 attribute list
92 *
93 * @return created pkcs9 attribute list.
94 */
95 pkcs9_t *pkcs9_create(void);
96
97 #endif /** PKCS9_H_ @}*/