|
@@ -2588,12 +2588,18 @@ var
|
|
Delete(S, 1, P);
|
|
Delete(S, 1, P);
|
|
end;
|
|
end;
|
|
|
|
|
|
- procedure AbortInit(const Msg: TSetupMessageID);
|
|
|
|
|
|
+ procedure AbortInit(const Msg: TSetupMessageID); overload;
|
|
begin
|
|
begin
|
|
LoggedMsgBox(SetupMessages[Msg], '', mbCriticalError, MB_OK, True, IDOK);
|
|
LoggedMsgBox(SetupMessages[Msg], '', mbCriticalError, MB_OK, True, IDOK);
|
|
Abort;
|
|
Abort;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ procedure AbortInit(const Msg: String); overload;
|
|
|
|
+ begin
|
|
|
|
+ LoggedMsgBox(Msg, '', mbCriticalError, MB_OK, True, IDOK);
|
|
|
|
+ Abort;
|
|
|
|
+ end;
|
|
|
|
+
|
|
procedure AbortInitFmt1(const Msg: TSetupMessageID; const Arg1: String);
|
|
procedure AbortInitFmt1(const Msg: TSetupMessageID; const Arg1: String);
|
|
begin
|
|
begin
|
|
LoggedMsgBox(FmtSetupMessage(Msg, [Arg1]), '', mbCriticalError, MB_OK, True, IDOK);
|
|
LoggedMsgBox(FmtSetupMessage(Msg, [Arg1]), '', mbCriticalError, MB_OK, True, IDOK);
|
|
@@ -2725,8 +2731,7 @@ var
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
- function HandleInitPassword(const NeedPassword, AllowSetFileExtractorCryptKey: Boolean;
|
|
|
|
- out CryptKey: TSetupEncryptionKey): Boolean; overload;
|
|
|
|
|
|
+ function HandleInitPassword(const NeedPassword: Boolean): Boolean;
|
|
{ Handles InitPassword and returns the updated value of NeedPassword }
|
|
{ Handles InitPassword and returns the updated value of NeedPassword }
|
|
{ Also see WizardForm.CheckPassword }
|
|
{ Also see WizardForm.CheckPassword }
|
|
begin
|
|
begin
|
|
@@ -2735,6 +2740,7 @@ var
|
|
if NeedPassword and (InitPassword <> '') then begin
|
|
if NeedPassword and (InitPassword <> '') then begin
|
|
var PasswordOk := False;
|
|
var PasswordOk := False;
|
|
var S := InitPassword;
|
|
var S := InitPassword;
|
|
|
|
+ var CryptKey: TSetupEncryptionKey;
|
|
GenerateEncryptionKey(S, SetupEncryptionHeader.KDFSalt, SetupEncryptionHeader.KDFIterations, CryptKey);
|
|
GenerateEncryptionKey(S, SetupEncryptionHeader.KDFSalt, SetupEncryptionHeader.KDFIterations, CryptKey);
|
|
if shPassword in SetupHeader.Options then
|
|
if shPassword in SetupHeader.Options then
|
|
PasswordOk := TestPassword(CryptKey, SetupEncryptionHeader.BaseNonce, SetupEncryptionHeader.PasswordTest);
|
|
PasswordOk := TestPassword(CryptKey, SetupEncryptionHeader.BaseNonce, SetupEncryptionHeader.PasswordTest);
|
|
@@ -2743,18 +2749,12 @@ var
|
|
|
|
|
|
if PasswordOk then begin
|
|
if PasswordOk then begin
|
|
Result := False;
|
|
Result := False;
|
|
- if AllowSetFileExtractorCryptKey and (SetupEncryptionHeader.EncryptionUse <> euNone) then
|
|
|
|
|
|
+ if SetupEncryptionHeader.EncryptionUse = euFiles then
|
|
FileExtractor.CryptKey := CryptKey;
|
|
FileExtractor.CryptKey := CryptKey;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
- function HandleInitPassword(const NeedPassword: Boolean): Boolean; overload;
|
|
|
|
- begin
|
|
|
|
- var CryptKey: TSetupEncryptionKey;
|
|
|
|
- Result := HandleInitPassword(NeedPassword, True, CryptKey);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
procedure SetupInstallMode;
|
|
procedure SetupInstallMode;
|
|
begin
|
|
begin
|
|
if InitVerySilent then
|
|
if InitVerySilent then
|
|
@@ -3079,7 +3079,6 @@ begin
|
|
SetupMessages[msgSetupFileMissing] := SSetupFileMissing;
|
|
SetupMessages[msgSetupFileMissing] := SSetupFileMissing;
|
|
SetupMessages[msgSetupFileCorrupt] := SSetupFileCorrupt;
|
|
SetupMessages[msgSetupFileCorrupt] := SSetupFileCorrupt;
|
|
SetupMessages[msgSetupFileCorruptOrWrongVer] := SSetupFileCorruptOrWrongVer;
|
|
SetupMessages[msgSetupFileCorruptOrWrongVer] := SSetupFileCorruptOrWrongVer;
|
|
- SetupMessages[msgIncorrectPassword] := SIncorrectPassword;
|
|
|
|
|
|
|
|
{ Read setup-0.bin, or from EXE }
|
|
{ Read setup-0.bin, or from EXE }
|
|
if not SetupLdrMode then begin
|
|
if not SetupLdrMode then begin
|
|
@@ -3106,13 +3105,12 @@ begin
|
|
var CryptKey: TSetupEncryptionKey;
|
|
var CryptKey: TSetupEncryptionKey;
|
|
if SetupEncryptionHeader.EncryptionUse = euFull then begin
|
|
if SetupEncryptionHeader.EncryptionUse = euFull then begin
|
|
if InitPassword = '' then
|
|
if InitPassword = '' then
|
|
- raise Exception.Create(SMissingPassword);
|
|
|
|
- { HandleInitPassword requires this }
|
|
|
|
- SetupHeader.Options := SetupHeader.Options + [shPassword];
|
|
|
|
- { Specifying False for AllowSetFileExtractorCryptKey because FileExtractor (a function!)
|
|
|
|
- requires SetupHeader.CompressMethod to be set, so delaying until SetupHeader is read below }
|
|
|
|
- if HandleInitPassword(True, False, CryptKey) then { HandleInitPassword returns True on failure }
|
|
|
|
- AbortInit(msgIncorrectPassword)
|
|
|
|
|
|
+ AbortInit(SMissingPassword);
|
|
|
|
+ GenerateEncryptionKey(InitPassword, SetupEncryptionHeader.KDFSalt, SetupEncryptionHeader.KDFIterations, CryptKey);
|
|
|
|
+ if not TestPassword(CryptKey, SetupEncryptionHeader.BaseNonce, SetupEncryptionHeader.PasswordTest) then
|
|
|
|
+ AbortInit(SIncorrectPassword);
|
|
|
|
+ { FileExtractor (a function!) requires SetupHeader.CompressMethod to be set, so delaying setting
|
|
|
|
+ FileExtractor.CryptKey until SetupHeader is read below }
|
|
end;
|
|
end;
|
|
|
|
|
|
try
|
|
try
|