~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

some reordering of verification, improve names of tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
249
249
        if len(result) == 0:
250
250
            return SIGNATURE_NOT_VALID, None
251
251
        #user has specified a list of acceptable keys, check our result is in it
252
 
        #test_verify_valid_but_unacceptable_key
 
252
        #test_verify_unacceptable_key
253
253
        fingerprint = result[0].fpr
254
254
        if self.acceptable_keys is not None:
255
255
            if not fingerprint in self.acceptable_keys:                
275
275
            return SIGNATURE_KEY_MISSING, fingerprint[-8:]
276
276
        #summary isn't set if sig is valid but key is untrusted
277
277
        #but if user has explicity set the key as acceptable we can validate it
278
 
        # test_verify_valid
279
278
        if result[0].summary == 0 and self.acceptable_keys is not None:
280
279
            if fingerprint in self.acceptable_keys:
 
280
                # test_verify_untrusted_but_accepted
281
281
                return SIGNATURE_VALID, None 
 
282
        #test_verify_valid_but_untrusted
 
283
        if result[0].summary == 0 and self.acceptable_keys is None:
 
284
            return SIGNATURE_NOT_VALID, None
282
285
        #if the expired key was not expired at time of signing it's good
283
286
        if result[0].summary & gpgme.SIGSUM_KEY_EXPIRED:
284
287
            expires = context.get_key(result[0].fpr).subkeys[0].expires
290
293
        #test_verify_revoked_signature
291
294
        if result[0].summary & gpgme.SIGSUM_SYS_ERROR:
292
295
            return SIGNATURE_NOT_VALID, None
293
 
        #no summary means an untrusted key
294
 
        #test_verify_valid_but_untrusted
295
 
        if result[0].summary == 0 and self.acceptable_keys is None:
296
 
            return SIGNATURE_NOT_VALID, None
297
296
        #other error types such as revokes keys should (I think) be caught by
298
297
        #SIGSUM_RED so anything else means something is wrong
299
298
        raise errors.SignatureVerificationFailed("Unknown GnuPG key "\