From 38b7e43f7d88a35b23b2d44a72d07d2ee589d31e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 21 Mar 2012 13:57:32 +0000 Subject: [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 --- src/include/ipxe/asn1.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/include/ipxe/asn1.h') 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 +#include + /** 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 */ -- cgit v1.2.3-55-g7522