Reorganize crypto code

Move all crypto functions to package "crypto", move random generators
for tests into helper package.
This commit is contained in:
Alexander Neumann committed 2015-04-12 09:36:14 +02:00
1 parent 8e8f31d3fe
commit 3a2525809c
10 files changed
+166 -187

No files matched your search

+3 -2
View File
@@ -11,6 +11,7 @@ import (
"github.com/restic/restic/backend"
"github.com/restic/restic/chunker"
"github.com/restic/restic/crypto"
"github.com/restic/restic/debug"
)
@@ -158,11 +159,11 @@ func (s Server) Save(t backend.Type, data []byte, id backend.ID) (Blob, error) {
var ciphertext []byte
// if the data is small enough, use a slice from the pool
if len(data) <= maxCiphertextSize-ivSize-macSize {
if len(data) <= maxCiphertextSize-crypto.CiphertextExtension {
ciphertext = GetChunkBuf("ch.Save()")
defer FreeChunkBuf("ch.Save()", ciphertext)
} else {
l := len(data) + ivSize + macSize
l := len(data) + crypto.CiphertextExtension
debug.Log("Server.Save", "create large slice of %d bytes for ciphertext", l)