Support different encoding types in certificate.get_encoding()

This commit is contained in:
Martin Willi
2010-07-13 13:53:20 +02:00
parent da9724e6d0
commit 0406eeaacb
27 changed files with 239 additions and 102 deletions
@@ -296,10 +296,16 @@ METHOD(certificate_t, get_validity, bool,
return t <= this->nextUpdate;
}
METHOD(certificate_t, get_encoding, chunk_t,
private_openssl_crl_t *this)
METHOD(certificate_t, get_encoding, bool,
private_openssl_crl_t *this, cred_encoding_type_t type, chunk_t *encoding)
{
return chunk_clone(this->encoding);
if (type == CERT_ASN1_DER)
{
*encoding = chunk_clone(this->encoding);
return TRUE;
}
return lib->encoding->encode(lib->encoding, type, NULL, encoding,
CRED_PART_X509_CRL_ASN1_DER, this->encoding, CRED_PART_END);
}
METHOD(certificate_t, equals, bool,
@@ -317,7 +323,10 @@ METHOD(certificate_t, equals, bool,
return chunk_equals(this->encoding,
((private_openssl_crl_t*)other)->encoding);
}
encoding = other->get_encoding(other);
if (!other->get_encoding(other, CERT_ASN1_DER, &encoding))
{
return FALSE;
}
equal = chunk_equals(this->encoding, encoding);
free(encoding.ptr);
return equal;
@@ -393,12 +393,19 @@ METHOD(certificate_t, get_validity, bool,
return (t >= this->notBefore && t <= this->notAfter);
}
METHOD(certificate_t, get_encoding, chunk_t,
private_openssl_x509_t *this)
METHOD(certificate_t, get_encoding, bool,
private_openssl_x509_t *this, cred_encoding_type_t type, chunk_t *encoding)
{
return chunk_clone(this->encoding);
if (type == CERT_ASN1_DER)
{
*encoding = chunk_clone(this->encoding);
return TRUE;
}
return lib->encoding->encode(lib->encoding, type, NULL, encoding,
CRED_PART_X509_ASN1_DER, this->encoding, CRED_PART_END);
}
METHOD(certificate_t, equals, bool,
private_openssl_x509_t *this, certificate_t *other)
{
@@ -418,7 +425,10 @@ METHOD(certificate_t, equals, bool,
encoding = ((private_openssl_x509_t*)other)->encoding;
return chunk_equals(this->encoding, encoding);
}
encoding = other->get_encoding(other);
if (!other->get_encoding(other, CERT_ASN1_DER, &encoding))
{
return FALSE;
}
equal = chunk_equals(this->encoding, encoding);
free(encoding.ptr);
return equal;