From 08fac28e738cef66933374c6be2246b77c009be6 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 3 May 2015 17:51:04 +0200 Subject: [PATCH] crypto: Remove polynomial from key --- crypto/crypto.go | 13 +++---------- server/key.go | 17 ----------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/crypto/crypto.go b/crypto/crypto.go index 418d80f8a..3e7aedf07 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" - "github.com/restic/restic/chunker" "golang.org/x/crypto/poly1305" "golang.org/x/crypto/scrypt" ) @@ -35,12 +34,10 @@ var ( // Key holds encryption and message authentication keys for a repository. It is stored // encrypted and authenticated as a JSON data structure in the Data field of the Key -// structure. For the master key, the secret random polynomial used for content -// defined chunking is included. +// structure. type Key struct { - MAC MACKey `json:"mac"` - Encrypt EncryptionKey `json:"encrypt"` - ChunkerPolynomial chunker.Pol `json:"chunker_polynomial,omitempty"` + MAC MACKey `json:"mac"` + Encrypt EncryptionKey `json:"encrypt"` } type EncryptionKey [32]byte @@ -340,9 +337,5 @@ func KDF(N, R, P int, salt []byte, password string) (*Key, error) { // Valid tests if the key is valid. func (k *Key) Valid() bool { - if k.ChunkerPolynomial != 0 && !k.ChunkerPolynomial.Irreducible() { - return false - } - return k.Encrypt.Valid() && k.MAC.Valid() } diff --git a/server/key.go b/server/key.go index 1e4294984..097ff6051 100644 --- a/server/key.go +++ b/server/key.go @@ -12,9 +12,7 @@ import ( "time" "github.com/restic/restic/backend" - "github.com/restic/restic/chunker" "github.com/restic/restic/crypto" - "github.com/restic/restic/debug" ) var ( @@ -92,13 +90,6 @@ func OpenKey(s *Server, name string, password string) (*Key, error) { return nil, errors.New("Invalid key for repository") } - // test if the chunker polynomial is present in the master key - if k.master.ChunkerPolynomial == 0 { - return nil, errors.New("Polynomial for content defined chunking is zero") - } - - debug.Log("OpenKey", "Master keys loaded, polynomial %v", k.master.ChunkerPolynomial) - return k, nil } @@ -177,14 +168,6 @@ func AddKey(s *Server, password string, template *Key) (*Key, error) { if template == nil { // generate new random master keys newkey.master = crypto.NewRandomKey() - // generate random polynomial for cdc - p, err := chunker.RandomPolynomial() - if err != nil { - debug.Log("AddKey", "error generating new polynomial for cdc: %v", err) - return nil, err - } - debug.Log("AddKey", "generated new polynomial for cdc: %v", p) - newkey.master.ChunkerPolynomial = p } else { // copy master keys from old key newkey.master = template.master