Use a generic getter for all numerical X.509 constraints
This commit is contained in:
@@ -40,7 +40,7 @@ static bool check_pathlen(x509_t *issuer, int pathlen)
|
||||
{
|
||||
int pathlen_constraint;
|
||||
|
||||
pathlen_constraint = issuer->get_pathLenConstraint(issuer);
|
||||
pathlen_constraint = issuer->get_constraint(issuer, X509_PATH_LEN);
|
||||
if (pathlen_constraint != X509_NO_CONSTRAINT &&
|
||||
pathlen > pathlen_constraint)
|
||||
{
|
||||
@@ -439,7 +439,7 @@ static bool check_policy_constraints(x509_t *issuer, int pathlen,
|
||||
enumerator = chain->create_enumerator(chain);
|
||||
while (enumerator->enumerate(enumerator, &x509))
|
||||
{
|
||||
expl = x509->get_policyConstraint(x509, FALSE);
|
||||
expl = x509->get_constraint(x509, X509_REQUIRE_EXPLICIT_POLICY);
|
||||
if (expl != X509_NO_CONSTRAINT)
|
||||
{
|
||||
if (!has_policy_chain(chain, (x509_t*)subject, len - expl))
|
||||
@@ -458,7 +458,7 @@ static bool check_policy_constraints(x509_t *issuer, int pathlen,
|
||||
enumerator = chain->create_enumerator(chain);
|
||||
while (enumerator->enumerate(enumerator, &x509))
|
||||
{
|
||||
expl = x509->get_policyConstraint(x509, TRUE);
|
||||
expl = x509->get_constraint(x509, X509_INHIBIT_POLICY_MAPPING);
|
||||
if (expl != X509_NO_CONSTRAINT)
|
||||
{
|
||||
if (!has_policy_mapping(chain, len - expl))
|
||||
|
||||
@@ -250,16 +250,16 @@ METHOD(x509_t, get_authKeyIdentifier, chunk_t,
|
||||
return chunk_empty;
|
||||
}
|
||||
|
||||
METHOD(x509_t, get_pathLenConstraint, int,
|
||||
private_openssl_x509_t *this)
|
||||
METHOD(x509_t, get_constraint, int,
|
||||
private_openssl_x509_t *this, x509_constraint_t type)
|
||||
{
|
||||
return this->pathlen;
|
||||
}
|
||||
|
||||
METHOD(x509_t, get_policyConstraint, int,
|
||||
private_openssl_x509_t *this, bool inhibit)
|
||||
{
|
||||
return X509_NO_CONSTRAINT;
|
||||
switch (type)
|
||||
{
|
||||
case X509_PATH_LEN:
|
||||
return this->pathlen;
|
||||
default:
|
||||
return X509_NO_CONSTRAINT;
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(x509_t, create_subjectAltName_enumerator, enumerator_t*,
|
||||
@@ -526,8 +526,7 @@ static private_openssl_x509_t *create_empty()
|
||||
.get_serial = _get_serial,
|
||||
.get_subjectKeyIdentifier = _get_subjectKeyIdentifier,
|
||||
.get_authKeyIdentifier = _get_authKeyIdentifier,
|
||||
.get_pathLenConstraint = _get_pathLenConstraint,
|
||||
.get_policyConstraint = _get_policyConstraint,
|
||||
.get_constraint = _get_constraint,
|
||||
.create_subjectAltName_enumerator = _create_subjectAltName_enumerator,
|
||||
.create_crl_uri_enumerator = _create_crl_uri_enumerator,
|
||||
.create_ocsp_uri_enumerator = _create_ocsp_uri_enumerator,
|
||||
|
||||
@@ -1716,20 +1716,20 @@ METHOD(x509_t, get_authKeyIdentifier, chunk_t,
|
||||
return this->authKeyIdentifier;
|
||||
}
|
||||
|
||||
METHOD(x509_t, get_pathLenConstraint, int,
|
||||
private_x509_cert_t *this)
|
||||
METHOD(x509_t, get_constraint, int,
|
||||
private_x509_cert_t *this, x509_constraint_t type)
|
||||
{
|
||||
return this->pathLenConstraint;
|
||||
}
|
||||
|
||||
METHOD(x509_t, get_policyConstraint, int,
|
||||
private_x509_cert_t *this, bool inhibit)
|
||||
{
|
||||
if (inhibit)
|
||||
switch (type)
|
||||
{
|
||||
return this->inhibit_policy_constraint;
|
||||
case X509_PATH_LEN:
|
||||
return this->pathLenConstraint;
|
||||
case X509_REQUIRE_EXPLICIT_POLICY:
|
||||
return this->explicit_policy_constraint;
|
||||
case X509_INHIBIT_POLICY_MAPPING:
|
||||
return this->inhibit_policy_constraint;
|
||||
default:
|
||||
return X509_NO_CONSTRAINT;
|
||||
}
|
||||
return this->explicit_policy_constraint;
|
||||
}
|
||||
|
||||
METHOD(x509_t, create_subjectAltName_enumerator, enumerator_t*,
|
||||
@@ -1841,8 +1841,7 @@ static private_x509_cert_t* create_empty(void)
|
||||
.get_serial = _get_serial,
|
||||
.get_subjectKeyIdentifier = _get_subjectKeyIdentifier,
|
||||
.get_authKeyIdentifier = _get_authKeyIdentifier,
|
||||
.get_pathLenConstraint = _get_pathLenConstraint,
|
||||
.get_policyConstraint = _get_policyConstraint,
|
||||
.get_constraint = _get_constraint,
|
||||
.create_subjectAltName_enumerator = _create_subjectAltName_enumerator,
|
||||
.create_crl_uri_enumerator = _create_crl_uri_enumerator,
|
||||
.create_ocsp_uri_enumerator = _create_ocsp_uri_enumerator,
|
||||
|
||||
Reference in New Issue
Block a user