From: Zooko O'Whielacronx Date: Fri, 9 Nov 2007 21:40:13 +0000 (-0700) Subject: hashutil.py: switch from pycrypto to pycryptopp SHA256 X-Git-Tag: allmydata-tahoe-0.7.0~232 X-Git-Url: https://git.rkrishnan.org/components/%22news.html/about.html?a=commitdiff_plain;h=3c7f96400df634db74f89849ef322ec3e1be45a5;p=tahoe-lafs%2Ftahoe-lafs.git hashutil.py: switch from pycrypto to pycryptopp SHA256 --- diff --git a/src/allmydata/util/hashutil.py b/src/allmydata/util/hashutil.py index 5ac98541..a06b43d4 100644 --- a/src/allmydata/util/hashutil.py +++ b/src/allmydata/util/hashutil.py @@ -1,17 +1,17 @@ -from allmydata.Crypto.Hash import SHA256 +from pycryptopp.hash.sha256 import SHA256 import os def netstring(s): return "%d:%s," % (len(s), s,) def tagged_hash(tag, val): - s = SHA256.new() + s = SHA256() s.update(netstring(tag)) s.update(val) return s.digest() def tagged_pair_hash(tag, val1, val2): - s = SHA256.new() + s = SHA256() s.update(netstring(tag)) s.update(netstring(val1)) s.update(netstring(val2)) @@ -20,7 +20,7 @@ def tagged_pair_hash(tag, val1, val2): # specific hash tags that we use def tagged_hasher(tag): - return SHA256.new(netstring(tag)) + return SHA256(netstring(tag)) def storage_index_chk_hash(data): # storage index is truncated to 128 bits (16 bytes). We're only hashing a @@ -114,8 +114,8 @@ def _xor(a, b): def hmac(tag, data): ikey = _xor(tag, "\x36") okey = _xor(tag, "\x5c") - h1 = SHA256.new(ikey + data).digest() - h2 = SHA256.new(okey + h1).digest() + h1 = SHA256(ikey + data).digest() + h2 = SHA256(okey + h1).digest() return h2 def mutable_rwcap_key_hash(iv, writekey):