hx509: Fix rfc2459.asn1 compilation w/o templates
This commit is contained in:
@@ -672,88 +672,43 @@ hx509_ca_tbs_add_crl_dp_uri(hx509_context context,
|
|||||||
const char *uri,
|
const char *uri,
|
||||||
hx509_name issuername)
|
hx509_name issuername)
|
||||||
{
|
{
|
||||||
|
DistributionPointName dpn;
|
||||||
DistributionPoint dp;
|
DistributionPoint dp;
|
||||||
|
GeneralNames crlissuer;
|
||||||
|
GeneralName gn, ign;
|
||||||
|
Name in;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(&dp, 0, sizeof(dp));
|
memset(&dp, 0, sizeof(dp));
|
||||||
|
memset(&gn, 0, sizeof(gn));
|
||||||
dp.distributionPoint = ecalloc(1, sizeof(*dp.distributionPoint));
|
memset(&ign, 0, sizeof(ign));
|
||||||
|
memset(&in, 0, sizeof(in));
|
||||||
{
|
|
||||||
DistributionPointName name;
|
|
||||||
GeneralName gn;
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
name.element = choice_DistributionPointName_fullName;
|
|
||||||
name.u.fullName.len = 1;
|
|
||||||
name.u.fullName.val = &gn;
|
|
||||||
|
|
||||||
gn.element = choice_GeneralName_uniformResourceIdentifier;
|
gn.element = choice_GeneralName_uniformResourceIdentifier;
|
||||||
gn.u.uniformResourceIdentifier.data = rk_UNCONST(uri);
|
gn.u.uniformResourceIdentifier.data = rk_UNCONST(uri);
|
||||||
gn.u.uniformResourceIdentifier.length = strlen(uri);
|
gn.u.uniformResourceIdentifier.length = strlen(uri);
|
||||||
|
dpn.element = choice_DistributionPointName_fullName;
|
||||||
ASN1_MALLOC_ENCODE(DistributionPointName,
|
dpn.u.fullName.len = 1;
|
||||||
dp.distributionPoint->data,
|
dpn.u.fullName.val = &gn;
|
||||||
dp.distributionPoint->length,
|
dp.distributionPoint = &dpn;
|
||||||
&name, &size, ret);
|
|
||||||
if (ret) {
|
|
||||||
hx509_set_error_string(context, 0, ret,
|
|
||||||
"Failed to encoded DistributionPointName");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (dp.distributionPoint->length != size)
|
|
||||||
_hx509_abort("internal ASN.1 encoder error");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (issuername) {
|
if (issuername) {
|
||||||
#if 1
|
ign.element = choice_GeneralName_directoryName;
|
||||||
/**
|
ret = hx509_name_to_Name(issuername, &ign.u.directoryName);
|
||||||
* issuername not supported
|
|
||||||
*/
|
|
||||||
hx509_set_error_string(context, 0, EINVAL,
|
|
||||||
"CRLDistributionPoints.name.issuername not yet supported");
|
|
||||||
return EINVAL;
|
|
||||||
#else
|
|
||||||
GeneralNames *crlissuer;
|
|
||||||
GeneralName gn;
|
|
||||||
Name n;
|
|
||||||
|
|
||||||
crlissuer = calloc(1, sizeof(*crlissuer));
|
|
||||||
if (crlissuer == NULL) {
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
memset(&gn, 0, sizeof(gn));
|
|
||||||
|
|
||||||
gn.element = choice_GeneralName_directoryName;
|
|
||||||
ret = hx509_name_to_Name(issuername, &n);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
hx509_set_error_string(context, 0, ret, "out of memory");
|
hx509_set_error_string(context, 0, ret, "out of memory");
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
crlissuer.len = 1;
|
||||||
gn.u.directoryName.element = n.element;
|
crlissuer.val = &ign;
|
||||||
gn.u.directoryName.u.rdnSequence = n.u.rdnSequence;
|
|
||||||
|
|
||||||
ret = add_GeneralNames(&crlissuer, &gn);
|
|
||||||
free_Name(&n);
|
|
||||||
if (ret) {
|
|
||||||
hx509_set_error_string(context, 0, ret, "out of memory");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
dp.cRLIssuer = &crlissuer;
|
dp.cRLIssuer = &crlissuer;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = add_CRLDistributionPoints(&tbs->crldp, &dp);
|
ret = add_CRLDistributionPoints(&tbs->crldp, &dp);
|
||||||
if (ret) {
|
if (issuername)
|
||||||
|
free_Name(&ign.u.directoryName);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
hx509_set_error_string(context, 0, ret, "out of memory");
|
hx509_set_error_string(context, 0, ret, "out of memory");
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
free_DistributionPoint(&dp);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -439,18 +439,9 @@ check_CRLDistributionPoints(hx509_validate_ctx ctx,
|
|||||||
validate_print(ctx, HX509_VALIDATE_F_VERBOSE, "CRL Distribution Points:\n");
|
validate_print(ctx, HX509_VALIDATE_F_VERBOSE, "CRL Distribution Points:\n");
|
||||||
for (i = 0 ; i < dp.len; i++) {
|
for (i = 0 ; i < dp.len; i++) {
|
||||||
if (dp.val[i].distributionPoint) {
|
if (dp.val[i].distributionPoint) {
|
||||||
DistributionPointName dpname;
|
DistributionPointName dpname = dp.val[i].distributionPoint[0];
|
||||||
heim_any *data = dp.val[i].distributionPoint;
|
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
ret = decode_DistributionPointName(data->data, data->length,
|
|
||||||
&dpname, NULL);
|
|
||||||
if (ret) {
|
|
||||||
validate_print(ctx, HX509_VALIDATE_F_VALIDATE,
|
|
||||||
"Failed to parse CRL Distribution Point Name: %d\n", ret);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (dpname.element) {
|
switch (dpname.element) {
|
||||||
case choice_DistributionPointName_fullName:
|
case choice_DistributionPointName_fullName:
|
||||||
validate_print(ctx, HX509_VALIDATE_F_VERBOSE, "Fullname:\n");
|
validate_print(ctx, HX509_VALIDATE_F_VERBOSE, "Fullname:\n");
|
||||||
@@ -480,7 +471,6 @@ check_CRLDistributionPoints(hx509_validate_ctx ctx,
|
|||||||
"Unknown DistributionPointName");
|
"Unknown DistributionPointName");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free_DistributionPointName(&dpname);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free_CRLDistributionPoints(&dp);
|
free_CRLDistributionPoints(&dp);
|
||||||
|
Reference in New Issue
Block a user