Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/DECBaseClass.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*****************************************************************************}

unit DECBaseClass;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

uses
{$IFDEF FPC}
Expand Down Expand Up @@ -237,7 +237,7 @@ class function TDECObject.Identity: Int64;
begin
{$IFDEF DEC52_IDENTITY}
Signature := StringOfChar(#$5A, 256 - Length(ClassName)) + UpperCase(ClassName);
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Result := CRC32(IdentityBase, Signature[Low(Signature)],
Length(Signature) * SizeOf(Signature[Low(Signature)]));
{$ELSE}
Expand All @@ -246,7 +246,7 @@ class function TDECObject.Identity: Int64;
{$IFEND}
{$ELSE !DEC52_IDENTITY}
Signature := RawByteString(StringOfChar(#$5A, 256 - Length(ClassName)) + UpperCase(ClassName));
{$IF CompilerVersion >= 24.0}
{$IFDEF HAVE_STR_LIKE_ARRAY}
Result := CRC32(IdentityBase, Signature[Low(Signature)],
Length(Signature) * SizeOf(Signature[Low(Signature)]));
{$ELSE}
Expand Down
4 changes: 2 additions & 2 deletions Source/DECCRC.pas
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
}

unit DECCRC;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}
interface

type
/// <summary>
Expand Down
14 changes: 7 additions & 7 deletions Source/DECCipherBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
under the License.
*****************************************************************************}
unit DECCipherBase;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

uses
{$IFDEF FPC}
Expand Down Expand Up @@ -1003,15 +1003,15 @@ procedure TDECCipher.Init(const Key : RawByteString;
raise EDECCipherException.CreateRes(@sNoKeyMaterialGiven);

if Length(IVector) > 0 then
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]),
IVector[Low(IVector)], Length(IVector) * SizeOf(IVector[Low(IVector)]), IFiller)
{$ELSE}
Init(Key[1], Length(Key) * SizeOf(Key[1]),
IVector[1], Length(IVector) * SizeOf(IVector[1]), IFiller)
{$IFEND}
else
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]), NullStr, 0, IFiller);
{$ELSE}
Init(Key[1], Length(Key) * SizeOf(Key[1]), NullStr, 0, IFiller);
Expand Down Expand Up @@ -1052,15 +1052,15 @@ procedure TDECCipher.Init(const Key, IVector: WideString; IFiller: Byte);
raise EDECCipherException.CreateRes(@sNoKeyMaterialGiven);

