Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
Always zero encryption key on Stop
Browse files Browse the repository at this point in the history
This change moves the zero key on Stop logic into cmdKEK.run.  This
guarantees via a defer that it is the last thing executed when run
exits (and thus the key is always zeroed).

Signed-off-by: Monis Khan <[email protected]>
  • Loading branch information
enj authored and Nathaniel McCallum committed Mar 20, 2018
1 parent 87ffa8a commit 926a972
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/kek/kek.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (c *cmdKEK) Get() ([]byte, error) {
}

func (c *cmdKEK) Stop() {
c.setErrorState(errEmptyKey)
close(c.stop)
}

Expand Down Expand Up @@ -81,6 +80,7 @@ func (c *cmdKEK) run() {
const factor = 5 // TODO move constant, maybe make configurable?
ticker := time.NewTicker(c.duration / factor)
defer ticker.Stop()
defer c.setErrorState(errEmptyKey)

current := 0

Expand Down

0 comments on commit 926a972

Please sign in to comment.