You've already forked lazarus-ccr
fpspreadsheet: Fix compilation of crypto package with FPC 3.3.1
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7376 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="11"/>
|
<Version Value="12"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<LRSInOutputDirectory Value="False"/>
|
<LRSInOutputDirectory Value="False"/>
|
||||||
|
<CompatibilityMode Value="True"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
<MainUnit Value="0"/>
|
|
||||||
<Title Value="ooxml_decrypt_and_read"/>
|
<Title Value="ooxml_decrypt_and_read"/>
|
||||||
<UseAppBundle Value="False"/>
|
<UseAppBundle Value="False"/>
|
||||||
</General>
|
</General>
|
||||||
@ -17,19 +17,16 @@
|
|||||||
</BuildModes>
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
|
||||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
|
||||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
<FormatVersion Value="2"/>
|
<FormatVersion Value="2"/>
|
||||||
<Modes Count="1">
|
<Modes Count="1">
|
||||||
<Mode0 Name="default">
|
<Mode0 Name="default">
|
||||||
<local>
|
<local>
|
||||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</Mode0>
|
</Mode0>
|
||||||
</Modes>
|
</Modes>
|
||||||
|
@ -27,11 +27,9 @@ var
|
|||||||
cell: PCell;
|
cell: PCell;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
password: String;
|
password: String;
|
||||||
Prot_enc: Integer = 0; // 0 - protected, 1 - encrypted workbook
|
Prot_enc: Integer = 1; // 0 - protected, 1 - encrypted workbook
|
||||||
|
|
||||||
begin
|
begin
|
||||||
MyDir := ExtractFilePath(ParamStr(0));
|
|
||||||
|
|
||||||
// Open the input file
|
// Open the input file
|
||||||
MyDir := ExtractFilePath(ParamStr(0));
|
MyDir := ExtractFilePath(ParamStr(0));
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<Package Version="4">
|
<Package Version="5">
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<Name Value="laz_fpspreadsheet_crypto"/>
|
<Name Value="laz_fpspreadsheet_crypto"/>
|
||||||
<Type Value="RunTimeOnly"/>
|
<Type Value="RunTimeOnly"/>
|
||||||
|
@ -126,52 +126,22 @@ uses
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
fpolebasic
|
fpolebasic;
|
||||||
;
|
|
||||||
|
|
||||||
procedure ConcatToByteArray(var outArray: TBytes; Arr1: TBytes; Arr2: TBytes);
|
procedure ConcatToByteArray(var OutArray: TBytes; Ptr1: PByte; ACount1: Integer;
|
||||||
var
|
Ptr2: PByte; ACount2: Integer);
|
||||||
LenArr1 : Integer;
|
|
||||||
LenArr2 : Integer;
|
|
||||||
begin
|
begin
|
||||||
LenArr1 := Length(Arr1);
|
SetLength(OutArray, ACount1 + ACount2);
|
||||||
LenArr2 := Length(Arr2);
|
if ACount1 > 0 then
|
||||||
|
Move(Ptr1^, OutArray[0], ACount1);
|
||||||
SetLength( outArray, LenArr1 + LenArr2 );
|
if ACount2 > 0 then
|
||||||
|
Move(Ptr2^, OutArray[ACount1], ACount2);
|
||||||
if LenArr1 > 0 then
|
|
||||||
Move(Arr1[0], outArray[0], LenArr1);
|
|
||||||
|
|
||||||
if LenArr2 > 0 then
|
|
||||||
Move(Arr2[0], outArray[LenArr1], LenArr2);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ConcatToByteArray(var outArray: TBytes; AValue: DWord; Arr: TBytes);
|
procedure ConcatToByteArray(var OutArray: TBytes; Ptr: PByte; ACount: Integer;
|
||||||
var
|
const Arr: TBytes);
|
||||||
LenArr : Integer;
|
|
||||||
begin
|
begin
|
||||||
LenArr := Length(Arr);
|
ConcatToByteArray(OutArray, Ptr, ACount, @Arr[0], Length(Arr));
|
||||||
|
|
||||||
SetLength( outArray, 4 + LenArr );
|
|
||||||
|
|
||||||
Move(AValue, outArray[0], 4);
|
|
||||||
|
|
||||||
if LenArr > 0 then
|
|
||||||
Move(Arr[0], outArray[4], LenArr);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure ConcatToByteArray(var outArray: TBytes; Arr: TBytes; AValue: DWord);
|
|
||||||
var
|
|
||||||
LenArr : Integer;
|
|
||||||
begin
|
|
||||||
LenArr := Length(Arr);
|
|
||||||
|
|
||||||
SetLength( outArray, 4 + LenArr );
|
|
||||||
|
|
||||||
if LenArr > 0 then
|
|
||||||
Move(Arr[0], outArray[0], LenArr);
|
|
||||||
|
|
||||||
Move(AValue, outArray[LenArr], 4);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TExcelFileDecryptor.InitEncryptionInfo(AStream: TStream): string;
|
function TExcelFileDecryptor.InitEncryptionInfo(AStream: TStream): string;
|
||||||
@ -312,6 +282,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TExcelFileDecryptor.CheckPasswordInternal(APassword: UnicodeString): Boolean;
|
function TExcelFileDecryptor.CheckPasswordInternal(APassword: UnicodeString): Boolean;
|
||||||
|
const
|
||||||
|
Zero: DWord = 0;
|
||||||
var
|
var
|
||||||
AES_Cipher: TDCP_rijndael;
|
AES_Cipher: TDCP_rijndael;
|
||||||
|
|
||||||
@ -340,20 +312,21 @@ begin
|
|||||||
|
|
||||||
// 1.1.Concat Salt and Password
|
// 1.1.Concat Salt and Password
|
||||||
// Calculate SHA1(0) = SHA1(salt + password)
|
// Calculate SHA1(0) = SHA1(salt + password)
|
||||||
ConcatToByteArray( ConcArr
|
ConcatToByteArray(ConcArr, FEncInfo.Verifier.Salt, Length(FEncInfo.Verifier.Salt),
|
||||||
, FEncInfo.Verifier.Salt
|
TEncoding.Unicode.GetBytes(APassword));
|
||||||
, TEncoding.Unicode.GetBytes(APassword));
|
|
||||||
LastHash := SHA1Buffer( ConcArr[0], Length(ConcArr) );
|
LastHash := SHA1Buffer( ConcArr[0], Length(ConcArr) );
|
||||||
|
|
||||||
// 1.2.Calculate SHA1(n) = SHA1(iterator + SHA1(n-1) ) -- iterator is 32bit
|
// 1.2.Calculate SHA1(n) = SHA1(iterator + SHA1(n-1) ) -- iterator is 32bit
|
||||||
for Iterator := 0 to 49999 do
|
for Iterator := 0 to 49999 do
|
||||||
begin
|
begin
|
||||||
ConcatToByteArray(ConcArr, Iterator, LastHash);
|
// ConcatToByteArray(ConcArr, Iterator, LastHash);
|
||||||
|
ConcatToByteArray(ConcArr, @Iterator, SizeOf(Iterator), @LastHash[0], Length(LastHash));
|
||||||
LastHash := SHA1Buffer( ConcArr[0], Length(ConcArr) );
|
LastHash := SHA1Buffer( ConcArr[0], Length(ConcArr) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// 1.3.Claculate final hash, SHA1(final) = SHA1(H(n) + block) -- block = 0 (32bit)
|
// 1.3.Claculate final hash, SHA1(final) = SHA1(H(n) + block) -- block = 0 (32bit)
|
||||||
ConcatToByteArray(ConcArr, LastHash, 0);
|
ConcatTobyteArray(ConcArr, @LastHash[0], Length(LastHash), @Zero, Sizeof(Zero));
|
||||||
|
// ConcatToByteArray(ConcArr, LastHash, 0);
|
||||||
LastHash := SHA1Buffer( ConcArr[0], Length(ConcArr) );
|
LastHash := SHA1Buffer( ConcArr[0], Length(ConcArr) );
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user