Browse Source

Merge branch 'master' into travis

Ugochukwu Mmaduekwe 7 years ago
parent
commit
e19399fe41

+ 0 - 159
.travis.install.py

@@ -1,159 +0,0 @@
-#!/usr/bin/env python
-# Part of `travis-lazarus` (https://github.com/nielsAD/travis-lazarus)
-# License: MIT
-
-import sys
-import os
-import subprocess
-
-OS_NAME=os.environ.get('TRAVIS_OS_NAME') or 'linux'
-OS_PMAN={'linux': 'sudo apt-get', 'osx': 'brew'}[OS_NAME]
-
-LAZ_TMP_DIR=os.environ.get('LAZ_TMP_DIR') or 'lazarus_tmp'
-LAZ_REL_DEF=os.environ.get('LAZ_REL_DEF') or {'linux':'amd64', 'qemu-arm':'amd64', 'qemu-arm-static':'amd64', 'osx':'i386', 'wine':'32'}
-LAZ_BIN_SRC=os.environ.get('LAZ_BIN_SRC') or 'http://mirrors.iwi.me/lazarus/releases/%(target)s/Lazarus%%20%(version)s'
-LAZ_BIN_TGT=os.environ.get('LAZ_BIN_TGT') or {
-    'linux':           'Lazarus%%20Linux%%20%(release)s%%20DEB',
-    'qemu-arm':        'Lazarus%%20Linux%%20%(release)s%%20DEB',
-    'qemu-arm-static': 'Lazarus%%20Linux%%20%(release)s%%20DEB',
-    'osx':             'Lazarus%%20Mac%%20OS%%20X%%20%(release)s',
-    'wine':            'Lazarus%%20Windows%%20%(release)s%%20bits'
-}
-
-def install_osx_dmg(dmg):
-    try:
-        # Mount .dmg file and parse (automatically determined) target volumes
-        res = subprocess.check_output('sudo hdiutil attach %s | grep /Volumes/' % (dmg), shell=True)
-        vol = ('/Volumes/' + l.strip().split('/Volumes/')[-1] for l in res.splitlines() if '/Volumes/' in l)
-    except:
-        return False
-
-    # Install .pkg files with installer
-    install_pkg = lambda v, f: os.system('sudo installer -pkg %s/%s -target /' % (v, f)) == 0
-
-    for v in vol:
-        try:
-            if not all(map(lambda f: (not f.endswith('.pkg')) or install_pkg(v, f), os.listdir(v))):
-                return False
-        finally:
-            # Unmount after installation
-            os.system('hdiutil detach %s' % (v))
-
-    return True
-
-def install_lazarus_default():
-    if OS_NAME == 'linux':
-        # Make sure nogui is installed for headless runs
-        pkg = 'lazarus lcl-nogui'
-    elif OS_NAME == 'osx':
-        # Install brew cask first
-        pkg = 'fpc caskroom/cask/brew-cask && %s cask install fpcsrc lazarus' % (OS_PMAN)
-    else:
-        # Default to lazarus
-        pkg = 'lazarus'
-    return os.system('%s install %s' % (OS_PMAN, pkg)) == 0
-
-def install_lazarus_version(ver,rel,env):
-    # Download all files in directory for specified Lazarus version
-    osn = env or OS_NAME
-    tgt = LAZ_BIN_TGT[osn] % {'release': rel or LAZ_REL_DEF[osn]}
-    src = LAZ_BIN_SRC % {'target': tgt, 'version': ver}
-    if os.system('wget -r -l1 -T 30 -np -nd -nc -A .deb,.dmg,.exe %s -P %s' % (src, LAZ_TMP_DIR)) != 0:
-        return False
-
-    if osn == 'wine':
-        # Install wine and Xvfb
-        if os.system('sudo dpkg --add-architecture i386 && %s update && %s install xvfb wine' % (OS_PMAN, OS_PMAN)) != 0:
-            return False
-
-        # Initialize virtual display and wine directory
-        if os.system('Xvfb %s & sleep 3 && wineboot -i' % (os.environ.get('DISPLAY') or '')) != 0:
-            return False
-
-        # Install basic Wine prerequisites, ignore failure
-        os.system('winetricks -q corefonts')
-
-        # Install all .exe files with wine
-        process_file = lambda f: (not f.endswith('.exe')) or os.system('wine %s /VERYSILENT /DIR="c:\\lazarus"' % (f)) == 0
-    elif osn == 'qemu-arm' or osn == 'qemu-arm-static':
-        # Install qemu and arm cross compiling utilities
-        if os.system('%s install libgtk2.0-dev qemu-user qemu-user-static binutils-arm-linux-gnueabi gcc-arm-linux-gnueabi' % (OS_PMAN)) != 0:
-            return False
-
-        # Install all .deb files (for linux) and cross compile later
-        process_file = lambda f: (not f.endswith('.deb')) or os.system('sudo dpkg --force-overwrite -i %s' % (f)) == 0
-    elif osn == 'linux':
-        # Install dependencies
-        if os.system('%s install libgtk2.0-dev' % (OS_PMAN)) != 0:
-            return False
-
-        # Install all .deb files
-        process_file = lambda f: (not f.endswith('.deb')) or os.system('sudo dpkg --force-overwrite -i %s' % (f)) == 0
-    elif osn == 'osx':
-        # Install all .dmg files
-        process_file = lambda f: (not f.endswith('.dmg')) or install_osx_dmg(f)
-    else:
-        return False
-
-    # Process all downloaded files
-    if not all(map(lambda f: process_file(os.path.join(LAZ_TMP_DIR, f)), sorted(os.listdir(LAZ_TMP_DIR)))):
-        return False
-
-    if osn == 'wine':
-        # Set wine Path (persistently) to include Lazarus binary directory
-        if os.system('wine cmd /C reg add HKEY_CURRENT_USER\\\\Environment /v PATH /t REG_SZ /d "%PATH%\\;c:\\\\lazarus"') != 0:
-            return False
-
-        # Redirect listed executables so they execute in wine
-        for alias in ('fpc', 'lazbuild', 'lazarus'):
-            os.system('echo "#!/usr/bin/env bash \nwine %(target)s \$@" | sudo tee %(name)s > /dev/null && sudo chmod +x %(name)s' % {
-                'target': subprocess.check_output("find $WINEPREFIX -iname '%s.exe' | head -1 " % (alias), shell=True).strip(),
-                'name': '/usr/bin/%s' % (alias)
-            })
-    elif osn == 'qemu-arm' or osn == 'qemu-arm-static':
-        fpcv = subprocess.check_output('fpc -iV', shell=True).strip()
-        gccv = subprocess.check_output('arm-linux-gnueabi-gcc -dumpversion', shell=True).strip()
-        opts = ' '.join([
-            'CPU_TARGET=arm',
-            'OS_TARGET=linux',
-            'BINUTILSPREFIX=arm-linux-gnueabi-',
-            # 'CROSSOPT="-CpARMV7A -CfVFPV3_D16"',
-            'OPT=-dFPC_ARMEL',
-            'INSTALL_PREFIX=/usr'
-        ])
-
-        # Compile ARM cross compiler
-        if os.system('cd /usr/share/fpcsrc/%s && sudo make clean crossall crossinstall %s' % (fpcv, opts)) != 0:
-            return False
-        
-        # Symbolic link to update default FPC cross compiler for ARM
-        if os.system('sudo ln -sf /usr/lib/fpc/%s/ppcrossarm /usr/bin/ppcarm' % (fpcv)) != 0:
-            return False
-
-        # Update config file with paths to ARM libraries
-        config = '\n'.join([
-            '#INCLUDE /etc/fpc.cfg',
-            '#IFDEF CPUARM',
-            '-Xd','-Xt',
-            '-XParm-linux-gnueabi-',
-            '-Fl/usr/arm-linux-gnueabi/lib',
-            '-Fl/usr/lib/gcc/arm-linux-gnueabi/%s' % (gccv),
-            '-Fl/usr/lib/gcc-cross/arm-linux-gnueabi/%s' % (gccv),
-            # '-CpARMV7A', '-CfVFPV3_D16',
-            '#ENDIF',
-            ''
-        ])
-        with open(os.path.expanduser('~/.fpc.cfg'),'w') as f:
-            f.write(config)
-
-    return True
-
-def install_lazarus(ver=None,rel=None,env=None):
-    return install_lazarus_version(ver,rel,env) if ver else install_lazarus_default()
-
-def main():
-    os.system('%s update' % (OS_PMAN))
-    return install_lazarus(os.environ.get('LAZ_VER'),os.environ.get('LAZ_REL'),os.environ.get('LAZ_ENV'))
-
-if __name__ == '__main__':
-    sys.exit(int(not main()))

