diff --git a/CryptoLib/src/Crypto/Digests/ClpDigest.pas b/CryptoLib/src/Crypto/Digests/ClpDigest.pas index d9560089..9c21722e 100644 --- a/CryptoLib/src/Crypto/Digests/ClpDigest.pas +++ b/CryptoLib/src/Crypto/Digests/ClpDigest.pas @@ -122,13 +122,10 @@ function TDigest.GetAlgorithmName: string; LowPoint, HighPoint: Int32; begin LName := FHash.Name; -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(LName); - HighPoint := System.High(LName); -{$ELSE} + LowPoint := 1; HighPoint := System.Length(LName); -{$ENDIF DELPHIXE3_UP} + result := Copy(LName, LowPoint + 1, HighPoint - 1); end; diff --git a/CryptoLib/src/Crypto/Macs/ClpKMac.pas b/CryptoLib/src/Crypto/Macs/ClpKMac.pas index 1b6472fe..07a1d05e 100644 --- a/CryptoLib/src/Crypto/Macs/ClpKMac.pas +++ b/CryptoLib/src/Crypto/Macs/ClpKMac.pas @@ -149,13 +149,10 @@ function TKMac.GetAlgorithmName: string; LowPoint, HighPoint: Int32; begin LName := Self.ClassName; -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(LName); - HighPoint := System.High(LName); -{$ELSE} + LowPoint := 1; HighPoint := System.Length(LName); -{$ENDIF DELPHIXE3_UP} + result := Copy(LName, LowPoint + 1, HighPoint - 1); end; diff --git a/CryptoLib/src/Include/CryptoLib.inc b/CryptoLib/src/Include/CryptoLib.inc index c07e3c09..c4bec1d4 100644 --- a/CryptoLib/src/Include/CryptoLib.inc +++ b/CryptoLib/src/Include/CryptoLib.inc @@ -15,224 +15,21 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -{$DEFINE DELPHI} -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) +{---------------------------- Compiler Family Switch --------------------------} {$IFDEF FPC} -{$I CryptoLibHelper.inc} // Had to Include this Since Delphi Does not allow "FPC_FULLVERSION" to Compile. -{$UNDEF DELPHI} -{$MODE delphi} - -{$IFDEF CPU386} - {$DEFINE CRYPTOLIB_X86} -{$ENDIF} - -{$IFDEF CPUX64} - {$DEFINE CRYPTOLIB_X86_64} -{$ENDIF} - -{$IFDEF CPUARM} - {$DEFINE CRYPTOLIB_ARM} -{$ENDIF} - -{$IFDEF CPUAARCH64} - {$DEFINE CRYPTOLIB_AARCH64} -{$ENDIF} - -{$IFDEF IPHONESIM} - {$DEFINE CRYPTOLIB_IOSSIM} -{$ENDIF} - -{$IF DEFINED(MSWINDOWS)} - {$DEFINE CRYPTOLIB_MSWINDOWS} -{$ELSEIF DEFINED(UNIX)} - {$DEFINE CRYPTOLIB_UNIX} - {$IF DEFINED(BSD)} - {$IF DEFINED(DARWIN)} - {$DEFINE CRYPTOLIB_APPLE} - {$IF DEFINED(CRYPTOLIB_ARM) OR DEFINED(CRYPTOLIB_AARCH64)} - {$DEFINE CRYPTOLIB_IOS} - {$ELSE} - {$DEFINE CRYPTOLIB_MACOS} - {$IFEND} - {$ELSEIF DEFINED(FREEBSD) OR DEFINED(NETBSD) OR DEFINED(OPENBSD) OR DEFINED(DRAGONFLY)} - {$DEFINE CRYPTOLIB_GENERIC_BSD} - {$IFEND} - {$ELSEIF DEFINED(ANDROID)} - {$DEFINE CRYPTOLIB_ANDROID} - {$ELSEIF DEFINED(LINUX)} - {$DEFINE CRYPTOLIB_LINUX} - {$ELSEIF DEFINED(SOLARIS)} - {$DEFINE CRYPTOLIB_SOLARIS} - {$ELSE} - {$DEFINE CRYPTOLIB_UNDEFINED_UNIX_VARIANTS} - {$IFEND} + {$I CryptoLibFPC.inc} // FPC-specific settings {$ELSE} - {$MESSAGE ERROR 'UNSUPPORTED TARGET.'} -{$IFEND} - -{$IFDEF CRYPTOLIB_ANDROID} - {$DEFINE CRYPTOLIB_LINUX} + {$DEFINE DELPHI} + {$I ../../CryptoLib/src/Include/CryptoLibDelphi.inc} // Delphi-specific settings {$ENDIF} -{$IF DEFINED(CRYPTOLIB_LINUX) OR DEFINED(CRYPTOLIB_SOLARIS)} - {$DEFINE CRYPTOLIB_HAS_GETRANDOM} -{$IFEND} - -{$DEFINE USE_UNROLLED_VARIANT} - -// Disable Overflow and RangeChecks. +{-------------------------- Common Compiler Settings --------------------------} +{$SCOPEDENUMS ON} {$OVERFLOWCHECKS OFF} {$RANGECHECKS OFF} - -// Enable Pointer Math {$POINTERMATH ON} - -// Disable Warnings and Hints. {$WARNINGS OFF} {$HINTS OFF} -{$NOTES OFF} - -// Optimizations -{$OPTIMIZATION LEVEL3} -// disable "USELOADMODIFYSTORE" because it produces incorrect result -// when used in combination with -CpCOREAVX2 and -OpCOREAVX2 in FPC 3.2.0 beta -{$IFDEF FPC_GREATER_THAN_3.0.4} - {$OPTIMIZATION NOUSELOADMODIFYSTORE} -{$ENDIF} -// level 4 optimizations -{$OPTIMIZATION ORDERFIELDS} -{$OPTIMIZATION DEADVALUES} - -{$IFDEF CPUI386} - {$OPTIMIZATION USEEBP} -{$ENDIF} - -{$IFDEF CPUX86_64} - {$OPTIMIZATION USERBP} -{$ENDIF} - -{$ENDIF FPC} - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) - -{$IFDEF DELPHI} - - // XE3 and Above -{$IF CompilerVersion >= 24.0} - {$DEFINE DELPHIXE3_UP} - {$DEFINE SUPPORT_TSTREAM_READ_BYTEARRAY_OVERLOAD} - {$DEFINE SUPPORT_TSTREAM_WRITE_BYTEARRAY_OVERLOAD} - {$LEGACYIFEND ON} - {$ZEROBASEDSTRINGS OFF} -{$IFEND} - - // XE and Above -{$IF CompilerVersion >= 22.0} - {$DEFINE DELPHIXE_UP} -{$IFEND} - - // XE4 and Above -{$IF CompilerVersion >= 25.0} - {$DEFINE DELPHIXE4_UP} - {$DEFINE SHIFT_OVERFLOW_BUG_FIXED} -{$IFEND} - - // 10.1 Berlin and Above -{$IF CompilerVersion >= 31.0} - {$DEFINE DELPHI10.1_BERLIN_UP} - {$DEFINE HAS_VOLATILE} -{$IFEND} - - // 10.2 Tokyo and Above -{$IF CompilerVersion >= 32.0} - {$DEFINE DELPHI10.2_TOKYO_UP} -{$IFEND} - - // 10.2 Tokyo and Above -{$IFNDEF DELPHI10.2_TOKYO_UP} - {$MESSAGE ERROR 'This Library requires Delphi Tokyo or higher.'} -{$ENDIF} - -{$IFDEF CPU386} - {$DEFINE CRYPTOLIB_X86} -{$ENDIF} - -{$IFDEF CPUX64} - {$DEFINE CRYPTOLIB_X86_64} -{$ENDIF} - -{$IFDEF CPUARM32} - {$DEFINE CRYPTOLIB_ARM} -{$ENDIF} - -{$IFDEF CPUARM64} - {$DEFINE CRYPTOLIB_AARCH64} -{$ENDIF} - -{$IFDEF IOS} - {$IFNDEF CPUARM} - {$DEFINE CRYPTOLIB_IOSSIM} - {$ENDIF} -{$ENDIF} - -{$IFDEF IOS} - {$DEFINE CRYPTOLIB_IOS} -{$ENDIF} - -{$IFDEF MSWINDOWS} - {$DEFINE CRYPTOLIB_MSWINDOWS} -{$ENDIF} - -{$IFDEF MACOS} - {$IFNDEF IOS} - {$DEFINE CRYPTOLIB_MACOS} - {$ENDIF} -{$ENDIF} - -{$IFDEF ANDROID} - {$DEFINE CRYPTOLIB_ANDROID} -{$ENDIF} - -{$IF DEFINED(CRYPTOLIB_IOS) OR DEFINED(CRYPTOLIB_MACOS)} - {$DEFINE CRYPTOLIB_APPLE} -{$IFEND} - -{$IF DEFINED(LINUX) OR DEFINED(CRYPTOLIB_ANDROID)} - {$DEFINE CRYPTOLIB_LINUX} -{$IFEND} - -{$IFDEF CRYPTOLIB_LINUX} - {$DEFINE CRYPTOLIB_HAS_GETRANDOM} -{$ENDIF} - -{$IF DEFINED(CRYPTOLIB_APPLE) OR DEFINED(CRYPTOLIB_LINUX)} - {$DEFINE CRYPTOLIB_UNIX} -{$IFEND} - -{$DEFINE USE_UNROLLED_VARIANT} - -// This option is needed to enable code browsing (aka Ctrl+Click) -// It does not affect the binary size or generated code -{$DEFINITIONINFO ON} - -// Disable Overflow and RangeChecks. -{$OVERFLOWCHECKS OFF} -{$RANGECHECKS OFF} - - // Enable Pointer Math -{$POINTERMATH ON} - -// Disable String Checks -{$STRINGCHECKS OFF} - -// Disable Duplicate Constructor Warnings -{$WARN DUPLICATE_CTOR_DTOR OFF} - -// Disable Deprecated Warnings -{$WARN SYMBOL_DEPRECATED OFF} - -{$ENDIF DELPHI} - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) diff --git a/CryptoLib/src/Include/CryptoLibDelphi.inc b/CryptoLib/src/Include/CryptoLibDelphi.inc new file mode 100644 index 00000000..1a5b713c --- /dev/null +++ b/CryptoLib/src/Include/CryptoLibDelphi.inc @@ -0,0 +1,105 @@ +{ *********************************************************************************** } +{ * CryptoLib Library * } +{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * } +{ * Github Repository * } + +{ * Distributed under the MIT software license, see the accompanying file LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license.php. * } + +{ * Acknowledgements: * } +{ * * } +{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } +{ * development of this library * } + +{ * ******************************************************************************* * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +{$IFDEF DELPHI} + {$DEFINITIONINFO ON} // IDE navigation; no binary impact + {$STRINGCHECKS OFF} + {$WARN DUPLICATE_CTOR_DTOR OFF} + +{$IF CompilerVersion < 32.0} + {$MESSAGE ERROR 'This Library requires Delphi Tokyo or higher.'} +{$IFEND} + + // XE and Above +{$IF CompilerVersion >= 22.0} + {$DEFINE DELPHIXE_UP} +{$IFEND} + + // XE3 and Above +{$IF CompilerVersion >= 24.0} + {$DEFINE SUPPORT_TSTREAM_READ_BYTEARRAY_OVERLOAD} + {$DEFINE SUPPORT_TSTREAM_WRITE_BYTEARRAY_OVERLOAD} +{$IFEND} + + // XE4 and Above +{$IF CompilerVersion >= 25.0} + {$DEFINE SHIFT_OVERFLOW_BUG_FIXED} +{$IFEND} + + // 10.1 Berlin and Above +{$IF CompilerVersion >= 31.0} + {$DEFINE HAS_VOLATILE} +{$IFEND} + +{$IFDEF CPU386} + {$DEFINE CRYPTOLIB_X86} +{$ENDIF} + +{$IFDEF CPUX64} + {$DEFINE CRYPTOLIB_X86_64} +{$ENDIF} + +{$IFDEF CPUARM32} + {$DEFINE CRYPTOLIB_ARM} +{$ENDIF} + +{$IFDEF CPUARM64} + {$DEFINE CRYPTOLIB_AARCH64} +{$ENDIF} + +{$IFDEF IOS} + {$IFNDEF CPUARM} + {$DEFINE CRYPTOLIB_IOSSIM} + {$ENDIF} +{$ENDIF} + +{$IFDEF IOS} + {$DEFINE CRYPTOLIB_IOS} +{$ENDIF} + +{$IFDEF MSWINDOWS} + {$DEFINE CRYPTOLIB_MSWINDOWS} +{$ENDIF} + +{$IFDEF MACOS} + {$IFNDEF IOS} + {$DEFINE CRYPTOLIB_MACOS} + {$ENDIF} +{$ENDIF} + +{$IFDEF ANDROID} + {$DEFINE CRYPTOLIB_ANDROID} +{$ENDIF} + +{$IF DEFINED(CRYPTOLIB_IOS) OR DEFINED(CRYPTOLIB_MACOS)} + {$DEFINE CRYPTOLIB_APPLE} +{$IFEND} + +{$IF DEFINED(LINUX) OR DEFINED(CRYPTOLIB_ANDROID)} + {$DEFINE CRYPTOLIB_LINUX} +{$IFEND} + +{$IFDEF CRYPTOLIB_LINUX} + {$DEFINE CRYPTOLIB_HAS_GETRANDOM} +{$ENDIF} + +{$IF DEFINED(CRYPTOLIB_APPLE) OR DEFINED(CRYPTOLIB_LINUX)} + {$DEFINE CRYPTOLIB_UNIX} +{$IFEND} + +{$ENDIF} + diff --git a/CryptoLib/src/Include/CryptoLibFPC.inc b/CryptoLib/src/Include/CryptoLibFPC.inc new file mode 100644 index 00000000..143a1570 --- /dev/null +++ b/CryptoLib/src/Include/CryptoLibFPC.inc @@ -0,0 +1,100 @@ +{ *********************************************************************************** } +{ * CryptoLib Library * } +{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * } +{ * Github Repository * } + +{ * Distributed under the MIT software license, see the accompanying file LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license.php. * } + +{ * Acknowledgements: * } +{ * * } +{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } +{ * development of this library * } + +{ * ******************************************************************************* * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +{$IFDEF FPC} +{$IFDEF ENDIAN_BIG} + {$MESSAGE FATAL 'This Library does not support "Big Endian" processors yet.'} +{$ENDIF} + +{$IF FPC_FULLVERSION < 30004} + {$MESSAGE ERROR 'This Library requires FreePascal 3.0.4 or higher.'} +{$IFEND} + +{$IF FPC_FULLVERSION >= 30301} + {$DEFINE HAS_VOLATILE} +{$IFEND} + +{$IFDEF CPU386} + {$DEFINE CRYPTOLIB_X86} +{$ENDIF} + +{$IFDEF CPUX64} + {$DEFINE CRYPTOLIB_X86_64} +{$ENDIF} + +{$IFDEF CPUARM} + {$DEFINE CRYPTOLIB_ARM} +{$ENDIF} + +{$IFDEF CPUAARCH64} + {$DEFINE CRYPTOLIB_AARCH64} +{$ENDIF} + +{$IFDEF IPHONESIM} + {$DEFINE CRYPTOLIB_IOSSIM} +{$ENDIF} + +{$IF DEFINED(MSWINDOWS)} + {$DEFINE CRYPTOLIB_MSWINDOWS} +{$ELSEIF DEFINED(UNIX)} + {$DEFINE CRYPTOLIB_UNIX} + {$IF DEFINED(BSD)} + {$IF DEFINED(DARWIN)} + {$DEFINE CRYPTOLIB_APPLE} + {$IF DEFINED(CRYPTOLIB_ARM) OR DEFINED(CRYPTOLIB_AARCH64)} + {$DEFINE CRYPTOLIB_IOS} + {$ELSE} + {$DEFINE CRYPTOLIB_MACOS} + {$IFEND} + {$ELSEIF DEFINED(FREEBSD) OR DEFINED(NETBSD) OR DEFINED(OPENBSD) OR DEFINED(DRAGONFLY)} + {$DEFINE CRYPTOLIB_GENERIC_BSD} + {$IFEND} + {$ELSEIF DEFINED(ANDROID)} + {$DEFINE CRYPTOLIB_ANDROID} + {$ELSEIF DEFINED(LINUX)} + {$DEFINE CRYPTOLIB_LINUX} + {$ELSEIF DEFINED(SOLARIS)} + {$DEFINE CRYPTOLIB_SOLARIS} + {$ELSE} + {$DEFINE CRYPTOLIB_UNDEFINED_UNIX_VARIANTS} + {$IFEND} +{$ELSE} + {$MESSAGE ERROR 'UNSUPPORTED TARGET.'} +{$IFEND} + +{$IFDEF CRYPTOLIB_ANDROID} + {$DEFINE CRYPTOLIB_LINUX} +{$ENDIF} + +{$IF DEFINED(CRYPTOLIB_LINUX) OR DEFINED(CRYPTOLIB_SOLARIS)} + {$DEFINE CRYPTOLIB_HAS_GETRANDOM} +{$IFEND} + + {$MODE DELPHI} + {$MACRO ON} + {$NOTES OFF} + + {$OPTIMIZATION LEVEL3} + + {$OPTIMIZATION NOREGVAR} + {$OPTIMIZATION NOUSELOADMODIFYSTORE} + {$OPTIMIZATION ORDERFIELDS} + {$OPTIMIZATION DEADVALUES} + {$IFDEF CPUI386} {$OPTIMIZATION USEEBP} {$ENDIF} + {$IFDEF CPUX86_64} {$OPTIMIZATION USERBP} {$ENDIF} +{$ENDIF} + diff --git a/CryptoLib/src/Include/CryptoLibHelper.inc b/CryptoLib/src/Include/CryptoLibHelper.inc deleted file mode 100644 index 317f0c00..00000000 --- a/CryptoLib/src/Include/CryptoLibHelper.inc +++ /dev/null @@ -1,34 +0,0 @@ -{ *********************************************************************************** } -{ * CryptoLib Library * } -{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * } -{ * Github Repository * } - -{ * Distributed under the MIT software license, see the accompanying file LICENSE * } -{ * or visit http://www.opensource.org/licenses/mit-license.php. * } - -{ * Acknowledgements: * } -{ * * } -{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } -{ * development of this library * } - -{ * ******************************************************************************* * } - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) - -{$MACRO ON} -{$IFDEF ENDIAN_BIG} - {$MESSAGE FATAL 'This Library does not support "Big Endian" processors yet.'} -{$ENDIF} -// FPC 3.0.4 and Above -// Had to Include this here since Delphi does not allow it Compile in "CryptoLib.inc". -{$IF FPC_FULLVERSION < 30004} - {$MESSAGE ERROR 'This Library requires FreePascal 3.0.4 or higher.'} -{$IFEND} - -{$IF FPC_FULLVERSION > 30004} - {$DEFINE FPC_GREATER_THAN_3.0.4} -{$IFEND} - -{$IF FPC_FULLVERSION >= 30301} - {$DEFINE HAS_VOLATILE} -{$IFEND} diff --git a/CryptoLib/src/Math/ClpBigInteger.pas b/CryptoLib/src/Math/ClpBigInteger.pas index 8fad9f95..72eed8f0 100644 --- a/CryptoLib/src/Math/ClpBigInteger.pas +++ b/CryptoLib/src/Math/ClpBigInteger.pas @@ -3313,13 +3313,9 @@ procedure TBigInteger.ParseString(const str: String; radix: Int32); end; -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(str); - HighPoint := System.High(str); -{$ELSE} LowPoint := 1; - HighPoint := System.length(str); -{$ENDIF DELPHIXE3_UP} + HighPoint := System.Length(str); + index := LowPoint; Fsign := 1; diff --git a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk index 0563505a..b52bd01d 100644 --- a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk +++ b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk @@ -24,7 +24,7 @@ Acknowledgements: Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the development of this library "/> - + @@ -147,7 +147,7 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - + diff --git a/CryptoLib/src/Security/ClpCipherUtilities.pas b/CryptoLib/src/Security/ClpCipherUtilities.pas index f38a0145..702d2633 100644 --- a/CryptoLib/src/Security/ClpCipherUtilities.pas +++ b/CryptoLib/src/Security/ClpCipherUtilities.pas @@ -172,13 +172,9 @@ class function TCipherUtilities.GetDigitIndex(const s: String): Int32; var i, LowPoint, HighPoint: Int32; begin -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(s); - HighPoint := System.High(s); -{$ELSE} LowPoint := 1; HighPoint := System.Length(s); -{$ENDIF DELPHIXE3_UP} + For i := LowPoint to HighPoint do begin if (CharInSet(s[i], ['0' .. '9'])) then @@ -345,11 +341,7 @@ class function TCipherUtilities.GetCipher(algorithm: String): IBufferedCipher; di := GetDigitIndex(mode); if di >= 0 then begin -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(mode); -{$ELSE} LowPoint := 1; -{$ENDIF DELPHIXE3_UP} modeName := System.Copy(mode, LowPoint, di); end else @@ -389,11 +381,7 @@ class function TCipherUtilities.GetCipher(algorithm: String): IBufferedCipher; end else begin -{$IFDEF DELPHIXE3_UP} - HighPoint := System.High(mode); -{$ELSE} HighPoint := System.Length(mode); -{$ENDIF DELPHIXE3_UP} bits := StrToInt(System.Copy(mode, di, HighPoint - di)); end; @@ -420,11 +408,7 @@ class function TCipherUtilities.GetCipher(algorithm: String): IBufferedCipher; end else begin -{$IFDEF DELPHIXE3_UP} - HighPoint := System.High(mode); -{$ELSE} HighPoint := System.Length(mode); -{$ENDIF DELPHIXE3_UP} bits := StrToInt(System.Copy(mode, di, HighPoint - di)); end; diff --git a/CryptoLib/src/Security/ClpMacUtilities.pas b/CryptoLib/src/Security/ClpMacUtilities.pas index b06e531b..46711b83 100644 --- a/CryptoLib/src/Security/ClpMacUtilities.pas +++ b/CryptoLib/src/Security/ClpMacUtilities.pas @@ -129,11 +129,7 @@ class function TMacUtilities.GetMac(const algorithm: string): IMac; if TStringUtils.BeginsWith(mechanism, 'HMAC', True) then begin -{$IFDEF DELPHIXE3_UP} - HighPoint := System.High(mechanism); -{$ELSE} HighPoint := System.Length(mechanism); -{$ENDIF DELPHIXE3_UP} if ((TStringUtils.BeginsWith(mechanism, 'HMAC-', True)) or (TStringUtils.BeginsWith(mechanism, 'HMAC/', True))) then begin diff --git a/CryptoLib/src/Security/ClpSecureRandom.pas b/CryptoLib/src/Security/ClpSecureRandom.pas index 5490c5f0..0066e932 100644 --- a/CryptoLib/src/Security/ClpSecureRandom.pas +++ b/CryptoLib/src/Security/ClpSecureRandom.pas @@ -342,13 +342,10 @@ class function TSecureRandom.GetInstance(const algorithm: String; LowPoint, HighPoint: Int32; begin upper := UpperCase(algorithm); -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(upper); - HighPoint := System.High(upper); -{$ELSE} + LowPoint := 1; HighPoint := System.length(upper); -{$ENDIF DELPHIXE3_UP} + if AnsiEndsStr('PRNG', upper) then begin digestName := System.Copy(upper, LowPoint, diff --git a/CryptoLib/src/Utils/ClpStringUtils.pas b/CryptoLib/src/Utils/ClpStringUtils.pas index 1cda4add..5bb5400b 100644 --- a/CryptoLib/src/Utils/ClpStringUtils.pas +++ b/CryptoLib/src/Utils/ClpStringUtils.pas @@ -87,13 +87,10 @@ class function TStringUtils.GetStringHashCode(const Input: string): Int32; LResult: UInt32; begin LResult := 0; -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(Input); - HighPoint := System.High(Input); -{$ELSE} + LowPoint := 1; HighPoint := System.Length(Input); -{$ENDIF DELPHIXE3_UP} + while LowPoint <= HighPoint do begin LResult := TBits.RotateLeft32(LResult, 5); @@ -168,13 +165,9 @@ class function TStringUtils.SplitString(const Input: string; Delimiter: Char) if Input <> '' then begin { Determine the length of the resulting array } -{$IFDEF DELPHIXE3_UP} - LowPoint := System.Low(Input); - HighPoint := System.High(Input); -{$ELSE} LowPoint := 1; HighPoint := System.Length(Input); -{$ENDIF DELPHIXE3_UP} + SplitPoints := 0; for I := LowPoint to HighPoint do begin