#define EINFO_ENOTTY_ALGORITHM \
__einfo_uniqify ( EINFO_ENOTTY, 0x01, "Inappropriate algorithm" )
-/**
- * Invalidate ASN.1 object cursor
- *
- * @v cursor ASN.1 object cursor
- */
-void asn1_invalidate_cursor ( struct asn1_cursor *cursor ) {
- static uint8_t asn1_invalid_object[] = { ASN1_END, 0 };
-
- cursor->data = asn1_invalid_object;
- cursor->len = 0;
-}
-
/**
* Start parsing ASN.1 object
*
unsigned int unused;
} __attribute__ (( packed ));
+/**
+ * Invalidate ASN.1 object cursor
+ *
+ * @v cursor ASN.1 object cursor
+ */
+static inline __attribute__ (( always_inline )) void
+asn1_invalidate_cursor ( struct asn1_cursor *cursor ) {
+ cursor->len = 0;
+}
+
/**
* Extract ASN.1 type
*
* @v cursor ASN.1 object cursor
- * @ret type Type
+ * @ret type Type, or ASN1_END if cursor is invalid
*/
static inline __attribute__ (( always_inline )) unsigned int
asn1_type ( const struct asn1_cursor *cursor ) {
- return ( *( ( const uint8_t * ) cursor->data ) );
+ const uint8_t *type = cursor->data;
+
+ return ( ( cursor->len >= sizeof ( *type ) ) ? *type : ASN1_END );
}
extern void asn1_invalidate_cursor ( struct asn1_cursor *cursor );