+ 0 - 80
.travis.yml

@@ -1,80 +0,0 @@
-# Part of `travis-lazarus` (https://github.com/nielsAD/travis-lazarus)
-# License: MIT
-
-language: generic
-sudo: required
-dist: trusty
-
-os:
-  - linux
-  - osx
-
-env:
-  global:
-    - WINEPREFIX=~/.winelaz
-    - DISPLAY=:99.0
-  matrix:
-   # - LAZ_PKG=true  # Use the latest version from the default package manager
-    - LAZ_VER=1.6.4 # Use specific (binary) release
-    - LAZ_VER=1.8.0
-    - LAZ_VER=1.8.4
-
-matrix:
-  include:
-    - os: linux
-      env: LAZ_VER=1.6.4  LAZ_ENV=wine WINEARCH=win32 LAZ_OPT="--os=win32 --cpu=i386"
-    - os: linux
-      env: LAZ_VER=1.8.0 LAZ_ENV=wine WINEARCH=win32 LAZ_OPT="--os=win32 --cpu=i386"
-    - os: linux
-      env: LAZ_VER=1.8.4 LAZ_ENV=wine WINEARCH=win32 LAZ_OPT="--os=win32 --cpu=i386"
-    - os: linux
-      env: LAZ_VER=1.6.4  LAZ_ENV=wine WINEARCH=win64 LAZ_OPT="--os=win64 --cpu=x86_64"
-    - os: linux
-      env: LAZ_VER=1.8.0 LAZ_ENV=wine WINEARCH=win64 LAZ_OPT="--os=win64 --cpu=x86_64"
-    - os: linux
-      env: LAZ_VER=1.8.4 LAZ_ENV=wine WINEARCH=win64 LAZ_OPT="--os=win64 --cpu=x86_64"
-    - os: linux
-      env: LAZ_VER=1.6.4  LAZ_ENV=qemu-arm LAZ_OPT="--os=linux --cpu=arm"
-    - os: linux
-      env: LAZ_VER=1.8.0 LAZ_ENV=qemu-arm LAZ_OPT="--os=linux --cpu=arm"
-    - os: linux
-      env: LAZ_VER=1.8.4 LAZ_ENV=qemu-arm LAZ_OPT="--os=linux --cpu=arm"
-
-before_install:
-  # Start virtual display server
-  - Xvfb $DISPLAY &
-  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
-          sudo apt-get update;
-          sudo apt-get install binutils-2.26;
-          sudo ln -sf /usr/lib/binutils-2.26/bin/* /usr/bin/;
-          sudo ln -sf /usr/lib/binutils-2.26/ldscripts/* /usr/lib/ldscripts/;
-    fi
-  - chmod +x .travis.install.py 
-
-install:
-  # Install prerequisites (fpc/lazarus/wine/qemu)
-  - ./.travis.install.py
-
-script:
-  - curl -L -k https://github.com/Xor-el/HashLib4Pascal/archive/master.zip -o HashLib4Pascal.zip
-  - curl -L -k https://github.com/Xor-el/SimpleBaseLib4Pascal/archive/master.zip -o SimpleBaseLib4Pascal.zip
-  - curl -L -k https://github.com/Xor-el/generics.collections/archive/master.zip -o generics.collections.zip
-  - unzip HashLib4Pascal.zip
-  - unzip SimpleBaseLib4Pascal.zip
-  - unzip generics.collections.zip
-  - lazbuild --add-package-link ./HashLib4Pascal-master/HashLib/src/Packages/FPC/HashLib4PascalPackage.lpk  # Add HashLib4Pascal Package
-  - lazbuild --add-package-link ./SimpleBaseLib4Pascal-master/SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk  # Add SimpleBaseLib4Pascal Package
-  - lazbuild --add-package-link ./generics.collections-master/generics_collections.lpk  # Add generics.collections Package
-  - lazbuild $LAZ_OPT ./HashLib4Pascal-master/HashLib/src/Packages/FPC/HashLib4PascalPackage.lpk  # Build HashLib4Pascal Package
-  - lazbuild $LAZ_OPT ./SimpleBaseLib4Pascal-master/SimpleBaseLib/src/Packages/FPC/SimpleBaseLib4PascalPackage.lpk  # Build SimpleBaseLib4Pascal Package
-  - lazbuild $LAZ_OPT ./generics.collections-master/generics_collections.lpk  # Build generics.collections Package
-  - lazbuild $LAZ_OPT ./CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk  # Build CryptoLib4Pascal Package
-  - lazbuild $LAZ_OPT ./CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.Tests.lpi  # Build CryptoLib4Pascal Test Project
-  - travis_wait 120 $LAZ_ENV ./CryptoLib.Tests/FreePascal.Tests/bin/CryptoLib --all --format=plain --progress # Run CryptoLib4Pascal TestSuite with timeout of 120 mins
- # - travis_wait 120 $LAZ_ENV ./CryptoLib.Tests/FreePascal.Tests/bin/CryptoLib --format=plain --suite=TTestMD5HMac --progress  # Run TTestMD5HMac TestSuite with timeout of 120 mins
-
-
-notifications:
-  email:
-    on_success: false
-    on_failure: change

+ 1 - 1
CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr

@@ -41,7 +41,7 @@ uses
   SHA512HMacTests,
   RIPEMD128HMacTests,
   RIPEMD160HMacTests,
- // HMacTests, stalling on x64 windows on travis ci
+  HMacTests,
   Pkcs5Tests,
   HkdfGeneratorTests,
   ECIESTests,

+ 6 - 4
CryptoLib/src/Crypto/Signers/ClpECDsaSigner.pas

@@ -39,6 +39,7 @@ uses
   ClpRandomDsaKCalculator,
   ClpIECKeyParameters,
   ClpIDsaKCalculator,
+  ClpECCurveConstants,
   ClpIDsaExt,
   ClpIECDsaSigner;
 
@@ -229,14 +230,15 @@ function TECDsaSigner.GetDenominator(coordinateSystem: Int32; const p: IECPoint)
   : IECFieldElement;
 begin
   case (coordinateSystem) of
-    TECCurve.COORD_HOMOGENEOUS, TECCurve.COORD_LAMBDA_PROJECTIVE,
-      TECCurve.COORD_SKEWED:
+    TECCurveConstants.COORD_HOMOGENEOUS,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE, TECCurveConstants.COORD_SKEWED:
       begin
         Result := p.GetZCoord(0);
       end;
 
-    TECCurve.COORD_JACOBIAN, TECCurve.COORD_JACOBIAN_CHUDNOVSKY,
-      TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN,
+      TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY,
+      TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         Result := p.GetZCoord(0).Square();
       end

+ 98 - 89
CryptoLib/src/Math/EC/ClpECC.pas

@@ -42,12 +42,12 @@ uses
   ClpWTauNafMultiplier,
   ClpFiniteFields,
   ClpSetWeakRef,
+  ClpECCurveConstants,
   ClpTnaf,
   ClpValidityPrecompInfo,
   ClpIValidityPrecompInfo,
   ClpIECC,
   ClpIFiniteField,
-  ClpECCurveConstants,
   ClpIPreCompInfo;
 
 resourcestring
@@ -533,18 +533,8 @@ type
 
   public
 
-    const
-
-    COORD_AFFINE = Int32(0);
-    COORD_HOMOGENEOUS = Int32(1);
-    COORD_JACOBIAN = Int32(2);
-    COORD_JACOBIAN_CHUDNOVSKY = Int32(3);
-    COORD_JACOBIAN_MODIFIED = Int32(4);
-    COORD_LAMBDA_AFFINE = Int32(5);
-    COORD_LAMBDA_PROJECTIVE = Int32(6);
-    COORD_SKEWED = Int32(7);
+    type
 
-  type
     TConfig = class(TInterfacedObject, IConfig)
 
     strict protected
@@ -763,7 +753,7 @@ type
 
   strict private
   const
-    FP_DEFAULT_COORDS = Int32(TECCurve.COORD_JACOBIAN_MODIFIED);
+    FP_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_JACOBIAN_MODIFIED);
 
   strict protected
   var
@@ -878,7 +868,7 @@ type
 
   strict private
   const
-    F2M_DEFAULT_COORDS = Int32(TECCurve.COORD_LAMBDA_PROJECTIVE);
+    F2M_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_LAMBDA_PROJECTIVE);
 
   var
     // /**
@@ -2770,9 +2760,12 @@ end;
 
 class function TECCurve.GetAllCoordinateSystems: TCryptoLibInt32Array;
 begin
-  result := TCryptoLibInt32Array.Create(COORD_AFFINE, COORD_HOMOGENEOUS,
-    COORD_JACOBIAN, COORD_JACOBIAN_CHUDNOVSKY, COORD_JACOBIAN_MODIFIED,
-    COORD_LAMBDA_AFFINE, COORD_LAMBDA_PROJECTIVE, COORD_SKEWED);
+  result := TCryptoLibInt32Array.Create(TECCurveConstants.COORD_AFFINE,
+    TECCurveConstants.COORD_HOMOGENEOUS, TECCurveConstants.COORD_JACOBIAN,
+    TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY,
+    TECCurveConstants.COORD_JACOBIAN_MODIFIED,
+    TECCurveConstants.COORD_LAMBDA_AFFINE,
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE, TECCurveConstants.COORD_SKEWED);
 end;
 
 function TECCurve.GetB: IECFieldElement;
@@ -2884,7 +2877,7 @@ var
 begin
   CheckPoints(points, off, len);
   case CoordinateSystem of
-    COORD_AFFINE, COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         if (iso <> Nil) then
         begin
@@ -2984,7 +2977,7 @@ end;
 
 function TECCurve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
-  result := coord = COORD_AFFINE;
+  result := coord = TECCurveConstants.COORD_AFFINE;
 end;
 
 function TECCurve.ValidatePoint(const x, y: TBigInteger;
@@ -3203,11 +3196,14 @@ end;
 
 function TFpCurve.ImportPoint(const P: IECPoint): IECPoint;
 begin
-  if ((Self as IECCurve <> P.curve) and (CoordinateSystem = COORD_JACOBIAN) and
-    (not P.IsInfinity)) then
+  if ((Self as IECCurve <> P.curve) and
+    (CoordinateSystem = TECCurveConstants.COORD_JACOBIAN) and (not P.IsInfinity))
+  then
   begin
     case P.curve.CoordinateSystem of
-      COORD_JACOBIAN, COORD_JACOBIAN_CHUDNOVSKY, COORD_JACOBIAN_MODIFIED:
+      TECCurveConstants.COORD_JACOBIAN,
+        TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY,
+        TECCurveConstants.COORD_JACOBIAN_MODIFIED:
         begin
           result := TFpPoint.Create(Self as IECCurve,
             FromBigInteger(P.RawXCoord.ToBigInteger()),
@@ -3225,7 +3221,9 @@ end;
 function TFpCurve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_AFFINE, COORD_HOMOGENEOUS, COORD_JACOBIAN, COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_HOMOGENEOUS,
+      TECCurveConstants.COORD_JACOBIAN,
+      TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         result := true;
       end
@@ -3285,7 +3283,8 @@ begin
   LY := FromBigInteger(y);
 
   case CoordinateSystem of
-    COORD_LAMBDA_AFFINE, COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_AFFINE,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         if (Lx.IsZero) then
         begin
@@ -3329,7 +3328,8 @@ begin
       end;
 
       case CoordinateSystem of
-        COORD_LAMBDA_AFFINE, COORD_LAMBDA_PROJECTIVE:
+        TECCurveConstants.COORD_LAMBDA_AFFINE,
+          TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
           begin
             yp := z.Add(xp);
           end
@@ -3611,7 +3611,8 @@ end;
 function TF2mCurve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_AFFINE, COORD_HOMOGENEOUS, COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_HOMOGENEOUS,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         result := true;
       end
@@ -3769,7 +3770,7 @@ begin
   end;
 
   case CurveCoordinateSystem of
-    TECCurve.COORD_AFFINE, TECCurve.COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         result := Self;
         Exit;
@@ -4053,7 +4054,7 @@ begin
   // Cope with null curve, most commonly used by implicitlyCa
   if curve = Nil then
   begin
-    coord := TECCurve.COORD_AFFINE;
+    coord := TECCurveConstants.COORD_AFFINE;
   end
   else
   begin
@@ -4061,7 +4062,7 @@ begin
   end;
 
   case coord of
-    TECCurve.COORD_AFFINE, TECCurve.COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         result := FEMPTY_ZS;
         Exit;
@@ -4072,20 +4073,20 @@ begin
 
   case coord of
 
-    TECCurve.COORD_HOMOGENEOUS, TECCurve.COORD_JACOBIAN,
-      TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_HOMOGENEOUS, TECCurveConstants.COORD_JACOBIAN,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         result := TCryptoLibGenericArray<IECFieldElement>.Create(One);
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN_CHUDNOVSKY:
+    TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY:
       begin
         result := TCryptoLibGenericArray<IECFieldElement>.Create(One, One, One);
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         result := TCryptoLibGenericArray<IECFieldElement>.Create(One, curve.a);
         Exit;
@@ -4167,8 +4168,8 @@ var
 begin
   coord := CurveCoordinateSystem;
 
-  result := (coord = TECCurve.COORD_AFFINE) or
-    (coord = TECCurve.COORD_LAMBDA_AFFINE) or (IsInfinity) or
+  result := (coord = TECCurveConstants.COORD_AFFINE) or
+    (coord = TECCurveConstants.COORD_LAMBDA_AFFINE) or (IsInfinity) or
     (RawZCoords[0].IsOne);
 end;
 
@@ -4187,14 +4188,16 @@ var
   zInv2, zInv3: IECFieldElement;
 begin
   case CurveCoordinateSystem of
-    TECCurve.COORD_HOMOGENEOUS, TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_HOMOGENEOUS,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         result := CreateScaledPoint(zInv, zInv);
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN, TECCurve.COORD_JACOBIAN_CHUDNOVSKY,
-      TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN,
+      TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY,
+      TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         zInv2 := zInv.Square();
         zInv3 := zInv2.Multiply(zInv);
@@ -4232,7 +4235,7 @@ begin
   // Cope with null curve, most commonly used by implicitlyCa
   if Fm_curve = Nil then
   begin
-    result := TECCurve.COORD_AFFINE;
+    result := TECCurveConstants.COORD_AFFINE;
   end
   else
   begin
@@ -4302,7 +4305,7 @@ begin
   x2 := b.RawXCoord;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         Y1 := RawYCoord;
         Y2 := b.RawYCoord;
@@ -4329,7 +4332,7 @@ begin
         result := TF2mPoint.Create(ecCurve, x3, Y3, IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         Y1 := RawYCoord;
         Z1 := RawZCoords[0];
@@ -4407,7 +4410,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         if (x1.IsZero) then
         begin
@@ -4555,7 +4558,8 @@ begin
   LY := RawYCoord;
 
   case CurveCoordinateSystem of
-    TECCurve.COORD_LAMBDA_AFFINE, TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_AFFINE,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         // Y is actually Lambda (X + Y/X) here
         result := LY.TestBitZero() <> Lx.TestBitZero();
@@ -4577,7 +4581,8 @@ begin
   coord := CurveCoordinateSystem;
 
   case coord of
-    TECCurve.COORD_LAMBDA_AFFINE, TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_AFFINE,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         Lx := RawXCoord;
         L := RawYCoord;
@@ -4590,7 +4595,7 @@ begin
 
         // Y is actually Lambda (X + Y/X) here; convert to affine value on the fly
         LY := L.Add(Lx).Multiply(Lx);
-        if (TECCurve.COORD_LAMBDA_PROJECTIVE = coord) then
+        if (TECCurveConstants.COORD_LAMBDA_PROJECTIVE = coord) then
         begin
           z := RawZCoords[0];
           if (not z.IsOne) then
@@ -4632,14 +4637,14 @@ begin
   coord := ecCurve.CoordinateSystem;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         bigY := RawYCoord;
         result := TF2mPoint.Create(ecCurve, Lx, bigY.Add(Lx), IsCompressed);
         Exit;
       end;
 
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         LY := RawYCoord;
         z := RawZCoords[0];
@@ -4648,14 +4653,14 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         L := RawYCoord;
         result := TF2mPoint.Create(ecCurve, Lx, L.AddOne(), IsCompressed);
         Exit;
       end;
 
-    TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         // L is actually Lambda (X + Y/X) here
         L := RawYCoord;
@@ -4701,7 +4706,7 @@ begin
 
   coord := ecCurve.CoordinateSystem;
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         Y1 := RawYCoord;
 
@@ -4713,7 +4718,7 @@ begin
         result := TF2mPoint.Create(ecCurve, x3, Y3, IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         Y1 := RawYCoord;
         Z1 := RawZCoords[0];
@@ -4753,7 +4758,7 @@ begin
           TCryptoLibGenericArray<IECFieldElement>.Create(Z3), IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         L1 := RawYCoord;
         Z1 := RawZCoords[0];
@@ -4889,7 +4894,7 @@ begin
   coord := ecCurve.CoordinateSystem;
 
   case coord of
-    TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
 
         // NOTE: twicePlus() only optimized for lambda-affine argument
@@ -5061,12 +5066,12 @@ begin
   lhs := LY.Square();
 
   case CurveCoordinateSystem of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         // do nothing
       end;
 
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         z := RawZCoords[0];
         if (not z.IsOne) then
@@ -5079,8 +5084,9 @@ begin
         end;
       end;
 
-    TECCurve.COORD_JACOBIAN, TECCurve.COORD_JACOBIAN_CHUDNOVSKY,
-      TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN,
+      TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY,
+      TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         z := RawZCoords[0];
         if (not z.IsOne) then
@@ -5155,7 +5161,7 @@ begin
   Y2 := b.RawYCoord;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
 
         dx := x2.Subtract(x1);
@@ -5182,7 +5188,7 @@ begin
         result := TFpPoint.Create(curve, x3, Y3, IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         Z1 := RawZCoords[0];
         Z2 := b.RawZCoords[0];
@@ -5274,7 +5280,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN, TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN, TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         Z1 := RawZCoords[0];
         Z2 := b.RawZCoords[0];
@@ -5400,7 +5406,7 @@ begin
           end;
         end;
 
-        if (coord = TECCurve.COORD_JACOBIAN_MODIFIED) then
+        if (coord = TECCurveConstants.COORD_JACOBIAN_MODIFIED) then
         begin
           // TODO If the result will only be used in a subsequent addition, we don't need W3
           W3 := CalculateJacobianModifiedW(Z3, Z3Squared);
@@ -5525,8 +5531,8 @@ end;
 
 function TFpPoint.GetZCoord(index: Int32): IECFieldElement;
 begin
-  if ((index = 1) and (TECCurve.COORD_JACOBIAN_MODIFIED = CurveCoordinateSystem))
-  then
+  if ((index = 1) and (TECCurveConstants.COORD_JACOBIAN_MODIFIED =
+    CurveCoordinateSystem)) then
   begin
     result := GetJacobianModifiedW();
     Exit;
@@ -5549,7 +5555,7 @@ begin
   Lcurve := curve;
   coord := Lcurve.CoordinateSystem;
 
-  if (TECCurve.COORD_AFFINE <> coord) then
+  if (TECCurveConstants.COORD_AFFINE <> coord) then
   begin
     result := TFpPoint.Create(Lcurve, RawXCoord, RawYCoord.Negate(), RawZCoords,
       IsCompressed);
@@ -5588,7 +5594,7 @@ begin
   coord := ecCurve.CoordinateSystem;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
 
         x1 := RawXCoord;
@@ -5615,7 +5621,7 @@ begin
         result := TFpPoint.Create(curve, X4, Y4, IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         result := TwiceJacobianModified(false).Add(Self);
         Exit;
@@ -5677,19 +5683,19 @@ begin
   if (not Z1.IsOne) then
   begin
     case coord of
-      TECCurve.COORD_HOMOGENEOUS:
+      TECCurveConstants.COORD_HOMOGENEOUS:
         begin
           Z1Sq := Z1.Square();
           x1 := x1.Multiply(Z1);
           Y1 := Y1.Multiply(Z1Sq);
           W1 := CalculateJacobianModifiedW(Z1, Z1Sq);
         end;
-      TECCurve.COORD_JACOBIAN:
+      TECCurveConstants.COORD_JACOBIAN:
         begin
           W1 := CalculateJacobianModifiedW(Z1, Nil);
         end;
 
-      TECCurve.COORD_JACOBIAN_MODIFIED:
+      TECCurveConstants.COORD_JACOBIAN_MODIFIED:
         begin
           W1 := GetJacobianModifiedW();
         end;
@@ -5735,7 +5741,7 @@ begin
   end;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         zInv := Z1.Invert();
         zInv2 := zInv.Square();
@@ -5746,7 +5752,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         x1 := x1.Multiply(Z1);
         Z1 := Z1.Multiply(Z1.Square());
@@ -5754,14 +5760,14 @@ begin
           TCryptoLibGenericArray<IECFieldElement>.Create(Z1), IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_JACOBIAN:
+    TECCurveConstants.COORD_JACOBIAN:
       begin
         result := TFpPoint.Create(ecCurve, x1, Y1,
           TCryptoLibGenericArray<IECFieldElement>.Create(Z1), IsCompressed);
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         result := TFpPoint.Create(ecCurve, x1, Y1,
           TCryptoLibGenericArray<IECFieldElement>.Create(Z1, W1), IsCompressed);
@@ -5806,7 +5812,7 @@ begin
   x1 := RawXCoord;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         X1Squared := x1.Square();
         gamma := Three(X1Squared).Add(curve.a).Divide(Two(Y1));
@@ -5817,7 +5823,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_HOMOGENEOUS:
+    TECCurveConstants.COORD_HOMOGENEOUS:
       begin
         Z1 := RawZCoords[0];
 
@@ -5874,7 +5880,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN:
+    TECCurveConstants.COORD_JACOBIAN:
       begin
         Z1 := RawZCoords[0];
 
@@ -5951,7 +5957,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         result := TwiceJacobianModified(true);
         Exit;
@@ -6041,7 +6047,7 @@ begin
   coord := ecCurve.CoordinateSystem;
 
   case coord of
-    TECCurve.COORD_AFFINE:
+    TECCurveConstants.COORD_AFFINE:
       begin
         x1 := RawXCoord;
         x2 := b.RawXCoord;
@@ -6088,7 +6094,7 @@ begin
         result := TFpPoint.Create(curve, X4, Y4, IsCompressed);
         Exit;
       end;
-    TECCurve.COORD_JACOBIAN_MODIFIED:
+    TECCurveConstants.COORD_JACOBIAN_MODIFIED:
       begin
         result := TwiceJacobianModified(false).Add(b);
         Exit;
@@ -6141,7 +6147,7 @@ begin
   b := ecCurve.b;
 
   coord := ecCurve.CoordinateSystem;
-  if (coord = TECCurve.COORD_LAMBDA_PROJECTIVE) then
+  if (coord = TECCurveConstants.COORD_LAMBDA_PROJECTIVE) then
   begin
     z := RawZCoords[0];
     ZIsOne := z.IsOne;
@@ -6182,12 +6188,12 @@ begin
     lhs := LY.Add(x).Multiply(LY);
 
     case coord of
-      TECCurve.COORD_AFFINE:
+      TECCurveConstants.COORD_AFFINE:
         begin
           // do nothing;
         end;
 
-      TECCurve.COORD_HOMOGENEOUS:
+      TECCurveConstants.COORD_HOMOGENEOUS:
         begin
           z := RawZCoords[0];
           if (not z.IsOne) then
@@ -6275,7 +6281,7 @@ begin
   end;
 
   case CurveCoordinateSystem of
-    TECCurve.COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         // Y is actually Lambda (X + Y/X) here
         Lx := RawXCoord;
@@ -6288,7 +6294,7 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         // Y is actually Lambda (X + Y/X) here
         Lx := RawXCoord;
@@ -6324,7 +6330,8 @@ begin
   end;
 
   case CurveCoordinateSystem of
-    TECCurve.COORD_LAMBDA_AFFINE, TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_AFFINE,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         Lx := RawXCoord;
         L := RawYCoord;
@@ -6372,7 +6379,7 @@ begin
   x1 := RawXCoord;
 
   case coord of
-    TECCurve.COORD_AFFINE, TECCurve.COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         Y1 := RawYCoord;
         result := ecCurve.CreateRawPoint(x1.Square(), Y1.Square(), IsCompressed)
@@ -6380,7 +6387,8 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_HOMOGENEOUS, TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_HOMOGENEOUS,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         Y1 := RawYCoord;
         Z1 := RawZCoords[0];
@@ -6417,7 +6425,7 @@ begin
   x1 := RawXCoord;
 
   case coord of
-    TECCurve.COORD_AFFINE, TECCurve.COORD_LAMBDA_AFFINE:
+    TECCurveConstants.COORD_AFFINE, TECCurveConstants.COORD_LAMBDA_AFFINE:
       begin
         Y1 := RawYCoord;
         result := ecCurve.CreateRawPoint(x1.SquarePow(pow), Y1.SquarePow(pow),
@@ -6425,7 +6433,8 @@ begin
         Exit;
       end;
 
-    TECCurve.COORD_HOMOGENEOUS, TECCurve.COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_HOMOGENEOUS,
+      TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       begin
         Y1 := RawYCoord;
         Z1 := RawZCoords[0];

+ 3 - 2
CryptoLib/src/Math/EC/Custom/Sec/ClpSecP256K1Custom.pas

@@ -31,6 +31,7 @@ uses
   ClpBigInteger,
   ClpArrayUtils,
   ClpCryptoLibTypes,
+  ClpECCurveConstants,
   ClpIECC,
   ClpISecP256K1Custom;
 
@@ -233,7 +234,7 @@ type
     end;
 
   const
-    SECP256K1_DEFAULT_COORDS = Int32(TECCurve.COORD_JACOBIAN);
+    SECP256K1_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_JACOBIAN);
     SECP256K1_FE_INTS = Int32(8);
 
   var
@@ -1115,7 +1116,7 @@ end;
 function TSecP256K1Curve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_JACOBIAN:
+    TECCurveConstants.COORD_JACOBIAN:
       result := true
   else
     result := false;

+ 3 - 2
CryptoLib/src/Math/EC/Custom/Sec/ClpSecP256R1Custom.pas

@@ -31,6 +31,7 @@ uses
   ClpBigInteger,
   ClpArrayUtils,
   ClpCryptoLibTypes,
+  ClpECCurveConstants,
   ClpIECC,
   ClpISecP256R1Custom;
 
@@ -234,7 +235,7 @@ type
     end;
 
   const
-    SECP256R1_DEFAULT_COORDS = Int32(TECCurve.COORD_JACOBIAN);
+    SECP256R1_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_JACOBIAN);
     SECP256R1_FE_INTS = Int32(8);
 
   var
@@ -1258,7 +1259,7 @@ end;
 function TSecP256R1Curve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_JACOBIAN:
+    TECCurveConstants.COORD_JACOBIAN:
       result := true
   else
     result := false;

+ 3 - 2
CryptoLib/src/Math/EC/Custom/Sec/ClpSecP384R1Custom.pas

@@ -31,6 +31,7 @@ uses
   ClpBigInteger,
   ClpArrayUtils,
   ClpCryptoLibTypes,
+  ClpECCurveConstants,
   ClpIECC,
   ClpISecP384R1Custom;
 
@@ -232,7 +233,7 @@ type
     end;
 
   const
-    SECP384R1_DEFAULT_COORDS = Int32(TECCurve.COORD_JACOBIAN);
+    SECP384R1_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_JACOBIAN);
     SECP384R1_FE_INTS = Int32(12);
 
   var
@@ -1266,7 +1267,7 @@ end;
 function TSecP384R1Curve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_JACOBIAN:
+    TECCurveConstants.COORD_JACOBIAN:
       result := true
   else
     result := false;

+ 3 - 2
CryptoLib/src/Math/EC/Custom/Sec/ClpSecP521R1Custom.pas

@@ -32,6 +32,7 @@ uses
   ClpArrayUtils,
   ClpIECC,
   ClpCryptoLibTypes,
+  ClpECCurveConstants,
   ClpISecP521R1Custom;
 
 resourcestring
@@ -229,7 +230,7 @@ type
     end;
 
   const
-    SECP521R1_DEFAULT_COORDS = Int32(TECCurve.COORD_JACOBIAN);
+    SECP521R1_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_JACOBIAN);
     SECP521R1_FE_INTS = Int32(17);
 
   var
@@ -1059,7 +1060,7 @@ end;
 function TSecP521R1Curve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_JACOBIAN:
+    TECCurveConstants.COORD_JACOBIAN:
       result := true
   else
     result := false;

+ 3 - 2
CryptoLib/src/Math/EC/Custom/Sec/ClpSecT283Custom.pas

@@ -33,6 +33,7 @@ uses
   ClpIECC,
   ClpWTauNafMultiplier,
   ClpCryptoLibTypes,
+  ClpECCurveConstants,
   ClpISecT283Custom;
 
 resourcestring
@@ -271,7 +272,7 @@ type
     end;
 
   const
-    SECT283K1_DEFAULT_COORDS = Int32(TECCurve.COORD_LAMBDA_PROJECTIVE);
+    SECT283K1_DEFAULT_COORDS = Int32(TECCurveConstants.COORD_LAMBDA_PROJECTIVE);
     SECT283K1_FE_LONGS = Int32(5);
 
     function GetM: Int32; inline;
@@ -1520,7 +1521,7 @@ end;
 function TSecT283K1Curve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of
-    COORD_LAMBDA_PROJECTIVE:
+    TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
       result := true
   else
     result := false;

+ 6 - 9
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk

@@ -1105,23 +1105,20 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel
         <UnitName Value="ClpIECC"/>
       </Item269>
     </Files>
-    <RequiredPkgs Count="4">
+    <RequiredPkgs Count="3">
       <Item1>
-        <PackageName Value="generics_collections"/>
-      </Item1>
-      <Item2>
         <PackageName Value="HashLib4PascalPackage"/>
         <MaxVersion Major="2" Minor="4"/>
         <MinVersion Major="2" Minor="5" Valid="True"/>
-      </Item2>
-      <Item3>
+      </Item1>
+      <Item2>
         <PackageName Value="SimpleBaseLib4PascalPackage"/>
         <MaxVersion Major="1" Minor="2"/>
         <MinVersion Major="1" Minor="4" Valid="True"/>
-      </Item3>
-      <Item4>
+      </Item2>
+      <Item3>
         <PackageName Value="FCL"/>
-      </Item4>
+      </Item3>
     </RequiredPkgs>
     <UsageOptions>
       <UnitPath Value="$(PkgOutDir)"/>