if Length(IVector) > 0 then
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]),
IVector[Low(IVector)], Length(IVector) * SizeOf(IVector[Low(IVector)]), IFiller)
{$ELSE}
Init(Key[1], Length(Key) * SizeOf(Key[1]),
IVector[1], Length(IVector) * SizeOf(IVector[1]), IFiller)
{$IFEND}
else
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Init(Key[Low(Key)], Length(Key) * SizeOf(Key[Low(Key)]), NullStr, 0, IFiller);
{$ELSE}
Init(Key[1], Length(Key) * SizeOf(Key[1]), NullStr, 0, IFiller);
Expand Down Expand Up @@ -1098,7 +1098,7 @@ function TDECCipher.EncodeRawByteString(const Source: RawByteString; Format: TDE
SetLength(b, 0);
if Length(Source) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
SetLength(b, Length(Source) * SizeOf(Source[Low(Source)]));
DoEncode(@Source[low(Source)], @b[0], Length(Source) * SizeOf(Source[low(Source)]));
{$ELSE}
Expand Down Expand Up @@ -1139,7 +1139,7 @@ function TDECCipher.DecodeRawByteString(const Source: RawByteString; Format: TDE
// This has been fixed in 10.3.0 Rio
b := ValidFormat(Format).Decode(BytesOf(Source));

{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
DoDecode(@b[0], @Result[Low(Result)], Length(Result) * SizeOf(Result[Low(Result)]));
{$ELSE}
DoDecode(@b[0], @Result[1], Length(Result) * SizeOf(Result[1]));
Expand Down
16 changes: 8 additions & 8 deletions Source/DECCipherFormats.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
under the License.
*****************************************************************************}
unit DECCipherFormats;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

uses
{$IFDEF FPC}
Expand Down Expand Up @@ -845,7 +845,7 @@ function TDECFormattedCipher.EncodeStringToBytes(const Source: string;
begin
if Length(Source) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Len := Length(Source) * SizeOf(Source[low(Source)]);
SetLength(Result, Len);
Encode(Source[low(Source)], Result[0], Len);
Expand All @@ -867,7 +867,7 @@ function TDECFormattedCipher.EncodeStringToBytes(const Source: RawByteString; Fo
begin
if Length(Source) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Len := Length(Source) * SizeOf(Source[low(Source)]);
SetLength(Result, Len);
Encode(Source[low(Source)], Result[0], Len);
Expand Down Expand Up @@ -1009,7 +1009,7 @@ function TDECFormattedCipher.EncodeStringToString(const Source: string;
begin
if Length(Source) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
SourceSize := Length(Source) * SizeOf(Source[low(Source)]);
SetLength(EncryptedBuffer, SourceSize);
Encode(Source[low(Source)], EncryptedBuffer[0], SourceSize);
Expand All @@ -1034,7 +1034,7 @@ function TDECFormattedCipher.EncodeStringToString(const Source: RawByteString;
begin
if Length(Source) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
SourceSize := Length(Source) * SizeOf(Source[low(Source)]);
SetLength(EncryptedBuffer, SourceSize);
Encode(Source[low(Source)], EncryptedBuffer[0], SourceSize);
Expand All @@ -1046,7 +1046,7 @@ function TDECFormattedCipher.EncodeStringToString(const Source: RawByteString;

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

SetLength(Result, length(Tmp));

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

SetLength(Result, length(Tmp));

{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Move(Tmp[0], Result[low(Result)], length(Tmp))
{$ELSE}
Move(Tmp[0], Result[1], length(Tmp))
Expand Down
6 changes: 3 additions & 3 deletions Source/DECCipherModes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
under the License.
*****************************************************************************}
unit DECCipherModes;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

uses
{$IFDEF FPC}
Expand Down Expand Up @@ -470,7 +470,7 @@ implementation
procedure TDECCipherModes.ReportInvalidMessageLength(Cipher: TDECCipher);
begin
raise EDECCipherException.CreateResFmt(@sInvalidMessageLength,
[System.TypInfo.GetEnumName(TypeInfo(TCipherMode),
[GetEnumName(TypeInfo(TCipherMode),
Integer(Cipher.Mode)),
Cipher.Context.BlockSize]);
end;
Expand Down Expand Up @@ -740,7 +740,7 @@ procedure TDECCipherModes.InitMode;
else
// GCM requires a cipher with 128 bit block size
raise EDECCipherException.CreateResFmt(@sInvalidBlockSize,
[128, System.TypInfo.GetEnumName(TypeInfo(TCipherMode),
[128, GetEnumName(TypeInfo(TCipherMode),
Integer(FMode))]);
end
else
Expand Down
10 changes: 5 additions & 5 deletions Source/DECFormat.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
/// to data
/// </summary>
unit DECFormat;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

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

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

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

SetLength(result, 68);
{$IF CompilerVersion >= 28.0}
{$IFdef HAVE_ASSIGN_ARRAY}
result := [$60, $21, $22, $23, $24, $25, $26, $27, $28, $29, $2A, $2B, $2C,
$2D, $2E, $2F, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39,
$3A, $3B, $3C, $3D, $3E, $3F, $40, $41, $42, $43, $44, $45, $46,
Expand Down Expand Up @@ -1350,7 +1350,7 @@ class function TFormat_XX.CharTableBinary: TBytes;
// '+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' +
// ' "()[]'''+CHR(9)+CHR(10)+CHR(13);
SetLength(result, 74);
{$IF CompilerVersion >= 28.0}
{$IFdef HAVE_ASSIGN_ARRAY}
result := [$2B, $2D, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $41,
$42, $43, $44, $45, $46, $47, $48, $49, $4A, $4B, $4C, $4D, $4E,
$4F, $50, $51, $52, $53, $54, $55, $56, $57, $58, $59, $5A, $61,
Expand Down
9 changes: 4 additions & 5 deletions Source/DECFormatBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
/// Contains the base class for all the formatting classes
/// </summary>
unit DECFormatBase;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

uses
{$IFDEF FPC}
SysUtils, Classes,
Expand Down Expand Up @@ -451,7 +450,7 @@ class function TDECFormat.Encode(const Data: RawByteString): RawByteString;
begin
if Length(Data) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
DoEncode(Data[Low(Data)], b, Length(Data) * SizeOf(Data[Low(Data)]));
{$ELSE}
DoEncode(Data[1], b, Length(Data) * SizeOf(Data[1]));
Expand Down Expand Up @@ -504,7 +503,7 @@ class function TDECFormat.Decode(const Data: RawByteString): RawByteString;
begin
if Length(Data) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
DoDecode(Data[Low(Data)], b, Length(Data) * SizeOf(Data[Low(Data)]));
{$ELSE}
DoDecode(Data[1], b, Length(Data) * SizeOf(Data[1]));
Expand Down Expand Up @@ -553,7 +552,7 @@ class function TDECFormat.IsValid(const Data: TBytes): Boolean;

class function TDECFormat.IsValid(const Text: RawByteString): Boolean;
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Result := (Length(Text) = 0) or
(DoIsValid(Text[Low(Text)], Length(Text) * SizeOf(Text[Low(Text)])));
{$ELSE}
Expand Down
6 changes: 3 additions & 3 deletions Source/DECHashAuthentication.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/// Unit containing all the KDF, MGF, HMAC and PBKDF2 algorithms
/// </summary>
unit DECHashAuthentication;
{$INCLUDE DECOptions.inc}

interface

Expand All @@ -30,7 +31,6 @@ interface
{$ENDIF}
DECBaseClass, DECHashBase, DECHashInterface, DECTypes , DECFormatBase;

{$INCLUDE DECOptions.inc}

type
/// <summary>
Expand Down Expand Up @@ -912,7 +912,7 @@ TDECPasswordHash = class(TDECHashAuthentication, IDECHashPassword)
write SetSalt;
end;

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

{ TArrHelper }

{$IF CompilerVersion < 28.0}
{$IFNDEF HAVE_ASSIGN_ARRAY}
class procedure TArrHelper.AppendArrays<T>(var A: TArray<T>; const B: TArray<T>);
var
i, L: Integer;
Expand Down
16 changes: 7 additions & 9 deletions Source/DECHashBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
/// to inherit from TDECHashBit
/// </summary>
unit DECHashBase;
{$INCLUDE DECOptions.inc}

interface

{$INCLUDE DECOptions.inc}

uses
{$IFDEF FPC}
Expand All @@ -45,14 +45,12 @@ TDECHashClass = class of TDECHash;
/// <summary>
/// Base class for all hash algorithm implementation classes
/// </summary>
{$IFDEF FPC}
TDECHash = class(TDECObject) // does not find methods of the interface as it
// searches for AnsiString instead of RawByteString
// and thus does not find that
{$ELSE}
TDECHash = class(TDECObject, IDECHash)
{$ENDIF}
{$IFDEF FPC}
protected
{$ELSE}
strict private
{$ENDIF}
/// <summary>
/// Raises an EDECHashException hash algorithm not initialized exception
/// </summary>
Expand Down Expand Up @@ -704,7 +702,7 @@ function TDECHash.CalcString(const Value: string; Format: TDECFormatClass): stri
Result := '';
if Length(Value) > 0 then
begin
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
Size := Length(Value) * SizeOf(Value[low(Value)]);
Data := CalcBuffer(Value[low(Value)], Size);
{$ELSE}
Expand All @@ -726,7 +724,7 @@ function TDECHash.CalcString(const Value: RawByteString; Format: TDECFormatClass
begin
Result := '';
if Length(Value) > 0 then
{$IF CompilerVersion >= 24.0}
{$IFdef HAVE_STR_LIKE_ARRAY}
result := BytesToRawString(
ValidFormat(Format).Encode(
CalcBuffer(Value[low(Value)],
Expand Down
1 change: 1 addition & 0 deletions Source/DECHashInterface.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
under the License.
*****************************************************************************}
unit DECHashInterface;
{$INCLUDE DECOptions.inc}

interface

Expand Down
Loading