Skip to content

Commit 9708af5

Browse files
author
alexrayne
committed
+package Lazarus fpc 3.2+
* starts asm code extracting on -> machine-dependent sources, with FPC-stylec directory structure: x86/ and x86_64/ dirs are CPU-targets * problems: FPC planed lambdas on ver3.3. So TDECProgressEvent still maybe only procedure
1 parent 91d6e66 commit 9708af5

18 files changed

+321
-89
lines changed

Source/DECBaseClass.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
*****************************************************************************}
1717

1818
unit DECBaseClass;
19+
{$INCLUDE DECOptions.inc}
1920

2021
interface
2122

22-
{$INCLUDE DECOptions.inc}
2323

2424
uses
2525
{$IFDEF FPC}
@@ -237,7 +237,7 @@ class function TDECObject.Identity: Int64;
237237
begin
238238
{$IFDEF DEC52_IDENTITY}
239239
Signature := StringOfChar(#$5A, 256 - Length(ClassName)) + UpperCase(ClassName);
240-
{$IF CompilerVersion >= 24.0}
240+
{$IFdef HAVE_STR_LIKE_ARRAY}
241241
Result := CRC32(IdentityBase, Signature[Low(Signature)],
242242
Length(Signature) * SizeOf(Signature[Low(Signature)]));
243243
{$ELSE}
@@ -246,7 +246,7 @@ class function TDECObject.Identity: Int64;
246246
{$IFEND}
247247
{$ELSE !DEC52_IDENTITY}
248248
Signature := RawByteString(StringOfChar(#$5A, 256 - Length(ClassName)) + UpperCase(ClassName));
249-
{$IF CompilerVersion >= 24.0}
249+
{$IFDEF HAVE_STR_LIKE_ARRAY}
250250
Result := CRC32(IdentityBase, Signature[Low(Signature)],
251251
Length(Signature) * SizeOf(Signature[Low(Signature)]));
252252
{$ELSE}

Source/DECCRC.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
}
4848

4949
unit DECCRC;
50+
{$INCLUDE DECOptions.inc}
5051

51-
interface
5252

53-
{$INCLUDE DECOptions.inc}
53+
interface
5454

5555
type
5656
/// <summary>

Source/DECCipherBase.pas

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
under the License.
1616
*****************************************************************************}
1717
unit DECCipherBase;
18+
{$INCLUDE DECOptions.inc}
1819

1920
interface
2021

21-
{$INCLUDE DECOptions.inc}
2222

2323
uses
2424
{$IFDEF FPC}
@@ -1003,15 +1003,15 @@ procedure TDECCipher.Init(const Key : RawByteString;
10031003
raise EDECCipherException.CreateRes(@sNoKeyMaterialGiven);
10041004

10051005
if Length(IVector) > 0 then
1006-
{$IF CompilerVersion >= 24.0}
1006+
{$IFdef HAVE_STR_LIKE_ARRAY}
10071007
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]),
10081008
IVector[Low(IVector)], Length(IVector) * SizeOf(IVector[Low(IVector)]), IFiller)
10091009
{$ELSE}
10101010
Init(Key[1], Length(Key) * SizeOf(Key[1]),
10111011
IVector[1], Length(IVector) * SizeOf(IVector[1]), IFiller)
10121012
{$IFEND}
10131013
else
1014-
{$IF CompilerVersion >= 24.0}
1014+
{$IFdef HAVE_STR_LIKE_ARRAY}
10151015
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]), NullStr, 0, IFiller);
10161016
{$ELSE}
10171017
Init(Key[1], Length(Key) * SizeOf(Key[1]), NullStr, 0, IFiller);
@@ -1052,15 +1052,15 @@ procedure TDECCipher.Init(const Key, IVector: WideString; IFiller: Byte);
10521052
raise EDECCipherException.CreateRes(@sNoKeyMaterialGiven);
10531053

