aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/asn1.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-03-21 13:57:32 +0000
committerMichael Brown <mcb30@ipxe.org>2012-03-22 00:31:22 +0000
commit38b7e43f7d88a35b23b2d44a72d07d2ee589d31e (patch)
tree1e8a9472a0b433e1f0e25f694b49301f850c1c17 /src/include/ipxe/asn1.h
parent9a03a8e3d23b993d4f4a475a9334cf29d8ce182b (diff)
downloadipxe-38b7e43f7d88a35b23b2d44a72d07d2ee589d31e.tar.gz
[crypto] Generalise X.509 OID-identified algorithm to asn1.c
The concept of an OID-identified algorithm as defined in X.509 is used in some other standards (e.g. PKCS#7). Generalise this functionality and provide it as part of the ASN.1 core. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/asn1.h')
-rw-r--r--src/include/ipxe/asn1.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h
index f912f5f57..553a8f3c3 100644
--- a/src/include/ipxe/asn1.h
+++ b/src/include/ipxe/asn1.h
@@ -9,6 +9,9 @@
FILE_LICENCE ( GPL2_OR_LATER );
+#include <stdint.h>
+#include <ipxe/tables.h>
+
/** An ASN.1 object cursor */
struct asn1_cursor {
/** Start of data */
@@ -143,6 +146,24 @@ struct asn1_cursor {
.len = sizeof ( oid_value ), \
}
+/** An ASN.1 OID-identified algorithm */
+struct asn1_algorithm {
+ /** Name */
+ const char *name;
+ /** Object identifier */
+ struct asn1_cursor oid;
+ /** Public-key algorithm (if applicable) */
+ struct pubkey_algorithm *pubkey;
+ /** Digest algorithm (if applicable) */
+ struct digest_algorithm *digest;
+};
+
+/** ASN.1 OID-identified algorithms */
+#define ASN1_ALGORITHMS __table ( struct asn1_algorithm, "asn1_algorithms" )
+
+/** Declare an ASN.1 OID-identified algorithm */
+#define __asn1_algorithm __table_entry ( ASN1_ALGORITHMS, 01 )
+
/** An ASN.1 boolean */
struct asn1_boolean {
/** Value */
@@ -181,5 +202,7 @@ extern int asn1_boolean ( const struct asn1_cursor *cursor );
extern int asn1_integer ( const struct asn1_cursor *cursor, int *value );
extern int asn1_compare ( const struct asn1_cursor *cursor1,
const struct asn1_cursor *cursor2 );
+extern struct asn1_algorithm *
+asn1_algorithm ( const struct asn1_cursor *cursor );
#endif /* _IPXE_ASN1_H */