Skip to content

Commit

Permalink
Avoid bailing on no error (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored Feb 28, 2024
1 parent 22dd4fc commit 5e575ce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions trusted_os/rpmb.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ func (r *RPMB) init() error {
return fmt.Errorf("RPMB could not be initialized: %v", err)
}

var e *rpmb.OperationError
_, err = r.partition.Counter(false)

if !(errors.As(err, &e) && e.Result == rpmb.AuthenticationKeyNotYetProgrammed) {
return fmt.Errorf("RPMB could not be initialized: %v", err)
if err != nil {
var e *rpmb.OperationError
if !errors.As(err, &e) {
return fmt.Errorf("RPMB failed to read counter: %v", err)
}
if e.Result != rpmb.AuthenticationKeyNotYetProgrammed {
return fmt.Errorf("RPMB failed to read counter with operatation error: %v", err)
}
}

// Fuse a bit to indicate previous key programming to prevent malicious
Expand Down

0 comments on commit 5e575ce

Please sign in to comment.