Support different encoding types in certificate.get_encoding()
This commit is contained in:
@@ -190,9 +190,16 @@ static bool get_validity(private_pgp_cert_t *this, time_t *when,
|
||||
/**
|
||||
* Implementation of certificate_t.get_encoding.
|
||||
*/
|
||||
static chunk_t get_encoding(private_pgp_cert_t *this)
|
||||
static bool get_encoding(private_pgp_cert_t *this, cred_encoding_type_t type,
|
||||
chunk_t *encoding)
|
||||
{
|
||||
return chunk_clone(this->encoding);
|
||||
if (type == CERT_PGP_PKT)
|
||||
{
|
||||
*encoding = chunk_clone(this->encoding);
|
||||
return TRUE;
|
||||
}
|
||||
return lib->encoding->encode(lib->encoding, type, NULL, encoding,
|
||||
CRED_PART_PGP_CERT, this->encoding, CRED_PART_END);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +222,10 @@ static bool equals(private_pgp_cert_t *this, certificate_t *other)
|
||||
{ /* skip allocation if we have the same implementation */
|
||||
return chunk_equals(this->encoding, ((private_pgp_cert_t*)other)->encoding);
|
||||
}
|
||||
encoding = other->get_encoding(other);
|
||||
if (!other->get_encoding(other, CERT_PGP_PKT, &encoding))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
equal = chunk_equals(this->encoding, encoding);
|
||||
free(encoding.ptr);
|
||||
return equal;
|
||||
@@ -259,7 +269,7 @@ private_pgp_cert_t *create_empty()
|
||||
this->public.interface.interface.issued_by = (bool (*) (certificate_t*, certificate_t*))issued_by;
|
||||
this->public.interface.interface.get_public_key = (public_key_t* (*) (certificate_t*))get_public_key;
|
||||
this->public.interface.interface.get_validity = (bool (*) (certificate_t*, time_t*, time_t*, time_t*))get_validity;
|
||||
this->public.interface.interface.get_encoding = (chunk_t (*) (certificate_t*))get_encoding;
|
||||
this->public.interface.interface.get_encoding = (bool (*) (certificate_t*,cred_encoding_type_t,chunk_t*))get_encoding;
|
||||
this->public.interface.interface.equals = (bool (*)(certificate_t*, certificate_t*))equals;
|
||||
this->public.interface.interface.get_ref = (certificate_t* (*)(certificate_t*))get_ref;
|
||||
this->public.interface.interface.destroy = (void (*)(certificate_t*))destroy;
|
||||
|
||||
Reference in New Issue
Block a user