mirror of
https://github.com/romanz/amodem.git
synced 2026-04-03 11:06:24 +08:00
gpg: rename agent -> keyring
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
from . import agent, decode, proto
|
||||
from . import decode, keyring, proto
|
||||
from .. import client, factory, formats, util
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -52,13 +52,13 @@ class AgentSigner(object):
|
||||
|
||||
def __init__(self, user_id):
|
||||
"""Connect to the agent and retrieve required public key."""
|
||||
self.sock = agent.connect()
|
||||
self.keygrip = agent.get_keygrip(user_id)
|
||||
self.sock = keyring.connect_to_agent()
|
||||
self.keygrip = keyring.get_keygrip(user_id)
|
||||
|
||||
def sign(self, digest):
|
||||
"""Sign the digest and return an ECDSA signature."""
|
||||
params = agent.sign(sock=self.sock,
|
||||
keygrip=self.keygrip, digest=digest)
|
||||
params = keyring.sign_digest(sock=self.sock,
|
||||
keygrip=self.keygrip, digest=digest)
|
||||
return b''.join(proto.mpi(p) for p in params)
|
||||
|
||||
def close(self):
|
||||
|
||||
@@ -15,7 +15,7 @@ from .. import util
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def connect(sock_path='~/.gnupg/S.gpg-agent'):
|
||||
def connect_to_agent(sock_path='~/.gnupg/S.gpg-agent'):
|
||||
"""Connect to GPG agent's UNIX socket."""
|
||||
sock_path = os.path.expanduser(sock_path)
|
||||
sp.check_call(['gpg-connect-agent', '/bye'])
|
||||
@@ -102,7 +102,7 @@ def _parse_sig(sig):
|
||||
return parser(args=sig[1:])
|
||||
|
||||
|
||||
def sign(sock, keygrip, digest):
|
||||
def sign_digest(sock, keygrip, digest):
|
||||
"""Sign a digest using specified key using GPG agent."""
|
||||
hash_algo = 8 # SHA256
|
||||
assert len(digest) == 32
|
||||
Reference in New Issue
Block a user