mirror of
https://github.com/romanz/amodem.git
synced 2026-05-09 13:07:39 +08:00
formats: remove unused code and reorg
This commit is contained in:
@@ -8,15 +8,17 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
def fingerprint(blob):
|
|
||||||
digest = hashlib.md5(blob).digest()
|
|
||||||
return ':'.join('{:02x}'.format(c) for c in bytearray(digest))
|
|
||||||
|
|
||||||
DER_OCTET_STRING = b'\x04'
|
DER_OCTET_STRING = b'\x04'
|
||||||
|
|
||||||
curve = ecdsa.NIST256p
|
curve = ecdsa.NIST256p
|
||||||
hashfunc = hashlib.sha256
|
hashfunc = hashlib.sha256
|
||||||
|
|
||||||
|
|
||||||
|
def fingerprint(blob):
|
||||||
|
digest = hashlib.md5(blob).digest()
|
||||||
|
return ':'.join('{:02x}'.format(c) for c in bytearray(digest))
|
||||||
|
|
||||||
|
|
||||||
def parse_pubkey(blob):
|
def parse_pubkey(blob):
|
||||||
s = io.BytesIO(blob)
|
s = io.BytesIO(blob)
|
||||||
key_type = util.read_frame(s)
|
key_type = util.read_frame(s)
|
||||||
@@ -45,9 +47,6 @@ def parse_pubkey(blob):
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def load_public_key(filename):
|
|
||||||
with open(filename) as f:
|
|
||||||
return parse_public_key(f.read())
|
|
||||||
|
|
||||||
def parse_public_key(data):
|
def parse_public_key(data):
|
||||||
file_type, base64blob, name = data.split()
|
file_type, base64blob, name = data.split()
|
||||||
@@ -58,6 +57,7 @@ def parse_public_key(data):
|
|||||||
log.debug('loaded %s %s', file_type, result['fingerprint'])
|
log.debug('loaded %s %s', file_type, result['fingerprint'])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def decompress_pubkey(pub):
|
def decompress_pubkey(pub):
|
||||||
P = curve.curve.p()
|
P = curve.curve.p()
|
||||||
A = curve.curve.a()
|
A = curve.curve.a()
|
||||||
|
|||||||
Reference in New Issue
Block a user