From e8afe848137d4c41bb7e9467b4d0b119dd2967e1 Mon Sep 17 00:00:00 2001 From: kevan Date: Sat, 24 Sep 2011 17:41:34 -0700 Subject: [PATCH] mutable/layout: break unpack_checkstring into unpack_mdmf_checkstring and unpack_sdmf_checkstring, add distinguisher function for checkstrings --- src/allmydata/mutable/layout.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/allmydata/mutable/layout.py b/src/allmydata/mutable/layout.py index 55f39685..91486957 100644 --- a/src/allmydata/mutable/layout.py +++ b/src/allmydata/mutable/layout.py @@ -136,13 +136,24 @@ def unpack_share(data): pubkey, signature, share_hash_chain, block_hash_tree, share_data, enc_privkey) -def unpack_checkstring(checkstring): +def get_version_from_checkstring(checkstring): + (t, ) = struct.unpack(">B", checkstring[:1]) + return t + +def unpack_sdmf_checkstring(checkstring): cs_len = struct.calcsize(PREFIX) version, seqnum, root_hash, IV = struct.unpack(PREFIX, checkstring[:cs_len]) if version != 0: # TODO: just ignore the share raise UnknownVersionError("got mutable share version %d, but I only understand version 0" % version) return (seqnum, root_hash, IV) +def unpack_mdmf_checkstring(checkstring): + cs_len = struct.calcsize(MDMFCHECKSTRING) + checkstring = checkstring[:cs_len] + version, seqnum, root_hash = struct.unpack(MDMFCHECKSTRING, checkstring) + + assert version == 1 + return (seqnum, root_hash) def pack_offsets(verification_key_length, signature_length, share_hash_chain_length, block_hash_tree_length, -- 2.45.2