#define EINFO_ENOTTY_ALGORITHM \
__einfo_uniqify ( EINFO_ENOTTY, 0x01, "Inappropriate algorithm" )
-/** "ecPublicKey" object identifier */
-static uint8_t oid_ecpublickey[] = { ASN1_OID_ECPUBLICKEY };
-
-/** Generic elliptic curve container algorithm
- *
- * The actual curve to be used is identified via the algorithm
- * parameters, rather than the top-level OID.
- */
-struct asn1_algorithm ecpubkey_algorithm __asn1_algorithm = {
- .name = "ecPublicKey",
- .oid = ASN1_CURSOR ( oid_ecpublickey ),
-};
-
/**
* Start parsing ASN.1 object
*
* Parse ASN.1 OID-identified elliptic curve algorithm
*
* @v cursor ASN.1 object cursor
+ * @v wrapper Optional wrapper algorithm, or NULL
* @ret algorithm Algorithm
* @ret rc Return status code
*/
int asn1_curve_algorithm ( const struct asn1_cursor *cursor,
+ struct asn1_algorithm *wrapper,
struct asn1_algorithm **algorithm ) {
struct asn1_cursor curve;
/* Elliptic curves are identified as either:
*
- * - the algorithm "id-ecPublicKey" with the actual curve
- * specified in the algorithm parameters, or
+ * - a wrapper algorithm "id-ecPublicKey" with the actual
+ * curve specified in the algorithm parameters, or
*
* - a standalone object identifier for the curve
*/
- if ( asn1_check_algorithm ( cursor, &ecpubkey_algorithm,
- &curve ) != 0 ) {
+ if ( wrapper && asn1_check_algorithm ( cursor, wrapper,
+ &curve ) != 0 ) {
memcpy ( &curve, cursor, sizeof ( curve ) );
}
#define EINFO_EINVAL_SIGNATURE \
__einfo_uniqify ( EINFO_EINVAL, 0x05, "Invalid signature" )
+/** "ecPublicKey" object identifier */
+static uint8_t oid_ecpublickey[] = { ASN1_OID_ECPUBLICKEY };
+
+/** Generic elliptic curve container algorithm
+ *
+ * The actual curve to be used is identified via the algorithm
+ * parameters, rather than the top-level OID.
+ */
+struct asn1_algorithm ecpubkey_algorithm __asn1_algorithm = {
+ .name = "ecPublicKey",
+ .oid = ASN1_CURSOR ( oid_ecpublickey ),
+ .pubkey = &ecdsa_algorithm,
+};
+
/** An ECDSA key */
struct ecdsa_key {
/** Elliptic curve */
asn1_enter_bits ( &cursor, NULL );
/* Identify curve */
- if ( ( rc = asn1_curve_algorithm ( &curve, &algorithm ) ) != 0 ) {
+ if ( ( rc = asn1_curve_algorithm ( &curve, &ecpubkey_algorithm,
+ &algorithm ) ) != 0 ) {
DBGC ( key, "ECDSA %p unknown curve: %s\n",
key, strerror ( rc ) );
DBGC_HDA ( key, 0, raw->data, raw->len );
extern int asn1_signature_algorithm ( const struct asn1_cursor *cursor,
struct asn1_algorithm **algorithm );
extern int asn1_curve_algorithm ( const struct asn1_cursor *cursor,
+ struct asn1_algorithm *wrapper,
struct asn1_algorithm **algorithm );
extern int asn1_check_algorithm ( const struct asn1_cursor *cursor,
struct asn1_algorithm *expected,