From: Zooko O'Whielacronx Date: Fri, 5 Jan 2007 00:58:14 +0000 (-0700) Subject: add padding to segments and convert type from string to list of integers before passi... X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~406 X-Git-Url: https://git.rkrishnan.org/%5B/frontends/%22file:/%22news.html/provisioning?a=commitdiff_plain;h=5ad6c43622572b6fbb197093f732b8b403a563c4;p=tahoe-lafs%2Ftahoe-lafs.git add padding to segments and convert type from string to list of integers before passing to py_ecc But then I get an error that I don't understand about ECC math... --- diff --git a/src/allmydata/encode_new.py b/src/allmydata/encode_new.py index b7cab187..6c6aa3cd 100644 --- a/src/allmydata/encode_new.py +++ b/src/allmydata/encode_new.py @@ -60,8 +60,16 @@ hash tree is put into the URI. """ +def pad(s, l, c='\x00'): + """ + Return string s with enough chars c appended to it to make its length be + an even multiple of l bytes. - + @param s the original string + @param l the length of the resulting padded string in bytes + @param c the pad char + """ + return s + c * mathutil.pad_size(len(s), l) class Encoder(object): @@ -118,7 +126,7 @@ class Encoder(object): # upgrade from the unusably slow py_ecc prototype to a fast ECC we # should also fix up this memory usage (by using the array module). for i in range(0, len(crypttext), self.required_shares): - words = self.fecer.Encode(crypttext[i:i+self.required_shares]) + words = self.fecer.Encode([ord(x) for x in crypttext[i:i+self.required_shares]]) for (subshare, word,) in zip(subshares, words): subshare.append(word) return [ ''.join(subshare) for subshare in subshares ] @@ -127,7 +135,7 @@ class Encoder(object): segment_plaintext = self.infile.read(self.segment_size) segment_crypttext = self.cryptor.encrypt(segment_plaintext) del segment_plaintext - subshares_for_this_segment = self.encode_segment(segment_crypttext) + subshares_for_this_segment = self.encode_segment(pad(segment_crypttext, self.segment_size)) del segment_crypttext dl = [] for share_num,subshare in enumerate(subshares_for_this_segment):