diff --git a/src/git.xdrm.io/schastsp/server/server.go b/src/git.xdrm.io/schastsp/server/server.go index 7e79c17..d0aa236 100644 --- a/src/git.xdrm.io/schastsp/server/server.go +++ b/src/git.xdrm.io/schastsp/server/server.go @@ -1,6 +1,7 @@ package server import ( + "fmt" "git.xdrm.io/schastsp/pkg/scha" "io" "os" @@ -135,4 +136,30 @@ func (s *T) HandleRequest(req io.Reader, res io.Writer) error { if written != len(y1) { return errors.New("Cannot write y2") } return nil +} + + + +/* (4) Apply a synchronisation key +* +* @syncKey<[]byte> Synchronisation key from client +* +* @return err +* +---------------------------------------------------------*/ +func (s *T) SynchronisationKey(syncKey []byte) error { + + /* (1) Check size */ + if uint16(len(syncKey)) != scha.HSIZE { + return fmt.Errorf("Invalid synchronisation key size (%d), expected %d bytes", len(syncKey), scha.HSIZE) + } + + /* (2) Copy synchronisation key */ + copy(s.hash, syncKey) + + /* (3) Store new config */ + s.store() + + return nil + } \ No newline at end of file