Add SignatureVerification class to return verification results. Add support for specifing against which key to verify a signature. Add support to preload all keys before verifing a signature. All test for specific key verificatio and all key preloading.
This commit is contained in:
@@ -1,15 +1,38 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from datetime import date
|
||||
|
||||
|
||||
class KeyStub(object):
|
||||
def __init__(self, raw):
|
||||
self.fingerprint = raw['keyid']
|
||||
self.key_type = raw['type']
|
||||
self.date = raw['date']
|
||||
self.expires = raw['expires']
|
||||
self.date = date.fromtimestamp(int(raw['date']))
|
||||
if raw['expires']:
|
||||
self.expires = date.fromtimestamp(int(raw['expires']))
|
||||
else:
|
||||
self.expires = None
|
||||
self.length = raw['length']
|
||||
self.uids = raw['uids']
|
||||
self.user_id = raw['uids']
|
||||
|
||||
@property
|
||||
def key_id(self):
|
||||
return self.fingerprint[-8:]
|
||||
|
||||
|
||||
class SignatureVerification(object):
|
||||
def __init__(self, raw):
|
||||
self.user_id = raw['username']
|
||||
self.status = raw['status']
|
||||
self.pubkey_fingerprint = raw['pubkey_fingerprint']
|
||||
self.date = date.fromtimestamp(int(raw['sig_timestamp']))
|
||||
if raw['expire_timestamp']:
|
||||
self.expires = date.fromtimestamp(int(raw['expire_timestamp']))
|
||||
else:
|
||||
self.expires = None
|
||||
self.trust_text = raw['trust_text']
|
||||
self.valid = raw['valid']
|
||||
self.stderr = raw['stderr']
|
||||
self.fingerprint = raw['fingerprint']
|
||||
self.signature_id = raw['signature_id']
|
||||
self.trust_level = raw['trust_level']
|
||||
|
||||
Reference in New Issue
Block a user