diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-08-14 22:03:56 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-14 22:03:56 +0800 |
commit | 97887d98da703a31040bceee13bce9ee77fca673 (patch) | |
tree | ffc9a8a6fba087b26d33c0ef6c939a19aaaad8c9 /swarm/storage/hasherstore.go | |
parent | 8a040de60bd6b740ebe87cd8e1fe6bfdb6635d2f (diff) | |
download | dexon-97887d98da703a31040bceee13bce9ee77fca673.tar dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.gz dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.bz2 dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.lz dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.xz dexon-97887d98da703a31040bceee13bce9ee77fca673.tar.zst dexon-97887d98da703a31040bceee13bce9ee77fca673.zip |
swarm/network, swarm/storage: validate chunk size (#17397)
* swarm/network, swarm/storage: validate default chunk size
* swarm/bmt, swarm/network, swarm/storage: update BMT hash initialisation
* swarm/bmt: move segmentCount to tests
* swarm/chunk: change chunk.DefaultSize to be untyped const
* swarm/storage: add size validator
* swarm/storage: add chunk size validation to localstore
* swarm/storage: move validation from localstore to validator
* swarm/storage: global chunk rules in MRU
Diffstat (limited to 'swarm/storage/hasherstore.go')
-rw-r--r-- | swarm/storage/hasherstore.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/swarm/storage/hasherstore.go b/swarm/storage/hasherstore.go index 139c0ee03..bc23077c1 100644 --- a/swarm/storage/hasherstore.go +++ b/swarm/storage/hasherstore.go @@ -22,6 +22,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/crypto/sha3" + "github.com/ethereum/go-ethereum/swarm/chunk" "github.com/ethereum/go-ethereum/swarm/storage/encryption" ) @@ -57,7 +58,7 @@ func NewHasherStore(chunkStore ChunkStore, hashFunc SwarmHasher, toEncrypt bool) refSize := int64(hashSize) if toEncrypt { refSize += encryption.KeyLength - chunkEncryption = newChunkEncryption(DefaultChunkSize, refSize) + chunkEncryption = newChunkEncryption(chunk.DefaultSize, refSize) } return &hasherStore{ @@ -190,9 +191,9 @@ func (h *hasherStore) decryptChunkData(chunkData ChunkData, encryptionKey encryp // removing extra bytes which were just added for padding length := ChunkData(decryptedSpan).Size() - for length > DefaultChunkSize { - length = length + (DefaultChunkSize - 1) - length = length / DefaultChunkSize + for length > chunk.DefaultSize { + length = length + (chunk.DefaultSize - 1) + length = length / chunk.DefaultSize length *= h.refSize } |