10541054
if Length(IVector) > 0 then
1055-
{$IF CompilerVersion >= 24.0}
1055+
{$IFdef HAVE_STR_LIKE_ARRAY}
10561056
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]),
10571057
IVector[Low(IVector)], Length(IVector) * SizeOf(IVector[Low(IVector)]), IFiller)
10581058
{$ELSE}
10591059
Init(Key[1], Length(Key) * SizeOf(Key[1]),
10601060
IVector[1], Length(IVector) * SizeOf(IVector[1]), IFiller)
10611061
{$IFEND}
10621062
else
1063-
{$IF CompilerVersion >= 24.0}
1063+
{$IFdef HAVE_STR_LIKE_ARRAY}
10641064
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]), NullStr, 0, IFiller);
10651065
{$ELSE}
10661066
Init(Key[1], Length(Key) * SizeOf(Key[1]), NullStr, 0, IFiller);
@@ -1098,7 +1098,7 @@ function TDECCipher.EncodeRawByteString(const Source: RawByteString; Format: TDE
10981098
SetLength(b, 0);
10991099
if Length(Source) > 0 then
11001100
begin
1101-
{$IF CompilerVersion >= 24.0}
1101+
{$IFdef HAVE_STR_LIKE_ARRAY}
11021102
SetLength(b, Length(Source) * SizeOf(Source[Low(Source)]));
11031103
DoEncode(@Source[low(Source)], @b[0], Length(Source) * SizeOf(Source[low(Source)]));
11041104
{$ELSE}
@@ -1139,7 +1139,7 @@ function TDECCipher.DecodeRawByteString(const Source: RawByteString; Format: TDE
11391139
// This has been fixed in 10.3.0 Rio
11401140
b := ValidFormat(Format).Decode(BytesOf(Source));
11411141

1142-
{$IF CompilerVersion >= 24.0}
1142+
{$IFdef HAVE_STR_LIKE_ARRAY}
11431143
DoDecode(@b[0], @Result[Low(Result)], Length(Result) * SizeOf(Result[Low(Result)]));
11441144
{$ELSE}
11451145
DoDecode(@b[0], @Result[1], Length(Result) * SizeOf(Result[1]));

Source/DECCipherFormats.pas

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
under the License.
1616
*****************************************************************************}
1717
unit DECCipherFormats;
18+
{$INCLUDE DECOptions.inc}
1819

1920
interface
2021

21-
{$INCLUDE DECOptions.inc}
2222

2323
uses
2424
{$IFDEF FPC}
@@ -845,7 +845,7 @@ function TDECFormattedCipher.EncodeStringToBytes(const Source: string;
845845
begin
846846
if Length(Source) > 0 then
847847
begin
848-
{$IF CompilerVersion >= 24.0}
848+
{$IFdef HAVE_STR_LIKE_ARRAY}
849849
Len := Length(Source) * SizeOf(Source[low(Source)]);
850850
SetLength(Result, Len);
851851
Encode(Source[low(Source)], Result[0], Len);
@@ -867,7 +867,7 @@ function TDECFormattedCipher.EncodeStringToBytes(const Source: RawByteString; Fo
867867
begin
868868
if Length(Source) > 0 then
869869
begin
870-
{$IF CompilerVersion >= 24.0}
870+
{$IFdef HAVE_STR_LIKE_ARRAY}
871871
Len := Length(Source) * SizeOf(Source[low(Source)]);
872872
SetLength(Result, Len);
873873
Encode(Source[low(Source)], Result[0], Len);
@@ -1009,7 +1009,7 @@ function TDECFormattedCipher.EncodeStringToString(const Source: string;
10091009
begin
10101010
if Length(Source) > 0 then
10111011
begin
1012-
{$IF CompilerVersion >= 24.0}
1012+
{$IFdef HAVE_STR_LIKE_ARRAY}
10131013
SourceSize := Length(Source) * SizeOf(Source[low(Source)]);
10141014
SetLength(EncryptedBuffer, SourceSize);
10151015
Encode(Source[low(Source)], EncryptedBuffer[0], SourceSize);
@@ -1034,7 +1034,7 @@ function TDECFormattedCipher.EncodeStringToString(const Source: RawByteString;
10341034
begin
10351035
if Length(Source) > 0 then
10361036
begin
1037-
{$IF CompilerVersion >= 24.0}
1037+
{$IFdef HAVE_STR_LIKE_ARRAY}
10381038
SourceSize := Length(Source) * SizeOf(Source[low(Source)]);
10391039
SetLength(EncryptedBuffer, SourceSize);
10401040
Encode(Source[low(Source)], EncryptedBuffer[0], SourceSize);
@@ -1046,7 +1046,7 @@ function TDECFormattedCipher.EncodeStringToString(const Source: RawByteString;
10461046

10471047
Temp := ValidFormat(Format).Encode(EncryptedBuffer);
10481048
SetLength(Result, length(Temp));
1049-
{$IF CompilerVersion >= 24.0}
1049+
{$IFdef HAVE_STR_LIKE_ARRAY}
10501050
Move(Temp[0], Result[low(Result)], length(Temp))
10511051
{$ELSE}
10521052
Move(Temp[0], Result[1], length(Temp))
@@ -1093,7 +1093,7 @@ function TDECFormattedCipher.DecodeStringToString(const Source: AnsiString;
10931093

10941094
SetLength(Result, length(Tmp));
10951095

1096-
{$IF CompilerVersion >= 24.0}
1096+
{$IFdef HAVE_STR_LIKE_ARRAY}
10971097
Move(Tmp[0], Result[low(Result)], length(Tmp))
10981098
{$ELSE}
10991099
Move(Tmp[0], Result[1], length(Tmp))
@@ -1129,7 +1129,7 @@ function TDECFormattedCipher.DecodeStringToString(const Source: RawByteString;
11291129

11301130
SetLength(Result, length(Tmp));
11311131

1132-
{$IF CompilerVersion >= 24.0}
1132+
{$IFdef HAVE_STR_LIKE_ARRAY}
11331133
Move(Tmp[0], Result[low(Result)], length(Tmp))
11341134
{$ELSE}
11351135
Move(Tmp[0], Result[1], length(Tmp))

Source/DECCipherModes.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
under the License.
1616
*****************************************************************************}
1717
unit DECCipherModes;
18+
{$INCLUDE DECOptions.inc}
1819

1920
interface
2021

21-
{$INCLUDE DECOptions.inc}
2222

2323
uses
2424
{$IFDEF FPC}
@@ -470,7 +470,7 @@ implementation
470470
procedure TDECCipherModes.ReportInvalidMessageLength(Cipher: TDECCipher);
471471
begin
472472
raise EDECCipherException.CreateResFmt(@sInvalidMessageLength,
473-
[System.TypInfo.GetEnumName(TypeInfo(TCipherMode),
473+
[GetEnumName(TypeInfo(TCipherMode),
474474
Integer(Cipher.Mode)),
475475
Cipher.Context.BlockSize]);
476476
end;
@@ -740,7 +740,7 @@ procedure TDECCipherModes.InitMode;
740740
else
741741
// GCM requires a cipher with 128 bit block size
742742
raise EDECCipherException.CreateResFmt(@sInvalidBlockSize,
743-
[128, System.TypInfo.GetEnumName(TypeInfo(TCipherMode),
743+
[128, GetEnumName(TypeInfo(TCipherMode),
744744
Integer(FMode))]);
745745
end
746746
else

Source/DECFormat.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
/// to data
2121
/// </summary>
2222
unit DECFormat;
23+
{$INCLUDE DECOptions.inc}
2324

2425
interface
2526

26-
{$INCLUDE DECOptions.inc}
2727

2828
uses
2929
{$IFDEF FPC}
@@ -431,7 +431,7 @@ class function TFormat_HEX.CharTableBinary: TBytes;
431431
// special and skipped chars
432432
// '0123456789ABCDEFX$ abcdefhHx()[]{},;:-_/\*+"'''+CHR(9)+CHR(10)+CHR(13);
433433

434-
{$IF CompilerVersion >= 28.0}
434+
{$IFdef HAVE_ASSIGN_ARRAY}
435435
result := [$30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $41, $42, $43,
436436
$44, $45, $46, $58, $24, $20, $61, $62, $63, $64, $65, $66, $68,
437437
$48, $78, $28, $29, $5B, $5D, $7B, $7D, $2C, $3B, $3A, $2D, $5F,
@@ -597,7 +597,7 @@ class function TFormat_HEXL.CharTableBinary: TBytes;
597597
// special and skipped chars
598598
// '0123456789abcdefX$ ABCDEFhHx()[]{},;:-_/\*+"'''+CHR(9)+CHR(10)+CHR(13);
599599

600-
{$IF CompilerVersion >= 28.0}
600+
{$IFdef HAVE_ASSIGN_ARRAY}
601601
result := [$30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $61, $62, $63,
602602
$64, $65, $66, $68, $58, $24, $20, $41, $42, $43, $44, $45, $46,
603603
$48, $78, $28, $29, $5B, $5D, $7B, $7D, $2C, $3B, $3A, $2D, $5F,
@@ -1113,7 +1113,7 @@ class function TFormat_UU.CharTableBinary: TBytes;
11131113
// ' '+CHR(9)+CHR(10)+CHR(13);
11141114

11151115
SetLength(result, 68);
1116-
{$IF CompilerVersion >= 28.0}
1116+
{$IFdef HAVE_ASSIGN_ARRAY}
11171117
result := [$60, $21, $22, $23, $24, $25, $26, $27, $28, $29, $2A, $2B, $2C,
11181118
$2D, $2E, $2F, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39,
11191119
$3A, $3B, $3C, $3D, $3E, $3F, $40, $41, $42, $43, $44, $45, $46,
@@ -1350,7 +1350,7 @@ class function TFormat_XX.CharTableBinary: TBytes;
13501350
// '+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' +
13511351
// ' "()[]'''+CHR(9)+CHR(10)+CHR(13);
13521352
SetLength(result, 74);
1353-
{$IF CompilerVersion >= 28.0}
1353+
{$IFdef HAVE_ASSIGN_ARRAY}
13541354
result := [$2B, $2D, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $41,
13551355
$42, $43, $44, $45, $46, $47, $48, $49, $4A, $4B, $4C, $4D, $4E,
13561356
$4F, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $61,

Source/DECFormatBase.pas

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
/// Contains the base class for all the formatting classes
2020
/// </summary>
2121
unit DECFormatBase;
22+
{$INCLUDE DECOptions.inc}
2223

2324
interface
2425

25-
{$INCLUDE DECOptions.inc}
26-
2726
uses
2827
{$IFDEF FPC}
2928
SysUtils, Classes,
@@ -451,7 +450,7 @@ class function TDECFormat.Encode(const Data: RawByteString): RawByteString;
451450
begin
452451
if Length(Data) > 0 then
453452
begin
454-
{$IF CompilerVersion >= 24.0}
453+
{$IFdef HAVE_STR_LIKE_ARRAY}
455454
DoEncode(Data[Low(Data)], b, Length(Data) * SizeOf(Data[Low(Data)]));
456455
{$ELSE}
457456
DoEncode(Data[1], b, Length(Data) * SizeOf(Data[1]));
@@ -504,7 +503,7 @@ class function TDECFormat.Decode(const Data: RawByteString): RawByteString;
504503
begin
505504
if Length(Data) > 0 then
506505
begin
507-
{$IF CompilerVersion >= 24.0}
506+
{$IFdef HAVE_STR_LIKE_ARRAY}
508507
DoDecode(Data[Low(Data)], b, Length(Data) * SizeOf(Data[Low(Data)]));
509508
{$ELSE}
510509
DoDecode(Data[1], b, Length(Data) * SizeOf(Data[1]));
@@ -553,7 +552,7 @@ class function TDECFormat.IsValid(const Data: TBytes): Boolean;
553552

554553
class function TDECFormat.IsValid(const Text: RawByteString): Boolean;
555554
begin
556-
{$IF CompilerVersion >= 24.0}
555+
{$IFdef HAVE_STR_LIKE_ARRAY}
557556
Result := (Length(Text) = 0) or
558557
(DoIsValid(Text[Low(Text)], Length(Text) * SizeOf(Text[Low(Text)])));
559558
{$ELSE}

Source/DECHashAuthentication.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/// Unit containing all the KDF, MGF, HMAC and PBKDF2 algorithms
2020
/// </summary>
2121
unit DECHashAuthentication;
22+
{$INCLUDE DECOptions.inc}
2223

2324
interface
2425

@@ -30,7 +31,6 @@ interface
3031
{$ENDIF}
3132
DECBaseClass, DECHashBase, DECHashInterface, DECTypes , DECFormatBase;
3233

33-
{$INCLUDE DECOptions.inc}
3434

3535
type
3636
/// <summary>
@@ -912,7 +912,7 @@ TDECPasswordHash = class(TDECHashAuthentication, IDECHashPassword)
912912
write SetSalt;
913913
end;
914914

915-
{$IF CompilerVersion < 28.0}
915+
{$IFndef HAVE_ASSIGN_ARRAY}
916916
/// <summary>
917917
/// Class helper for implementing array concatenation which is not available
918918
/// in Delphi XE6 or lower.
@@ -1508,7 +1508,7 @@ function TDECHashExtended.CalcFile(const FileName: string; Format: TDECFormatCla
15081508

15091509
{ TArrHelper }
15101510

1511-
{$IF CompilerVersion < 28.0}
1511+
{$IFNDEF HAVE_ASSIGN_ARRAY}
15121512
class procedure TArrHelper.AppendArrays<T>(var A: TArray<T>; const B: TArray<T>);
15131513
var
15141514
i, L: Integer;

Source/DECHashBase.pas

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
/// to inherit from TDECHashBit
2323
/// </summary>
2424
unit DECHashBase;
25+
{$INCLUDE DECOptions.inc}
2526

2627
interface
2728

28-
{$INCLUDE DECOptions.inc}
2929

3030
uses
3131
{$IFDEF FPC}
@@ -45,14 +45,12 @@ TDECHashClass = class of TDECHash;
4545
/// <summary>
4646
/// Base class for all hash algorithm implementation classes
4747
/// </summary>
48-
{$IFDEF FPC}
49-
TDECHash = class(TDECObject) // does not find methods of the interface as it
50-
// searches for AnsiString instead of RawByteString
51-
// and thus does not find that
52-
{$ELSE}
5348
TDECHash = class(TDECObject, IDECHash)
54-
{$ENDIF}
49+
{$IFDEF FPC}
50+
protected
51+
{$ELSE}
5552
strict private
53+
{$ENDIF}
5654
/// <summary>
5755
/// Raises an EDECHashException hash algorithm not initialized exception
5856
/// </summary>
@@ -704,7 +702,7 @@ function TDECHash.CalcString(const Value: string; Format: TDECFormatClass): stri
704702
Result := '';
705703
if Length(Value) > 0 then
706704
begin
707-
{$IF CompilerVersion >= 24.0}
705+
{$IFdef HAVE_STR_LIKE_ARRAY}
708706
Size := Length(Value) * SizeOf(Value[low(Value)]);
709707
Data := CalcBuffer(Value[low(Value)], Size);
710708
{$ELSE}
@@ -726,7 +724,7 @@ function TDECHash.CalcString(const Value: RawByteString; Format: TDECFormatClass
726724
begin
727725
Result := '';
728726
if Length(Value) > 0 then
729-
{$IF CompilerVersion >= 24.0}
727+
{$IFdef HAVE_STR_LIKE_ARRAY}
730728
result := BytesToRawString(
731729
ValidFormat(Format).Encode(
732730
CalcBuffer(Value[low(Value)],

Source/DECHashInterface.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
under the License.
1616
*****************************************************************************}
1717
unit DECHashInterface;
18+
{$INCLUDE DECOptions.inc}
1819

1920
interface
2021

0 commit comments

Comments
 (0)