'version' is not optional in the encoding
[openssl.git] / crypto / ecdsa / ecs_asn1.c
index f68081d..0789915 100644 (file)
@@ -86,7 +86,7 @@ DECLARE_ASN1_ENCODE_FUNCTIONS_const(X9_62_CURVE, X9_62_CURVE)
 IMPLEMENT_ASN1_FUNCTIONS_const(X9_62_CURVE)
 
 ASN1_SEQUENCE(X9_62_EC_PARAMETERS) = {
-       ASN1_OPT(X9_62_EC_PARAMETERS, version, ASN1_INTEGER),
+       ASN1_SIMPLE(X9_62_EC_PARAMETERS, version, ASN1_INTEGER),
        ASN1_SIMPLE(X9_62_EC_PARAMETERS, fieldID, X9_62_FIELDID),
        ASN1_SIMPLE(X9_62_EC_PARAMETERS, curve, X9_62_CURVE),
        ASN1_SIMPLE(X9_62_EC_PARAMETERS, base, ASN1_OCTET_STRING),
@@ -261,14 +261,9 @@ X9_62_EC_PARAMETERS *ECDSA_get_X9_62_EC_PARAMETERS(const ECDSA *ecdsa, X9_62_EC_
        }
        else
                ret = param;
-       if (ecdsa->version == 1)
-               ret->version = NULL;
-       else
-       {
-               if (ret->version == NULL && (ret->version = ASN1_INTEGER_new()) == NULL)
-                       OPENSSL_ECDSA_ABORT(ERR_R_MALLOC_FAILURE)
-               if (!ASN1_INTEGER_set(ret->version, (long)ecdsa->version)) goto err;
-       }
+       if (ret->version == NULL && (ret->version = ASN1_INTEGER_new()) == NULL)
+               OPENSSL_ECDSA_ABORT(ERR_R_MALLOC_FAILURE)
+       if (!ASN1_INTEGER_set(ret->version, (long)ecdsa->version)) goto err;
        if ((ret->fieldID = ECDSA_get_X9_62_FIELDID(ecdsa, ret->fieldID)) == NULL)
                OPENSSL_ECDSA_ABORT(ECDSA_R_ECDSA_GET_X9_62_FIELDID_FAILURE)
        if ((ret->curve = ECDSA_get_X9_62_CURVE(ecdsa, ret->curve)) == NULL)