mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-17 10:20:13 +00:00
sign_to_foolscap: require key
This commit is contained in:
parent
ae91fa9ffe
commit
b2e5507e09
@ -27,16 +27,13 @@ def get_tubid_string(furl):
|
|||||||
|
|
||||||
|
|
||||||
def sign_to_foolscap(ann, sk):
|
def sign_to_foolscap(ann, sk):
|
||||||
# return (bytes, None, None) or (bytes, sig-str, pubkey-str). A future
|
# return (bytes, sig-str, pubkey-str). A future HTTP-based serialization
|
||||||
# HTTP-based serialization will use JSON({msg:b64(JSON(msg).utf8),
|
# will use JSON({msg:b64(JSON(msg).utf8), sig:v0-b64(sig),
|
||||||
# sig:v0-b64(sig), pubkey:v0-b64(pubkey)}) .
|
# pubkey:v0-b64(pubkey)}) .
|
||||||
msg = simplejson.dumps(ann).encode("utf-8")
|
msg = simplejson.dumps(ann).encode("utf-8")
|
||||||
if sk:
|
sig = "v0-"+base32.b2a(sk.sign(msg))
|
||||||
sig = "v0-"+base32.b2a(sk.sign(msg))
|
vk_bytes = sk.get_verifying_key_bytes()
|
||||||
vk_bytes = sk.get_verifying_key_bytes()
|
ann_t = (msg, sig, "v0-"+base32.b2a(vk_bytes))
|
||||||
ann_t = (msg, sig, "v0-"+base32.b2a(vk_bytes))
|
|
||||||
else:
|
|
||||||
ann_t = (msg, None, None)
|
|
||||||
return ann_t
|
return ann_t
|
||||||
|
|
||||||
class UnknownKeyError(Exception):
|
class UnknownKeyError(Exception):
|
||||||
|
Loading…
Reference in New Issue
Block a user