def store_revocation_cert(db, armored_key, RevocationKey):
# First be able to ensure we can add an extra newline on the fly.
ascii_data = get_pgp_key_data(armored_key)
packets = list(ascii_data.packets())
if len(packets) == 0:
raise BadRevocationKeyException("No packets found")
signature = get_revocation_signature_packet(ascii_data)
created = signature.creation_time
expires = signature.expiration_time
length = signature.length
key_id = signature.key_id.decode()[-8:] # We just need the last 8 chars
try:
# XXX Can two keys have the same id? I mean can there be collision with
# the last 8 digits?
RevocationKey.query.filter(RevocationKey.pgp_keyid_for == key_id).one()
except NoResultFound:
revocation_key = RevocationKey(created, expires, length, armored_key, key_id)
db.session.add(revocation_key)
db.session.commit()
评论列表
文章目录