Skip to content

Commit a36421c

Browse files
jhinderssonChriMarMe
authored andcommitted
Add AdminSP auth retry with provided password if MSID auth fails. Also add the same password retry for EraseMaster
1 parent 0cf6827 commit a36421c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cmd/gosedctl/cmd.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,14 @@ func (i *initialSetupEnterpriseCmd) Run(ctx *context) error {
330330
return fmt.Errorf("Admin_C_PIN_MSID_GetPin() failed: %v", err)
331331
}
332332

333+
pwhash := pbkdf2.Key([]byte(i.SIDPassword), []byte(salt[:20]), 75000, 32, sha1.New)
334+
333335
if err := table.ThisSP_Authenticate(adminSession, uid.AuthoritySID, msid); err != nil {
334-
return fmt.Errorf("authenticating as AdminSP failed: %v", err)
336+
if err := table.ThisSP_Authenticate(adminSession, uid.AuthoritySID, pwhash); err != nil {
337+
return fmt.Errorf("authenticating as AdminSP failed: %v", err)
338+
}
335339
}
336340

337-
pwhash := pbkdf2.Key([]byte(i.SIDPassword), []byte(salt[:20]), 75000, 32, sha1.New)
338-
339341
if err := table.Admin_C_Pin_SID_SetPIN(adminSession, pwhash); err != nil {
340342
return fmt.Errorf("Admin_C_PIN_SID_SetPIN() failed: %v", err)
341343
}
@@ -365,14 +367,16 @@ func (i *initialSetupEnterpriseCmd) Run(ctx *context) error {
365367
return fmt.Errorf("failed to set BandMaster0 PIN: %v", err)
366368
}
367369

370+
erasePw := pbkdf2.Key([]byte(i.EraseMasterPW), []byte(salt[:20]), 75000, 32, sha1.New)
371+
368372
if err := table.ThisSP_Authenticate(lockingSession, uid.EraseMaster, msid); err != nil {
369373
if err := table.ThisSP_Authenticate(lockingSession, uid.EraseMaster, pwhash); err != nil {
370-
return fmt.Errorf("authenticating as EraseMaster failed: %v", err)
374+
if err := table.ThisSP_Authenticate(lockingSession, uid.EraseMaster, erasePw); err != nil {
375+
return fmt.Errorf("authenticating as EraseMaster failed: %v", err)
376+
}
371377
}
372378
}
373379

374-
erasePw := pbkdf2.Key([]byte(i.EraseMasterPW), []byte(salt[:20]), 75000, 32, sha1.New)
375-
376380
if err := table.SetEraseMasterPin(lockingSession, erasePw); err != nil {
377381
return fmt.Errorf("failed to set EraseMaster PIN: %v", err)
378382
}

0 commit comments

Comments
 (0)