~ubuntu-branches/ubuntu/precise/strongswan/precise

« back to all changes in this revision

Viewing changes to src/libstrongswan/plugins/pgp/pgp_cert.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2010-10-18 10:19:52 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20101018101952-zqd04yd4jvls81mj
Tags: 4.4.1-5ubuntu1
* Merge from debian unstable. Remaining change
  - Build depend on libnm-glib-dev instead of libnm-glib-vpn-dev to
    match the network manager package naming in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
}
189
189
 
190
190
/**
191
 
 * Implementation of certificate_t.is_newer.
192
 
 */
193
 
static bool is_newer(certificate_t *this, certificate_t *that)
194
 
{
195
 
        time_t this_update, that_update, now = time(NULL);
196
 
        bool new;
197
 
 
198
 
        this->get_validity(this, &now, &this_update, NULL);
199
 
        that->get_validity(that, &now, &that_update, NULL);
200
 
        new = this_update > that_update;
201
 
        DBG1(DBG_LIB, "  certificate from %T is %s - existing certificate"
202
 
                 " from %T %s", &this_update, FALSE, new ? "newer" : "not newer",
203
 
                 &that_update, FALSE, new ? "replaced" : "retained");
204
 
        return new;
205
 
}
206
 
 
207
 
/**
208
191
 * Implementation of certificate_t.get_encoding.
209
192
 */
210
 
static chunk_t get_encoding(private_pgp_cert_t *this)
 
193
static bool get_encoding(private_pgp_cert_t *this, cred_encoding_type_t type,
 
194
                                                 chunk_t *encoding)
211
195
{
212
 
        return chunk_clone(this->encoding);
 
196
        if (type == CERT_PGP_PKT)
 
197
        {
 
198
                *encoding = chunk_clone(this->encoding);
 
199
                return TRUE;
 
200
        }
 
201
        return lib->encoding->encode(lib->encoding, type, NULL, encoding,
 
202
                                                CRED_PART_PGP_CERT, this->encoding, CRED_PART_END);
213
203
}
214
204
 
215
205
/**
232
222
        {       /* skip allocation if we have the same implementation */
233
223
                return chunk_equals(this->encoding, ((private_pgp_cert_t*)other)->encoding);
234
224
        }
235
 
        encoding = other->get_encoding(other);
 
225
        if (!other->get_encoding(other, CERT_PGP_PKT, &encoding))
 
226
        {
 
227
                return FALSE;
 
228
        }
236
229
        equal = chunk_equals(this->encoding, encoding);
237
230
        free(encoding.ptr);
238
231
        return equal;
276
269
        this->public.interface.interface.issued_by = (bool (*) (certificate_t*, certificate_t*))issued_by;
277
270
        this->public.interface.interface.get_public_key = (public_key_t* (*) (certificate_t*))get_public_key;
278
271
        this->public.interface.interface.get_validity = (bool (*) (certificate_t*, time_t*, time_t*, time_t*))get_validity;
279
 
        this->public.interface.interface.is_newer = (bool (*) (certificate_t*,certificate_t*))is_newer;
280
 
        this->public.interface.interface.get_encoding = (chunk_t (*) (certificate_t*))get_encoding;
 
272
        this->public.interface.interface.get_encoding = (bool (*) (certificate_t*,cred_encoding_type_t,chunk_t*))get_encoding;
281
273
        this->public.interface.interface.equals = (bool (*)(certificate_t*, certificate_t*))equals;
282
274
        this->public.interface.interface.get_ref = (certificate_t* (*)(certificate_t*))get_ref;
283
275
        this->public.interface.interface.destroy = (void (*)(certificate_t*))destroy;
365
357
        else
366
358
        {
367
359
                /* V3 fingerprint is computed by public_key_t class */
368
 
                if (!this->key->get_fingerprint(this->key, KEY_ID_PGPV3,
 
360
                if (!this->key->get_fingerprint(this->key, KEYID_PGPV3,
369
361
                                                                                &this->fingerprint))
370
362
                {
371
363
                        return FALSE;