Changes between 0.9.7 and 0.9.8 [xx XXX 2002]
- *) Add 'nid' and 'asn1_flag' members to EC_GROUP, and functions
- EC_GROUP_get_nid()
- EC_GROUP_get_set_asn1_flag()
- EC_GROUP_get_get_asn1_flag()
- 'nid' is an optional NID for named curves. 'asn1_flag'
- determines the encoding to be used for ASN1 purposes.
+ *) Add 'asn1_flag' and 'asn1_form' member to EC_GROUP with access
+ functions
+ EC_GROUP_set_asn1_flag()
+ EC_GROUP_get_asn1_flag()
+ EC_GROUP_set_point_conversion_form()
+ EC_GROUP_get_point_conversion_form()
+ These control ASN1 encoding details:
+ - Curve are encoded explicitly unless asn1_flag has been set to
+ OPENSSL_EC_NAMED_CURVE.
+ - Points are encoded in compressed form by default; options for
+ asn1_for are as for point2oct, namely
+ POINT_CONVERSION_COMPRESSED
+ POINT_CONVERSION_UNCOMPRESSED
+ POINT_CONVERSION_HYBRID
[Nils Larsch <nla@trustcenter.de>]
*) Add 'field_type' member to EC_METHOD, which holds the NID
functions
EC_GROUP_new_by_nid()
EC_GROUP_new_by_name()
- Also add a 'nid' field to EC_GROUP objects, which can be accessed
- via
+ Also add a 'curve_name' member to EC_GROUP objects, which can be
+ accessed via
EC_GROUP_set_nid()
EC_GROUP_get_nid()
[Nils Larsch <nla@trustcenter.de, Bodo Moeller]
ecdsa->group = EC_GROUP_new_by_name(curve_type);
if (named_curve)
EC_GROUP_set_asn1_flag(ecdsa->group,
- OPENSSL_EC_NAMED_CURVE |
- (EC_GROUP_get_asn1_flag(ecdsa->group) & ~0x3));
+ OPENSSL_EC_NAMED_CURVE);
}
else if (informat == FORMAT_ASN1)
ecdsa = d2i_ECDSAParameters_bio(in,NULL);
goto err;
}
- if ((EC_GROUP_get_asn1_flag(ecdsa->group) & OPENSSL_EC_NAMED_CURVE)
+ if (EC_GROUP_get_asn1_flag(ecdsa->group)
&& (nid = EC_GROUP_get_nid(ecdsa->group)))
{
/* just set the OID */
if ((ecdsa->group = EC_GROUP_new_by_name(
OBJ_obj2nid(a->parameter->value.object))) == NULL)
goto err;
- EC_GROUP_set_asn1_flag(ecdsa->group, OPENSSL_EC_NAMED_CURVE |
- (EC_GROUP_get_asn1_flag(ecdsa->group) & ~0x03));
+ EC_GROUP_set_asn1_flag(ecdsa->group,
+ OPENSSL_EC_NAMED_CURVE);
}
/* the case implicitlyCA is currently not implemented */
ret->save_parameters = 1;
/* ASN1 stuff */
-#define OPENSSL_EC_EXPLICIT 0x001
-#define OPENSSL_EC_NAMED_CURVE 0x002
-#define OPENSSL_EC_COMPRESSED 0x010
-#define OPENSSL_EC_UNCOMPRESSED 0x020
-#define OPENSSL_EC_HYBRID 0x040
+#define OPENSSL_EC_NAMED_CURVE 0x001
typedef struct ec_parameters_st ECPARAMETERS;
typedef struct ecpk_parameters_st ECPKPARAMETERS;
void EC_GROUP_set_asn1_flag(EC_GROUP *, int flag);
int EC_GROUP_get_asn1_flag(const EC_GROUP *);
+void EC_GROUP_set_point_conversion_form(EC_GROUP *, point_conversion_form_t);
+point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);
+
EC_GROUP *d2i_ECParameters(EC_GROUP **, const unsigned char **in, long len);
int i2d_ECParameters(const EC_GROUP *, unsigned char **out);
static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *group,
ECPARAMETERS *param)
{
- int ok=0, i;
+ int ok=0;
size_t len=0;
ECPARAMETERS *ret=NULL;
BIGNUM *tmp=NULL;
goto err;
}
- i = EC_GROUP_get_asn1_flag(group);
- if (i | OPENSSL_EC_COMPRESSED)
- form = POINT_CONVERSION_COMPRESSED;
- else if (i | OPENSSL_EC_UNCOMPRESSED)
- form = POINT_CONVERSION_UNCOMPRESSED;
- else if (i | OPENSSL_EC_HYBRID)
- form = POINT_CONVERSION_HYBRID;
- else
- goto err;
+ form = EC_GROUP_get_point_conversion_form(group);
len = EC_POINT_point2oct(group, point, form, NULL, len, NULL);
if (len == 0)
ECPARAMETERS_free(ret->value.parameters);
}
- tmp = EC_GROUP_get_asn1_flag(group);
-
- if (tmp & OPENSSL_EC_NAMED_CURVE)
+ if (EC_GROUP_get_asn1_flag(group))
{
/* use the asn1 OID to describe the
* the elliptic curve parameters
ok = 0;
}
}
- else if (tmp & OPENSSL_EC_EXPLICIT)
+ else
{
/* use the ECPARAMETERS structure */
ret->type = 1;
group, NULL)) == NULL)
ok = 0;
}
- else
- ok = 0;
if (!ok)
{
EC_R_EC_GROUP_NEW_BY_NAME_FAILURE);
return NULL;
}
- tmp = EC_GROUP_get_asn1_flag(ret);
- tmp = (tmp & ~0x03) | OPENSSL_EC_NAMED_CURVE;
- EC_GROUP_set_asn1_flag(ret, tmp);
+ EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_NAMED_CURVE);
}
else if (params->type == 1)
{ /* the parameters are given by a ECPARAMETERS
ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, ERR_R_EC_LIB);
return NULL;
}
- tmp = EC_GROUP_get_asn1_flag(ret);
- tmp = (tmp & ~0x03) | OPENSSL_EC_EXPLICIT;
- EC_GROUP_set_asn1_flag(ret, tmp);
+ EC_GROUP_set_asn1_flag(ret, 0x0);
}
else if (params->type == 2)
{ /* implicitlyCA */
EC_POINT *generator; /* optional */
BIGNUM order, cofactor;
- int nid; /* optional NID for named curve */
+ int curve_name;/* optional NID for named curve */
int asn1_flag; /* flag to control the asn1 encoding */
+ point_conversion_form_t asn1_form;
void *extra_data;
void *(*extra_data_dup_func)(void *);
BN_init(&ret->order);
BN_init(&ret->cofactor);
- ret->nid = 0;
- ret->asn1_flag = OPENSSL_EC_EXPLICIT | OPENSSL_EC_COMPRESSED;
+ ret->curve_name = 0;
+ ret->asn1_flag = 0;
+ ret->asn1_form = POINT_CONVERSION_COMPRESSED;
ret->seed = NULL;
ret->seed_len = 0;
if (!BN_copy(&dest->order, &src->order)) return 0;
if (!BN_copy(&dest->cofactor, &src->cofactor)) return 0;
- dest->nid = src->nid;
- dest->asn1_flag = src->asn1_flag;
+ dest->curve_name = src->curve_name;
+ dest->asn1_flag = src->asn1_flag;
+ dest->asn1_form = src->asn1_form;
if (src->seed)
{
void EC_GROUP_set_nid(EC_GROUP *group, int nid)
{
- group->nid = nid;
+ group->curve_name = nid;
}
int EC_GROUP_get_nid(const EC_GROUP *group)
{
- return group->nid;
+ return group->curve_name;
}
}
+void EC_GROUP_set_point_conversion_form(EC_GROUP *group,
+ point_conversion_form_t form)
+ {
+ group->asn1_form = form;
+ }
+
+
+point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *group)
+ {
+ return group->asn1_form;
+ }
+
+
int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
if (group->meth->group_set_curve_GFp == 0)