diff options
Diffstat (limited to 'MokManager.c')
| -rw-r--r-- | MokManager.c | 70 |
1 files changed, 51 insertions, 19 deletions
diff --git a/MokManager.c b/MokManager.c index f7504d0d..eb5bb919 100644 --- a/MokManager.c +++ b/MokManager.c @@ -664,7 +664,9 @@ static UINTN mok_enrollment_prompt (void *MokNew, UINTN MokNewSize, int auth) { } static INTN mok_enrollment_prompt_callback (void *MokNew, void *data2, - void *data3) { + void *data3) +{ + uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); return mok_enrollment_prompt(MokNew, (UINTN)data2, TRUE); } @@ -694,15 +696,12 @@ static INTN mok_sb_prompt (void *MokSB, void *data2, void *data3) { EFI_STATUS efi_status; UINTN MokSBSize = (UINTN)data2; MokSBvar *var = MokSB; - CHAR16 password[1]; - UINT8 correct = 0, fail_count = 0; - UINT8 hash[SHA256_DIGEST_SIZE]; + CHAR16 pass1, pass2, pass3; + UINT8 fail_count = 0; UINT32 length; CHAR16 line[1]; UINT8 sbval = 1; - UINT8 pos; - - LibDeleteVariable(L"MokSB", &shim_lock_guid); + UINT8 pos1, pos2, pos3; if (MokSBSize != sizeof(MokSBvar)) { Print(L"Invalid MokSB variable contents\n"); @@ -711,23 +710,37 @@ static INTN mok_sb_prompt (void *MokSB, void *data2, void *data3) { uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); - while (correct < 3) { - RandomBytes (&pos, sizeof(pos)); + while (fail_count < 3) { + RandomBytes (&pos1, sizeof(pos1)); + pos1 = (pos1 % var->PWLen); + + do { + RandomBytes (&pos2, sizeof(pos2)); + pos2 = (pos2 % var->PWLen); + } while (pos2 == pos1); + + do { + RandomBytes (&pos3, sizeof(pos3)); + pos3 = (pos3 % var->PWLen) ; + } while (pos3 == pos2 || pos3 == pos1); + + Print(L"Enter password character %d: ", pos1 + 1); + get_line(&length, &pass1, 1, 0); - pos = pos % var->PWLen; + Print(L"Enter password character %d: ", pos2 + 1); + get_line(&length, &pass2, 1, 0); - Print(L"Enter password character %d: ", pos + 1); - get_line(&length, password, 1, 0); + Print(L"Enter password character %d: ", pos3 + 1); + get_line(&length, &pass3, 1, 0); - if (password[0] != var->Password[pos]) { + if (pass1 != var->Password[pos1] || + pass2 != var->Password[pos2] || + pass3 != var->Password[pos3]) { Print(L"Invalid character\n"); fail_count++; } else { - correct++; - } - - if (fail_count >= 3) break; + } } if (fail_count >= 3) { @@ -761,6 +774,8 @@ static INTN mok_sb_prompt (void *MokSB, void *data2, void *data3) { &shim_lock_guid); } + LibDeleteVariable(L"MokSB", &shim_lock_guid); + Print(L"Press a key to reboot system\n"); Pause(); uefi_call_wrapper(RT->ResetSystem, 4, EfiResetWarm, @@ -789,10 +804,25 @@ static INTN mok_pw_prompt (void *MokPW, void *data2, void *data3) { return -1; } - LibDeleteVariable(L"MokPW", &shim_lock_guid); - uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); + SetMem(hash, SHA256_DIGEST_SIZE, 0); + + if (CompareMem(MokPW, hash, SHA256_DIGEST_SIZE) == 0) { + Print(L"Clear MOK password? (y/n): "); + + do { + get_line (&length, line, 1, 1); + + if (line[0] == 'Y' || line[0] == 'y') { + LibDeleteVariable(L"MokPWStore", &shim_lock_guid); + LibDeleteVariable(L"MokPW", &shim_lock_guid); + } + } while (line[0] != 'N' && line[0] != 'n'); + + return 0; + } + while (fail_count < 3) { Print(L"Confirm MOK passphrase: "); get_line(&length, password, PASSWORD_MAX, 0); @@ -842,6 +872,8 @@ static INTN mok_pw_prompt (void *MokPW, void *data2, void *data3) { return -1; } + LibDeleteVariable(L"MokPW", &shim_lock_guid); + Print(L"Press a key to reboot system\n"); Pause(); uefi_call_wrapper(RT->ResetSystem, 4, EfiResetWarm, |
