Compare subject against all key identifiers in has_subject()

This commit is contained in:
Martin Willi
2010-09-09 17:46:20 +02:00
parent f85f0c2795
commit 663e735553
2 changed files with 26 additions and 10 deletions
@@ -295,10 +295,23 @@ METHOD(certificate_t, has_subject, id_match_t,
identification_t *current; identification_t *current;
enumerator_t *enumerator; enumerator_t *enumerator;
id_match_t match, best; id_match_t match, best;
chunk_t encoding;
if (subject->get_type(subject) == ID_KEY_ID) if (subject->get_type(subject) == ID_KEY_ID)
{ {
if (chunk_equals(this->hash, subject->get_encoding(subject))) encoding = subject->get_encoding(subject);
if (chunk_equals(this->hash, encoding))
{
return ID_MATCH_PERFECT;
}
if (this->subjectKeyIdentifier.len &&
chunk_equals(this->subjectKeyIdentifier, encoding))
{
return ID_MATCH_PERFECT;
}
if (this->pubkey &&
this->pubkey->has_fingerprint(this->pubkey, encoding))
{ {
return ID_MATCH_PERFECT; return ID_MATCH_PERFECT;
} }
+11 -8
View File
@@ -1098,11 +1098,6 @@ static identification_t* get_issuer(private_x509_cert_t *this)
return this->issuer; return this->issuer;
} }
/**
* Forward declaration
*/
static chunk_t get_subjectKeyIdentifier(private_x509_cert_t *this);
/** /**
* Implementation of certificate_t.has_subject. * Implementation of certificate_t.has_subject.
*/ */
@@ -1111,16 +1106,24 @@ static id_match_t has_subject(private_x509_cert_t *this, identification_t *subje
identification_t *current; identification_t *current;
enumerator_t *enumerator; enumerator_t *enumerator;
id_match_t match, best; id_match_t match, best;
chunk_t encoding;
if (subject->get_type(subject) == ID_KEY_ID) if (subject->get_type(subject) == ID_KEY_ID)
{ {
chunk_t keyid = subject->get_encoding(subject); encoding = subject->get_encoding(subject);
if (this->encoding_hash.ptr && chunk_equals(this->encoding_hash, keyid)) if (this->encoding_hash.len &&
chunk_equals(this->encoding_hash, encoding))
{ {
return ID_MATCH_PERFECT; return ID_MATCH_PERFECT;
} }
if (chunk_equals(get_subjectKeyIdentifier(this), keyid)) if (this->subjectKeyIdentifier.len &&
chunk_equals(this->subjectKeyIdentifier, encoding))
{
return ID_MATCH_PERFECT;
}
if (this->public_key &&
this->public_key->has_fingerprint(this->public_key, encoding))
{ {
return ID_MATCH_PERFECT; return ID_MATCH_PERFECT;
} }