UNDO: hashutil: replace pycrypto's SHA256 with pycryptopp's SHA256
This commit is contained in:
parent
11412da436
commit
f60dc4adfb
|
@ -1,17 +1,17 @@
|
||||||
from pycryptopp.hash.sha256 import SHA256
|
from allmydata.Crypto.Hash import SHA256
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def netstring(s):
|
def netstring(s):
|
||||||
return "%d:%s," % (len(s), s,)
|
return "%d:%s," % (len(s), s,)
|
||||||
|
|
||||||
def tagged_hash(tag, val):
|
def tagged_hash(tag, val):
|
||||||
s = SHA256()
|
s = SHA256.new()
|
||||||
s.update(netstring(tag))
|
s.update(netstring(tag))
|
||||||
s.update(val)
|
s.update(val)
|
||||||
return s.digest()
|
return s.digest()
|
||||||
|
|
||||||
def tagged_pair_hash(tag, val1, val2):
|
def tagged_pair_hash(tag, val1, val2):
|
||||||
s = SHA256()
|
s = SHA256.new()
|
||||||
s.update(netstring(tag))
|
s.update(netstring(tag))
|
||||||
s.update(netstring(val1))
|
s.update(netstring(val1))
|
||||||
s.update(netstring(val2))
|
s.update(netstring(val2))
|
||||||
|
@ -20,7 +20,7 @@ def tagged_pair_hash(tag, val1, val2):
|
||||||
# specific hash tags that we use
|
# specific hash tags that we use
|
||||||
|
|
||||||
def tagged_hasher(tag):
|
def tagged_hasher(tag):
|
||||||
return SHA256(netstring(tag))
|
return SHA256.new(netstring(tag))
|
||||||
|
|
||||||
def storage_index_chk_hash(data):
|
def storage_index_chk_hash(data):
|
||||||
# storage index is truncated to 128 bits (16 bytes). We're only hashing a
|
# 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):
|
def hmac(tag, data):
|
||||||
ikey = _xor(tag, "\x36")
|
ikey = _xor(tag, "\x36")
|
||||||
okey = _xor(tag, "\x5c")
|
okey = _xor(tag, "\x5c")
|
||||||
h1 = SHA256(ikey + data).digest()
|
h1 = SHA256.new(ikey + data).digest()
|
||||||
h2 = SHA256(okey + h1).digest()
|
h2 = SHA256.new(okey + h1).digest()
|
||||||
return h2
|
return h2
|
||||||
|
|
||||||
def mutable_rwcap_key_hash(iv, writekey):
|
def mutable_rwcap_key_hash(iv, writekey):
|
||||||
|
|
Loading…
Reference in New Issue